summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/photon
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2009-06-30 22:00:12 +0000
committerFelipe Heidrich <fheidric>2009-06-30 22:00:12 +0000
commitf664d297f7bb009784868bf3fcf0b3e3bb9a646b (patch)
tree54012fe4929893eef4891c88cbbf5841272ff433 /bundles/org.eclipse.swt/Eclipse SWT/photon
parentbc18a5e014088ce811f09c603b88361094486062 (diff)
downloadeclipse.platform.swt-f664d297f7bb009784868bf3fcf0b3e3bb9a646b.tar.gz
eclipse.platform.swt-f664d297f7bb009784868bf3fcf0b3e3bb9a646b.tar.xz
eclipse.platform.swt-f664d297f7bb009784868bf3fcf0b3e3bb9a646b.zip
*** empty log message ***
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java238
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java464
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java627
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java265
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java456
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java174
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java3655
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java46
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java1046
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java638
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java67
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java662
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java310
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java515
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java151
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java1400
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java1165
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java3286
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java634
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java177
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java2737
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java369
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java211
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java223
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java464
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Link.java680
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java1259
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java844
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java921
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java221
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java292
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java422
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java378
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java725
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java245
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java1426
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java559
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Spinner.java824
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java756
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java344
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java1615
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java490
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java967
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java1057
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java1274
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java113
47 files changed, 0 insertions, 35415 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
deleted file mode 100755
index 2459e50106..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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
- * specify the individual color components as integers in the range
- * 0 to 255 or provide an instance of an <code>RGB</code>.
- * <p>
- * Application code must explicitly invoke the <code>Color.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- *
- * @see RGB
- * @see Device#getSystemColor
- * @see <a href="http://www.eclipse.org/swt/snippets/#color">Color and RGB snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: PaintExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public final class Color extends Resource {
-
- /**
- * the handle to the OS color resource
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int handle;
-
-Color(Device device) {
- super(device);
-}
-
-/**
- * Constructs a new instance of this class given a device and the
- * desired red, green and blue values expressed as ints in the range
- * 0 to 255 (where 0 is black and 255 is full brightness). On limited
- * color devices, the color instance created by this call may not have
- * the same RGB values as the ones specified by the arguments. The
- * RGB values on the returned instance will be the color values of
- * the operating system color.
- * <p>
- * You must dispose the color when it is no longer required.
- * </p>
- *
- * @param device the device on which to allocate the color
- * @param red the amount of red in the color
- * @param green the amount of green in the color
- * @param blue the amount of blue in the color
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
- * </ul>
- *
- * @see #dispose
- */
-public Color (Device device, int red, int green, int blue) {
- super(device);
- init(red, green, blue);
- init();
-}
-
-/**
- * Constructs a new instance of this class given a device and an
- * <code>RGB</code> describing the desired red, green and blue values.
- * On limited color devices, the color instance created by this call
- * may not have the same RGB values as the ones specified by the
- * argument. The RGB values on the returned instance will be the color
- * values of the operating system color.
- * <p>
- * You must dispose the color when it is no longer required.
- * </p>
- *
- * @param device the device on which to allocate the color
- * @param rgb the RGB values of the desired color
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
- * </ul>
- *
- * @see #dispose
- */
-public Color (Device device, RGB rgb) {
- super(device);
- if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(rgb.red, rgb.green, rgb.blue);
- init();
-}
-
-void destroy() {
- handle = -1;
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof 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.
- *
- * @return the blue component of the color
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns the amount of green in the color, from 0 to 255.
- *
- * @return the green component of the color
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns the amount of red in the color, from 0 to 255.
- *
- * @return the red component of the color
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns an <code>RGB</code> representing the receiver.
- *
- * @return the RGB for the color
- *
- * @exception SWTException <ul>
- * <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);
-}
-
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
-public int hashCode () {
- return handle;
-}
-
-void init(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);
- }
- handle = (blue & 0xFF) | ((green & 0xFF) << 8) | ((red & 0xFF) << 16);
-}
-
-/**
- * Returns <code>true</code> if the color has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the color.
- * When a color has been disposed, it is an error to
- * invoke any other method using the color.
- *
- * @return <code>true</code> when the color is disposed and <code>false</code> otherwise
- */
-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) {
- Color color = new Color(device);
- color.handle = handle;
- 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
deleted file mode 100755
index aa75bdbe01..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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
- * cursor you specify the device and either a simple cursor style
- * describing one of the standard operating system provided cursors
- * or the image and mask data for the desired appearance.
- * <p>
- * Application code must explicitly invoke the <code>Cursor.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>
- * CURSOR_ARROW, CURSOR_WAIT, CURSOR_CROSS, CURSOR_APPSTARTING, CURSOR_HELP,
- * CURSOR_SIZEALL, CURSOR_SIZENESW, CURSOR_SIZENS, CURSOR_SIZENWSE, CURSOR_SIZEWE,
- * CURSOR_SIZEN, CURSOR_SIZES, CURSOR_SIZEE, CURSOR_SIZEW, CURSOR_SIZENE, CURSOR_SIZESE,
- * CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
- * </dd>
- * </dl>
- * <p>
- * Note: Only one of the above styles may be specified.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#cursor">Cursor snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public final class Cursor extends Resource {
-
- /**
- * the type to the OS cursor resource
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int type;
-
- /**
- * the handle to the OS cursor resource
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int bitmap;
-
-Cursor(Device device) {
- super(device);
-}
-
-/**
- * Constructs a new cursor given a device and a style
- * constant describing the desired cursor appearance.
- * <p>
- * You must dispose the cursor when it is no longer required.
- * </p>
- *
- * @param device the device on which to allocate the cursor
- * @param style the style of cursor to allocate
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - when an unknown style is specified</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
- * </ul>
- *
- * @see SWT#CURSOR_ARROW
- * @see SWT#CURSOR_WAIT
- * @see SWT#CURSOR_CROSS
- * @see SWT#CURSOR_APPSTARTING
- * @see SWT#CURSOR_HELP
- * @see SWT#CURSOR_SIZEALL
- * @see SWT#CURSOR_SIZENESW
- * @see SWT#CURSOR_SIZENS
- * @see SWT#CURSOR_SIZENWSE
- * @see SWT#CURSOR_SIZEWE
- * @see SWT#CURSOR_SIZEN
- * @see SWT#CURSOR_SIZES
- * @see SWT#CURSOR_SIZEE
- * @see SWT#CURSOR_SIZEW
- * @see SWT#CURSOR_SIZENE
- * @see SWT#CURSOR_SIZESE
- * @see SWT#CURSOR_SIZESW
- * @see SWT#CURSOR_SIZENW
- * @see SWT#CURSOR_UPARROW
- * @see SWT#CURSOR_IBEAM
- * @see SWT#CURSOR_NO
- * @see SWT#CURSOR_HAND
- */
-public Cursor(Device device, int style) {
- super(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);
- init();
-}
-
-/**
- * Constructs a new cursor given a device, image and mask
- * data describing the desired cursor appearance, and the x
- * and y coordinates of the <em>hotspot</em> (that is, the point
- * within the area covered by the cursor which is considered
- * to be where the on-screen pointer is "pointing").
- * <p>
- * The mask data is allowed to be null, but in this case the source
- * must be an ImageData representing an icon that specifies both
- * color data and mask data.
- * <p>
- * You must dispose the cursor when it is no longer required.
- * </p>
- *
- * @param device the device on which to allocate the cursor
- * @param source the color data for the cursor
- * @param mask the mask data for the cursor (or null)
- * @param hotspotX the x coordinate of the cursor's hotspot
- * @param hotspotY the y coordinate of the cursor's hotspot
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the source is null</li>
- * <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li>
- * <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same
- * size, or if the hotspot is outside the bounds of the image</li>
- * </ul>
- * @exception SWTError <ul>
- * <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) {
- super(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 the hotspots */
- if (hotspotX >= source.width || hotspotX < 0 ||
- hotspotY >= source.height || hotspotY < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- /* Convert to depth 1 */
- mask = ImageData.convertMask(mask);
- source = ImageData.convertMask(source);
- 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);
- init();
-}
-
-/**
- * Constructs a new cursor given a device, image data describing
- * the desired cursor appearance, and the x and y coordinates of
- * the <em>hotspot</em> (that is, the point within the area
- * covered by the cursor which is considered to be where the
- * on-screen pointer is "pointing").
- * <p>
- * You must dispose the cursor when it is no longer required.
- * </p>
- *
- * @param device the device on which to allocate the cursor
- * @param source the image data for the cursor
- * @param hotspotX the x coordinate of the cursor's hotspot
- * @param hotspotY the y coordinate of the cursor's hotspot
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the hotspot is outside the bounds of the
- * image</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
- * </ul>
- *
- * @since 3.0
- */
-public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
- super(device);
- if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (hotspotX >= source.width || hotspotX < 0 ||
- hotspotY >= source.height || hotspotY < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- ImageData mask = source.getTransparencyMask();
-
- /* Ensure depth is equal to 1 */
- if (source.depth > 1) {
- /* Create a destination image with no data */
- ImageData newSource = new ImageData(
- source.width, source.height, 1, ImageData.bwPalette(),
- 1, null, 0, null, null, -1, -1, 0, 0, 0, 0, 0);
-
- byte[] newReds = new byte[]{0, (byte)255}, newGreens = newReds, newBlues = newReds;
-
- /* Convert the source to a black and white image of depth 1 */
- PaletteData palette = source.palette;
- if (palette.isDirect) {
- ImageData.blit(ImageData.BLIT_SRC,
- source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, palette.redMask, palette.greenMask, palette.blueMask,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, newReds, newGreens, newBlues,
- false, false);
- } else {
- RGB[] rgbs = palette.getRGBs();
- int length = rgbs.length;
- byte[] srcReds = new byte[length];
- byte[] srcGreens = new byte[length];
- byte[] srcBlues = new byte[length];
- for (int i = 0; i < rgbs.length; i++) {
- RGB rgb = rgbs[i];
- if (rgb == null) continue;
- srcReds[i] = (byte)rgb.red;
- srcGreens[i] = (byte)rgb.green;
- srcBlues[i] = (byte)rgb.blue;
- }
- ImageData.blit(ImageData.BLIT_SRC,
- source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, srcReds, srcGreens, srcBlues,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, newReds, newGreens, newBlues,
- false, false);
- }
- source = newSource;
- }
- 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 == 1) {
- // BLACK
- mask1_pixel = 0;
- mask2_pixel = 1;
- } else if (src_pixel == 1 && mask_pixel == 1) {
- // WHITE - cursor color
- mask1_pixel = 1;
- mask2_pixel = 0;
- } else if (src_pixel == 0 && 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);
- init();
-}
-
-void destroy() {
- if (type == OS.Ph_CURSOR_BITMAP && bitmap != 0) {
- OS.free(bitmap);
- }
- type = bitmap = 0;
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof 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 that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
-public int hashCode () {
- return bitmap ^ type;
-}
-
-/**
- * Returns <code>true</code> if the cursor has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the cursor.
- * When a cursor has been disposed, it is an error to
- * invoke any other method using the cursor.
- *
- * @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) {
- Cursor cursor = new Cursor(device);
- cursor.type = type;
- cursor.bitmap = bitmap;
- 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 + "}";
-}
-
-}
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
deleted file mode 100755
index c7db383959..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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.
- *
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public abstract class Device implements Drawable {
-
- /* Debugging */
- public static boolean DEBUG;
- boolean debug = DEBUG;
- boolean tracking = DEBUG;
- Error [] errors;
- Object [] objects;
- Object trackingLock;
-
- boolean disposed;
-
- Font 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.
- */
- protected static Device CurrentDevice;
- protected static Runnable DeviceFinder;
- static {
- try {
- Class.forName ("org.eclipse.swt.widgets.Display");
- } catch (ClassNotFoundException e) {}
- }
-
-static synchronized Device getDevice () {
- if (DeviceFinder != null) DeviceFinder.run();
- Device device = CurrentDevice;
- CurrentDevice = null;
- return device;
-}
-
-/**
- * Constructs a new instance of this class.
- * <p>
- * You must dispose the device when it is no longer required.
- * </p>
- *
- * @see #create
- * @see #init
- *
- * @since 3.1
- */
-public Device() {
- this(null);
-}
-
-/**
- * Constructs a new instance of this class.
- * <p>
- * You must dispose the device when it is no longer required.
- * </p>
- *
- * @param data the DeviceData which describes the receiver
- *
- * @see #create
- * @see #init
- * @see DeviceData
- */
-public Device(DeviceData data) {
- synchronized (Device.class) {
- if (data != null) {
- debug = data.debug;
- tracking = data.tracking;
- }
- if (tracking) {
- errors = new Error [128];
- objects = new Object [128];
- trackingLock = new Object ();
- }
- create (data);
- init ();
- }
-}
-
-/**
- * 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
- * device implementors to enforce the standard SWT invariants.
- * <p>
- * Currently, it is an error to invoke any method (other than
- * <code>isDisposed()</code> and <code>dispose()</code>) on a
- * device that has had its <code>dispose()</code> method called.
- * </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>
- * </ul>
- */
-protected void checkDevice () {
- if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
-}
-
-/**
- * Creates the device in the operating system. If the device
- * does not have a handle, this method may do nothing depending
- * on the device.
- * <p>
- * This method is called before <code>init</code>.
- * </p><p>
- * Subclasses are supposed to reimplement this method and not
- * call the <code>super</code> implementation.
- * </p>
- *
- * @param data the DeviceData which describes the receiver
- *
- * @see #init
- */
-protected void create (DeviceData data) {
-}
-
-/**
- * Destroys the device in the operating system and releases
- * the device's handle. If the device does not have a handle,
- * this method may do nothing depending on the device.
- * <p>
- * This method is called after <code>release</code>.
- * </p><p>
- * Subclasses are supposed to reimplement this method and not
- * call the <code>super</code> implementation.
- * </p>
- *
- * @see #dispose
- * @see #release
- */
-protected void destroy () {
-}
-
-/**
- * Disposes of the operating system resources associated with
- * the receiver. After this method has been invoked, the receiver
- * will answer <code>true</code> when sent the message
- * <code>isDisposed()</code>.
- *
- * @see #release
- * @see #destroy
- * @see #checkDevice
- */
-public void dispose () {
- synchronized (Device.class) {
- if (isDisposed()) return;
- checkDevice ();
- release ();
- destroy ();
- disposed = true;
- if (tracking) {
- synchronized (trackingLock) {
- objects = null;
- errors = null;
- trackingLock = null;
- }
- }
- }
-}
-
-void dispose_Object (Object object) {
- synchronized (trackingLock) {
- 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.
- *
- * @return the bounding rectangle
- *
- * @exception SWTException <ul>
- * <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);
-}
-
-/**
- * Returns a rectangle which describes the area of the
- * receiver which is capable of displaying data.
- *
- * @return the client area
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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);
-}
-
-/**
- * Returns the bit depth of the screen, which is the number of
- * bits it takes to represent the number of unique colors that
- * the screen is currently capable of displaying. This number
- * will typically be one of 1, 8, 15, 16, 24 or 32.
- *
- * @return the depth of the screen
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns a <code>DeviceData</code> based on the receiver.
- * Modifications made to this <code>DeviceData</code> will not
- * affect the receiver.
- *
- * @return a <code>DeviceData</code> containing the device's data and attributes
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see DeviceData
- */
-public DeviceData getDeviceData () {
- checkDevice();
- DeviceData data = new DeviceData ();
- data.debug = debug;
- data.tracking = tracking;
- if (tracking) {
- synchronized (trackingLock) {
- int count = 0, 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++;
- }
- }
- }
- } else {
- data.objects = new Object [0];
- data.errors = new Error [0];
- }
- return data;
-}
-
-/**
- * Returns a point whose x coordinate is the horizontal
- * dots per inch of the display, and whose y coordinate
- * is the vertical dots per inch of the display.
- *
- * @return the horizontal and vertical DPI
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-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
- * <code>faceName</code> is null, all fonts will be returned.
- *
- * @param faceName the name of the font to look for, or null
- * @param scalable if true only scalable fonts are returned, otherwise only non-scalable fonts are returned.
- * @return the matching font data
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns the matching standard color for the given
- * constant, which should be one of the color constants
- * specified in class <code>SWT</code>. Any value other
- * than one of the SWT color constants which is passed
- * in will result in the color black. This color should
- * not be freed because it was allocated by the system,
- * not the application.
- *
- * @param id the color constant
- * @return the matching color
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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);
-}
-
-/**
- * Returns a reasonable font for applications to use.
- * On some platforms, this will match the "default font"
- * or "system font" if such can be found. This font
- * should not be freed because it was allocated by the
- * system, not the application.
- * <p>
- * Typically, applications which want the default look
- * should simply not set the font on the widgets they
- * create. Widgets are always created with the correct
- * default font for the class of user-interface component
- * they represent.
- * </p>
- *
- * @return a font
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Font getSystemFont () {
- checkDevice ();
- return systemFont;
-}
-
-/**
- * Returns <code>true</code> if the underlying window system prints out
- * warning messages on the console, and <code>setWarnings</code>
- * had previously been called with <code>true</code>.
- *
- * @return <code>true</code>if warnings are being handled, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean getWarnings () {
- checkDevice ();
- return false;
-}
-
-/**
- * Initializes any internal resources needed by the
- * device.
- * <p>
- * This method is called after <code>create</code>.
- * </p><p>
- * If subclasses reimplement this method, they must
- * call the <code>super</code> implementation.
- * </p>
- *
- * @see #create
- */
-protected void init () {
- /* Initialize the system font slot */
- systemFont = getSystemFont ();
-}
-
-/**
- * Invokes platform specific functionality to allocate a new GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Device</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- */
-public abstract int internal_new_GC (GCData data);
-
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Device</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param hDC the platform specific GC handle
- * @param data the platform specific GC 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.
- * <p>
- * This method gets the dispose state for the device.
- * When a device has been disposed, it is an error to
- * invoke any other method using the device.
- *
- * @return <code>true</code> when the device is disposed and <code>false</code> otherwise
- */
-public boolean isDisposed () {
- synchronized (Device.class) {
- return disposed;
- }
-}
-
-/**
- * Loads the font specified by a file. The font will be
- * present in the list of fonts available to the application.
- *
- * @param path the font file path
- * @return whether the font was successfully loaded
- *
- * @exception SWTException <ul>
- * <li>ERROR_NULL_ARGUMENT - if path is null</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Font
- *
- * @since 3.3
- */
-public boolean loadFont (String path) {
- checkDevice();
- if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return false;
-}
-
-void new_Object (Object object) {
- synchronized (trackingLock) {
- 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;
- }
-}
-
-/**
- * Releases any internal resources back to the operating
- * system and clears all fields except the device handle.
- * <p>
- * When a device is destroyed, resources that were acquired
- * on behalf of the programmer need to be returned to the
- * operating system. For example, if the device allocated a
- * font to be used as the system font, this font would be
- * freed in <code>release</code>. Also,to assist the garbage
- * collector and minimize the amount of memory that is not
- * reclaimed when the programmer keeps a reference to a
- * disposed device, all fields except the handle are zero'd.
- * The handle is needed by <code>destroy</code>.
- * </p>
- * This method is called before <code>destroy</code>.
- * </p><p>
- * If subclasses reimplement this method, they must
- * call the <code>super</code> implementation.
- * </p>
- *
- * @see #dispose
- * @see #destroy
- */
-protected void release () {
-}
-
-/**
- * If the underlying window system supports printing warning messages
- * to the console, setting warnings to <code>false</code> prevents these
- * messages from being printed. If the argument is <code>true</code> then
- * message printing is not blocked.
- *
- * @param warnings <code>true</code>if warnings should be printed, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-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
deleted file mode 100755
index 9b95c99718..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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
deleted file mode 100755
index b3cece7cd1..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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
- * by providing a device and either name, size and style information
- * or a <code>FontData</code> object which encapsulates this data.
- * <p>
- * Application code must explicitly invoke the <code>Font.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- *
- * @see FontData
- * @see <a href="http://www.eclipse.org/swt/snippets/#font">Font snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, PaintExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public final class Font extends Resource {
-
- /**
- * the handle to the OS font resource
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public byte[] handle;
-
-Font(Device device) {
- super(device);
-}
-
-/**
- * Constructs a new font given a device and font data
- * 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 fd the 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 fd argument 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 fd) {
- super(device);
- if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(fd.getName(), fd.getHeight(), fd.getStyle(), fd.stem);
- init();
-}
-
-/**
- * Constructs a new font given a device and an array
- * of font data 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>
- *
- * @since 2.1
- */
-public Font(Device device, FontData[] fds) {
- super(device);
- if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- for (int i=0; i<fds.length; i++) {
- if (fds[i] == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- FontData fd = fds[0];
- init(fd.getName(), fd.getHeight(), fd.getStyle(), fd.stem);
- init();
-}
-/**
- * Constructs a new font given a device, a font name,
- * the height of the desired font in points, and a font
- * style.
- * <p>
- * You must dispose the font when it is no longer required.
- * </p>
- *
- * @param device the device to create the font on
- * @param name the name of the font (must not be null)
- * @param height the font height in points
- * @param style a bit or combination of NORMAL, BOLD, ITALIC
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
- * </ul>
- * @exception SWTError <ul>
- * <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) {
- super(device);
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(name, height, style, null);
- init();
-}
-
-void destroy() {
- handle = null;
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals(Object object) {
- if (object == this) return true;
- if (!(object instanceof 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,
- * a <code>Font</code> object <em>may</em> be composed of multiple X
- * fonts. To support this case, we return an array of font data objects.
- *
- * @return an array of font data objects describing the receiver
- *
- * @exception SWTException <ul>
- * <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)};
-}
-
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
-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.
- * <p>
- * This method gets the dispose state for the font.
- * When a font has been disposed, it is an error to
- * invoke any other method using the font.
- *
- * @return <code>true</code> when the font is disposed and <code>false</code> otherwise
- */
-public boolean isDisposed() {
- return handle == null;
-}
-
-void init(String name, int height, int style, byte[] stem) {
- if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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];
- if (OS.PfGenerateFontName(description, osStyle, height, buffer) != 0) handle = buffer;
- if (handle == null) {
- byte[] defaultFont = device.systemFont.handle;
- 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);
- if (OS.PfGenerateFontName(defaultFontName, osStyle, height, buffer) != 0) handle = buffer;
- }
- if (handle == null) handle = defaultFont;
- }
- }
- if (handle == null)SWT.error(SWT.ERROR_NO_HANDLES);
-}
-
-public static Font photon_new(Device device, byte[] stem) {
- Font font = new Font(device);
- font.init(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 + "}";
-}
-
-}
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
deleted file mode 100755
index 4eac8a32b3..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class describe operating system fonts.
- * <p>
- * For platform-independent behaviour, use the get and set methods
- * corresponding to the following properties:
- * <dl>
- * <dt>height</dt><dd>the height of the font in points</dd>
- * <dt>name</dt><dd>the face name of the font, which may include the foundry</dd>
- * <dt>style</dt><dd>A bitwise combination of NORMAL, ITALIC and BOLD</dd>
- * </dl>
- * If extra, platform-dependent functionality is required:
- * <ul>
- * <li>On <em>Windows</em>, the data member of the <code>FontData</code>
- * corresponds to a Windows <code>LOGFONT</code> structure whose fields
- * may be retrieved and modified.</li>
- * <li>On <em>X</em>, the fields of the <code>FontData</code> correspond
- * to the entries in the font's XLFD name and may be retrieved and modified.
- * </ul>
- * Application code does <em>not</em> need to explicitly release the
- * resources managed by each instance when those instances are no longer
- * required, and thus no <code>dispose()</code> method is provided.
- *
- * @see Font
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public final class FontData {
-
- /**
- * the font name
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public String name;
-
- /**
- * The height of the font data in points
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int height;
-
- /**
- * the font style
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int style;
-
- /**
- * A Photon stem
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public byte[] stem;
-
- /**
- * The locales of the font
- */
- 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 uninitialized font data.
- */
-public FontData() {
- this("", 12, SWT.NORMAL);
-}
-
-/**
- * Constructs a new FontData given a string representation
- * in the form generated by the <code>FontData.toString</code>
- * method.
- * <p>
- * Note that the representation varies between platforms,
- * and a FontData can only be created from a string that was
- * generated on the same platform.
- * </p>
- *
- * @param string the string representation of a <code>FontData</code> (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description</li>
- * </ul>
- *
- * @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;
- }
-}
-
-/**
- * Constructs a new font data given a font name,
- * the height of the desired font in points,
- * and a font style.
- *
- * @param name the name of the font (must not be null)
- * @param height the font height in points
- * @param style a bit or combination of NORMAL, BOLD, ITALIC
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
- * <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);
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof FontData)) return false;
- FontData data = (FontData)object;
- return name.equals(data.name) && height == data.height && style == data.style;
-}
-
-/**
- * Returns the height of the receiver in points.
- *
- * @return the height of this FontData
- *
- * @see #setHeight(int)
- */
-public int getHeight() {
- return height;
-}
-
-/**
- * Returns 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 where there are multiple character sets for a
- * given language/country locale, the variant portion of the
- * locale will determine the character set.
- * </p>
- *
- * @return the <code>String</code> representing a Locale object
- * @since 3.0
- */
-public String getLocale () {
- StringBuffer buffer = new StringBuffer ();
- char sep = '_';
- if (lang != null) {
- buffer.append (lang);
- buffer.append (sep);
- }
- if (country != null) {
- buffer.append (country);
- buffer.append (sep);
- }
- if (variant != null) {
- buffer.append (variant);
- }
-
- String result = buffer.toString ();
- int length = result.length ();
- if (length > 0) {
- if (result.charAt (length - 1) == sep) {
- result = result.substring (0, length - 1);
- }
- }
- return result;
-}
-
-/**
- * Returns the name of the receiver.
- * On platforms that support font foundries, the return value will
- * be the foundry followed by a dash ("-") followed by the face name.
- *
- * @return the name of this <code>FontData</code>
- *
- * @see #setName
- */
-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
- * and ITALIC.
- *
- * @return the style of this <code>FontData</code>
- *
- * @see #setStyle
- */
-public int getStyle() {
- return style;
-}
-
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
-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
- * seventy-second of an inch.
- *
- * @param height the height of the <code>FontData</code>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
- * </ul>
- *
- * @see #getHeight
- */
-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>
- * Some platforms support font foundries. On these platforms, the name
- * of the font specified in setName() may have one of the following forms:
- * <ol>
- * <li>a face name (for example, "courier")</li>
- * <li>a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")</li>
- * </ol>
- * In either case, the name returned from getName() will include the
- * foundry.
- * </p>
- * <p>
- * On platforms that do not support font foundries, only the face name
- * (for example, "courier") is used in <code>setName()</code> and
- * <code>getName()</code>.
- * </p>
- *
- * @param name the name of the font data (must not be null)
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
- * </ul>
- *
- * @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 where 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);
- }
-}
-
-/**
- * Sets the style of the receiver to the argument which must
- * be a bitwise OR of one or more of the <code>SWT</code>
- * constants NORMAL, BOLD and ITALIC. All other style bits are
- * ignored.
- *
- * @param style the new style for this <code>FontData</code>
- *
- * @see #getStyle
- */
-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
- * <code>FontData(String)</code> constructor.
- *
- * @return a string representation of the FontData
- *
- * @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);
-}
-
-}
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
deleted file mode 100755
index d21e6e4d60..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-import org.eclipse.swt.internal.photon.*;
-
-/**
- * Instances of this class provide measurement information
- * about fonts including ascent, descent, height, leading
- * space between rows, and average character width.
- * <code>FontMetrics</code> are obtained from <code>GC</code>s
- * using the <code>getFontMetrics()</code> method.
- *
- * @see GC#getFontMetrics
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-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)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public FontQueryInfo handle;
-
-FontMetrics() {
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof 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
- * top of actual characters, not including any of the leading area,
- * measured in pixels.
- *
- * @return the ascent of the font
- */
-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;
-}
-
-/**
- * Returns the descent of the font described by the receiver. A
- * font's <em>descent</em> is the distance from the baseline to the
- * bottom of actual characters, not including any of the leading area,
- * measured in pixels.
- *
- * @return the descent of the font
- */
-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
- * its ascent, descent and leading area.
- *
- * @return the height of the font
- *
- * @see #getAscent
- * @see #getDescent
- * @see #getLeading
- */
-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
- * above its ascent which may include accents or other marks.
- *
- * @return the leading space of the font
- */
-public int getLeading() {
- return 0;
-}
-
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @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 internal_new(int ascent, int descent, int aveCharWidth, int leading, int height) {
- FontQueryInfo info = new FontQueryInfo();
- info.ascender = (short)-ascent;
- info.descender = (short)descent;
- info.style = OS.PHFONT_INFO_FIXED;
- info.width = (short)aveCharWidth;
- return photon_new(info);
-}
-
-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
deleted file mode 100755
index ea5c82634b..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
+++ /dev/null
@@ -1,3655 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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
- * <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
- * </dl>
- *
- * <p>
- * The SWT drawing coordinate system is the two-dimensional space with the origin
- * (0,0) at the top left corner of the drawing area and with (x,y) values increasing
- * to the right and downward respectively.
- * </p>
- *
- * <p>
- * The result of drawing on an image that was created with an indexed
- * palette using a color that is not in the palette is platform specific.
- * Some platforms will match to the nearest color while other will draw
- * the color itself. This happens because the allocated image might use
- * a direct palette on platforms that do not support indexed palette.
- * </p>
- *
- * <p>
- * Application code must explicitly invoke the <code>GC.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required. This is <em>particularly</em>
- * important on Windows95 and Windows98 where the operating system has a limited
- * number of device contexts available.
- * </p>
- *
- * <p>
- * Note: Only one of LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified.
- * </p>
- *
- * @see org.eclipse.swt.events.PaintEvent
- * @see <a href="http://www.eclipse.org/swt/snippets/#gc">GC snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, PaintExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public final class GC extends Resource {
- /**
- * the handle to the OS device context
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- 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
- { 18, 6 }, // SWT.LINE_DASH
- { 3, 3 }, // SWT.LINE_DOT
- { 9, 6, 3, 6 }, // SWT.LINE_DASHDOT
- { 9, 3, 3, 3, 3, 3 } // 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_LINECAP = 1 << 6;
- static final int DIRTY_LINEJOIN = 1 << 7;
- static final int DIRTY_XORMODE = 1 << 8;
-
-GC() {
-}
-
-/**
- * Constructs a new instance of this class which has been
- * configured to draw on the specified drawable. Sets the
- * foreground color, background color and font in the GC
- * to match those in the drawable.
- * <p>
- * You must dispose the graphics context when it is no longer required.
- * </p>
- * @param drawable the drawable to draw on
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the drawable is null</li>
- * <li>ERROR_NULL_ARGUMENT - if there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT
- * - if the drawable is an image that is not a bitmap or an icon
- * - if the drawable is an image or printer that is already selected
- * into another graphics context</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li>
- * <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li>
- * </ul>
- */
-public GC(Drawable drawable) {
- this(drawable, 0);
-}
-
-/**
- * Constructs a new instance of this class which has been
- * configured to draw on the specified drawable. Sets the
- * foreground color, background color and font in the GC
- * to match those in the drawable.
- * <p>
- * You must dispose the graphics context when it is no longer required.
- * </p>
- *
- * @param drawable the drawable to draw on
- * @param style the style of GC to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the drawable is null</li>
- * <li>ERROR_NULL_ARGUMENT - if there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT
- * - if the drawable is an image that is not a bitmap or an icon
- * - if the drawable is an image or printer that is already selected
- * into another graphics context</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li>
- * <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public GC(Drawable drawable, int style) {
- int flags = OS.PtEnter(0);
- try {
- if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- GCData data = new GCData ();
- data.style = checkStyle(style);
- 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);
- this.device = data.device = device;
- init (drawable, data, hDC);
- init();
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
-static int checkStyle (int style) {
- if ((style & SWT.LEFT_TO_RIGHT) != 0) style &= ~SWT.RIGHT_TO_LEFT;
- return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
-}
-
-/**
- * Copies a rectangular area of the receiver at the specified
- * position into the image, which must be of type <code>SWT.BITMAP</code>.
- *
- * @param image the image to copy into
- * @param x the x coordinate in the receiver of the area to be copied
- * @param y the y coordinate in the receiver of the area to be copied
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image is not a bitmap or has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <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 = (byte)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.
- *
- * @param srcX the x coordinate in the receiver of the area to be copied
- * @param srcY the y coordinate in the receiver of the area to be copied
- * @param width the width of the area to copy
- * @param height the height of the area to copy
- * @param destX the x coordinate in the receiver of the area to copy to
- * @param destY the y coordinate in the receiver of the area to copy to
- *
- * @exception SWTException <ul>
- * <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) {
- copyArea(x, y, width, height, destX, destY, true);
-}
-/**
- * Copies a rectangular area of the receiver at the source
- * position onto the receiver at the destination position.
- *
- * @param srcX the x coordinate in the receiver of the area to be copied
- * @param srcY the y coordinate in the receiver of the area to be copied
- * @param width the width of the area to copy
- * @param height the height of the area to copy
- * @param destX the x coordinate in the receiver of the area to copy to
- * @param destY the y coordinate in the receiver of the area to copy to
- * @param paint if <code>true</code> paint events will be generated for old and obscured areas
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void copyArea(int x, int y, int width, int height, int destX, int destY, boolean paint) {
- 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 = (byte)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();
- setGCTranslation();
- 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 visibleTiles = getClipping(widget, data.topWidget, true, true, null);
- if ( visibleTiles == 0 )
- OS.PtBlit(widget, rect, delta);
- else {
- int srcTile = OS.PhGetTile();
- OS.memmove(srcTile, rect, PhRect_t.sizeof);
- OS.PtClippedBlit(widget, srcTile, delta, visibleTiles);
- OS.PhFreeTiles(srcTile);;
- OS.PhFreeTiles(visibleTiles);
- }
- }
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
-void destroy() {
- int flags = OS.PtEnter(0);
- try {
- 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.
- */
- drawable.internal_dispose_GC(handle, data);
- drawable = null;
- handle = 0;
- data.image = null;
- data.font = null;
- data.rid = data.widget = data.topWidget = 0;
- data = null;
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
-/**
- * Draws the outline of a circular or elliptical arc
- * within the specified rectangular area.
- * <p>
- * The resulting arc begins at <code>startAngle</code> and extends
- * for <code>arcAngle</code> degrees, using the current color.
- * Angles are interpreted such that 0 degrees is at the 3 o'clock
- * position. A positive value indicates a counter-clockwise rotation
- * while a negative value indicates a clockwise rotation.
- * </p><p>
- * The center of the arc is the center of the rectangle whose origin
- * is (<code>x</code>, <code>y</code>) and whose size is specified by the
- * <code>width</code> and <code>height</code> arguments.
- * </p><p>
- * The resulting arc covers an area <code>width + 1</code> pixels wide
- * by <code>height + 1</code> pixels tall.
- * </p>
- *
- * @param x the x coordinate of the upper-left corner of the arc to be drawn
- * @param y the y coordinate of the upper-left corner of the arc to be drawn
- * @param width the width of the arc to be drawn
- * @param height the height of the arc to be drawn
- * @param startAngle the beginning angle
- * @param arcAngle the angular extent of the arc, relative to the start angle
- *
- * @exception SWTException <ul>
- * <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 arcAngle) {
- 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 || arcAngle == 0) return;
- if (startAngle > 0) {
- if (arcAngle > 0) {
- //No need to modify start angle.
- arcAngle += startAngle;
- } else {
- int newStartAngle;
- int newStopAngle = startAngle;
- if (startAngle > Math.abs(arcAngle)) {
- newStartAngle = startAngle - Math.abs(arcAngle);
- } else {
- newStartAngle = startAngle + 360 - Math.abs(arcAngle);
- }
- startAngle = newStartAngle;
- arcAngle = newStopAngle;
- }
- } else {
- if (arcAngle > 0) {
- arcAngle = arcAngle + startAngle;
- startAngle = 360 - Math.abs(startAngle);
- } else {
- int newStopAngle = 360 + startAngle;
- startAngle = newStopAngle - Math.abs(arcAngle);
- arcAngle = newStopAngle;
- }
- }
- startAngle = (int) (startAngle * 65536 / 360);
- arcAngle = (int) (arcAngle * 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();
- setGCTranslation();
- setGCClipping();
- OS.PgDrawArc(center, radii, startAngle, arcAngle, 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
- * platform supports such a notion, and otherwise draws a simple
- * rectangle in the receiver's foreground color.
- *
- * @param x the x coordinate of the rectangle
- * @param y the y coordinate of the rectangle
- * @param width the width of the rectangle
- * @param height the height of the rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle(int, int, int, int)
- */
-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();
- setGCTranslation();
- 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.
- *
- * @param image the image to draw
- * @param x the x coordinate of where to draw
- * @param y the y coordinate of where to draw
- *
- * @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 the given coordinates are outside the bounds of the image</li>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</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 SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</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);
- if (drawImage == 0) return;
- 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();
- setGCTranslation();
- setGCClipping();
- OS.PgSetDrawMode(data.xorMode ? OS.Pg_DrawModeDSx : OS.Pg_DrawModeS);
- dirtyBits |= DIRTY_XORMODE;
- 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 = (byte)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.Pg_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) return 0;
- int mc = OS.PmMemCreateMC(memImage, scale, trans);
- if (mc == 0) {
- Image.destroyImage(memImage);
- return 0;
- }
- 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);
- return 0;
- }
- mc = OS.PmMemCreateMC(maskImage, scale, trans);
- if (mc == 0) {
- Image.destroyImage(maskImage);
- Image.destroyImage(memImage);
- return 0;
- }
- 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.Pg_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 = (byte)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);
- return 0;
- }
-
- /* 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);
- return 0;
- }
- mc = OS.PmMemCreateMC(alphaImage, scale, trans);
- if (mc == 0) {
- OS.free(palettePtr);
- OS.free(alphaPtr);
- Image.destroyImage(alphaImage);
- Image.destroyImage(memImage);
- return 0;
- }
- 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 = (byte)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>).
- *
- * @param x1 the first point's x coordinate
- * @param y1 the first point's y coordinate
- * @param x2 the second point's x coordinate
- * @param y2 the second point's y coordinate
- *
- * @exception SWTException <ul>
- * <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();
- setGCTranslation();
- 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.
- * <p>
- * The result is a circle or ellipse that fits within the
- * rectangle specified by the <code>x</code>, <code>y</code>,
- * <code>width</code>, and <code>height</code> arguments.
- * </p><p>
- * The oval covers an area that is <code>width + 1</code>
- * pixels wide and <code>height + 1</code> pixels tall.
- * </p>
- *
- * @param x the x coordinate of the upper left corner of the oval to be drawn
- * @param y the y coordinate of the upper left corner of the oval to be drawn
- * @param width the width of the oval to be drawn
- * @param height the height of the oval to be drawn
- *
- * @exception SWTException <ul>
- * <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();
- setGCTranslation();
- setGCClipping();
- OS.PgDrawEllipse(center, radii, OS.Pg_DRAW_STROKE | OS.Pg_EXTENT_BASED);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
-/**
- * Draws the path described by the parameter.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param path the path to draw
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see Path
- *
- * @since 3.1
- */
-public void drawPath(Path path) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * Draws a pixel, using the foreground color, at the specified
- * point (<code>x</code>, <code>y</code>).
- * <p>
- * Note that the receiver's line attributes do not affect this
- * operation.
- * </p>
- *
- * @param x the point's x coordinate
- * @param y the point's y coordinate
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void drawPoint (int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- setGCTranslation();
- setGCClipping();
- OS.PgDrawIPixel(x, y);
- 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
- * contains alternating x and y values which are considered to represent
- * points which are the vertices of the polygon. Lines are drawn between
- * each consecutive pair, and between the first pair and last pair in the
- * array.
- *
- * @param pointArray an array of alternating x and y values which are the vertices of the polygon
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <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();
- setGCTranslation();
- 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
- * contains alternating x and y values which are considered to represent
- * points which are the corners of the polyline. Lines are drawn between
- * each consecutive pair, but not between the first pair and last pair in
- * the array.
- *
- * @param pointArray an array of alternating x and y values which are the corners of the polyline
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <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();
- setGCTranslation();
- 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
- * of the rectangle are at <code>x</code> and <code>x + width</code>.
- * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
- *
- * @param x the x coordinate of the rectangle to be drawn
- * @param y the y coordinate of the rectangle to be drawn
- * @param width the width of the rectangle to be drawn
- * @param height the height of the rectangle to be drawn
- *
- * @exception SWTException <ul>
- * <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();
- setGCTranslation();
- 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
- * <code>rect.x</code> and <code>rect.x + rect.width</code>. The top
- * and bottom edges are at <code>rect.y</code> and
- * <code>rect.y + rect.height</code>.
- *
- * @param rect the rectangle to draw
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <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);
-}
-
-/**
- * Draws the outline of the round-cornered rectangle specified by
- * the arguments, using the receiver's foreground color. The left and
- * right edges of the rectangle are at <code>x</code> and <code>x + width</code>.
- * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
- * The <em>roundness</em> of the corners is specified by the
- * <code>arcWidth</code> and <code>arcHeight</code> arguments, which
- * are respectively the width and height of the ellipse used to draw
- * the corners.
- *
- * @param x the x coordinate of the rectangle to be drawn
- * @param y the y coordinate of the rectangle to be drawn
- * @param width the width of the rectangle to be drawn
- * @param height the height of the rectangle to be drawn
- * @param arcWidth the width of the arc
- * @param arcHeight the height of the arc
- *
- * @exception SWTException <ul>
- * <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();
- setGCTranslation();
- 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
- * will be performed. The background of the rectangular area where
- * the string is being drawn will be filled with the receiver's
- * background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
- *
- * @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 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
- * will be performed. If <code>isTransparent</code> is <code>true</code>,
- * then the background of the rectangular area where the string is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
- * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
- *
- * @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 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();
- setGCTranslation();
- setGCClipping();
- PhPoint_t pos = new PhPoint_t();
- pos.x = (short)x;
- pos.y = (short)y;
- if (!data.xorMode) {
- OS.PgDrawText(buffer, buffer.length, pos, drawFlags);
- } else {
- if (isTransparent) {
- Font font = data.font;
- PhRect_t rect = new PhRect_t();
- OS.PfExtentText(rect, null, font.handle, buffer, buffer.length);
- short width = (short)(rect.lr_x - rect.ul_x + 1);
- short height = (short)(rect.lr_y - rect.ul_y + 1);
- int image = OS.PhCreateImage(null, width, height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
- PhDim_t dim = new PhDim_t();
- dim.w = width;
- dim.h = height;
- PhPoint_t point = new PhPoint_t();
- int pmMC = OS.PmMemCreateMC(image, dim, point);
- if (pmMC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int prevCont = OS.PmMemStart(pmMC);
- OS.PgSetTextColor(data.foreground);
- OS.PgSetFont(font.handle);
- pos.x = pos.y = (short)0;
- OS.PgDrawText(buffer, buffer.length, pos, drawFlags);
- OS.PmMemFlush(pmMC, image);
- OS.PmMemStop(pmMC);
- OS.PhDCSetCurrent(prevCont);
- OS.PmMemReleaseMC(pmMC);
- point.x = (short)x;
- point.y = (short)y;
- PhImage_t phImage = new PhImage_t();
- OS.memmove(phImage, image, PhImage_t.sizeof);
- OS.PgSetDrawMode(OS.Pg_DrawModeDSx);
- dirtyBits |= DIRTY_XORMODE;
- OS.PgDrawImage(phImage.image, phImage.type, point, dim, phImage.bpl, 0);
- phImage.flags = (byte)OS.Ph_RELEASE_IMAGE_ALL;
- OS.memmove(image, phImage, PhImage_t.sizeof);
- OS.PhReleaseImage(image);
- OS.free(image);
- } else {
- OS.PgSetTextXORColor(data.foreground, data.background);
- OS.PgSetDrawMode(OS.Pg_DrawModeS);
- OS.PgDrawText(buffer, buffer.length, pos, drawFlags);
- dirtyBits |= DIRTY_XORMODE | DIRTY_FOREGROUND;
- }
- }
- 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
- * are performed. The background of the rectangular area where
- * the text is being drawn will be filled with the receiver's
- * background color.
- *
- * @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
- *
- * @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) {
- 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
- * are performed. If <code>isTransparent</code> is <code>true</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.
- *
- * @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 isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
- *
- * @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 specifying 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);
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle));
-}
-
-/**
- * Fills the interior of a circular or elliptical arc within
- * the specified rectangular area, with the receiver's background
- * color.
- * <p>
- * The resulting arc begins at <code>startAngle</code> and extends
- * for <code>arcAngle</code> degrees, using the current color.
- * Angles are interpreted such that 0 degrees is at the 3 o'clock
- * position. A positive value indicates a counter-clockwise rotation
- * while a negative value indicates a clockwise rotation.
- * </p><p>
- * The center of the arc is the center of the rectangle whose origin
- * is (<code>x</code>, <code>y</code>) and whose size is specified by the
- * <code>width</code> and <code>height</code> arguments.
- * </p><p>
- * The resulting arc covers an area <code>width + 1</code> pixels wide
- * by <code>height + 1</code> pixels tall.
- * </p>
- *
- * @param x the x coordinate of the upper-left corner of the arc to be filled
- * @param y the y coordinate of the upper-left corner of the arc to be filled
- * @param width the width of the arc to be filled
- * @param height the height of the arc to be filled
- * @param startAngle the beginning angle
- * @param arcAngle the angular extent of the arc, relative to the start angle
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawArc
- */
-public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) {
- 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 || arcAngle == 0) return;
- if (startAngle > 0) {
- if (arcAngle > 0) {
- //No need to modify start angle.
- arcAngle += startAngle;
- } else {
- int newStartAngle;
- int newStopAngle = startAngle;
- if (startAngle > Math.abs(arcAngle)) {
- newStartAngle = startAngle - Math.abs(arcAngle);
- } else {
- newStartAngle = startAngle + 360 - Math.abs(arcAngle);
- }
- startAngle = newStartAngle;
- arcAngle = newStopAngle;
- }
- } else {
- if (arcAngle > 0) {
- arcAngle = arcAngle + startAngle;
- startAngle = 360 - Math.abs(startAngle);
- } else {
- int newStopAngle = 360 + startAngle;
- startAngle = newStopAngle - Math.abs(arcAngle);
- arcAngle = newStopAngle;
- }
- }
- startAngle = (int) (startAngle * 65536 / 360);
- arcAngle = (int) (arcAngle * 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();
- setGCTranslation();
- setGCClipping();
- OS.PgDrawArc(center, radii, startAngle, arcAngle, 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(int, int, int, int)
- */
-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;
- }
- if (fromColor == toColor) {
- fillRectangle(x, y, width, height);
- return;
- }
- 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();
- setGCTranslation();
- 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
- * color.
- *
- * @param x the x coordinate of the upper left corner of the oval to be filled
- * @param y the y coordinate of the upper left corner of the oval to be filled
- * @param width the width of the oval to be filled
- * @param height the height of the oval to be filled
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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();
- setGCTranslation();
- setGCClipping();
- OS.PgDrawEllipse(center, radii, OS.Pg_DRAW_FILL | OS.Pg_EXTENT_BASED);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
-/**
- * Fills the path described by the parameter.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param path the path to fill
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see Path
- *
- * @since 3.1
- */
-public void fillPath (Path path) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * Fills the interior of the closed polygon which is defined by the
- * specified array of integer coordinates, using the receiver's
- * background color. The array contains alternating x and y values
- * which are considered to represent points which are the vertices of
- * the polygon. Lines are drawn between each consecutive pair, and
- * between the first pair and last pair in the array.
- *
- * @param pointArray an array of alternating x and y values which are the vertices of the polygon
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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();
- setGCTranslation();
- 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.
- *
- * @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
- * @param height the height of the rectangle to be filled
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle(int, int, int, int)
- */
-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();
- setGCTranslation();
- 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.
- *
- * @param rect the rectangle to be filled
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle(int, int, int, int)
- */
-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.
- *
- * @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
- * @param height the height of the rectangle to be filled
- * @param arcWidth the width of the arc
- * @param arcHeight the height of the arc
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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();
- setGCTranslation();
- 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);
-}
-
-/**
- * Returns the <em>advance width</em> of the specified character in
- * the font which is currently selected into the receiver.
- * <p>
- * The advance width is defined as the horizontal distance the cursor
- * should move after printing the character in the selected font.
- * </p>
- *
- * @param ch the character to measure
- * @return the distance in the x direction to move past the character before painting the next
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public int getAdvanceWidth(char ch) {
- return getCharWidth(ch);
-}
-
-/**
- * Returns <code>true</code> if receiver is using the operating system's
- * advanced graphics subsystem. Otherwise, <code>false</code> is returned
- * to indicate that normal graphics are in use.
- * <p>
- * Advanced graphics may not be installed for the operating system. In this
- * case, <code>false</code> is always returned. Some operating system have
- * only one graphics subsystem. If this subsystem supports advanced graphics,
- * then <code>true</code> is always returned. If any graphics operation such
- * as alpha, antialias, patterns, interpolation, paths, clipping or transformation
- * has caused the receiver to switch from regular to advanced graphics mode,
- * <code>true</code> is returned. If the receiver has been explicitly switched
- * to advanced mode and this mode is supported, <code>true</code> is returned.
- * </p>
- *
- * @return the advanced value
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #setAdvanced
- *
- * @since 3.1
- */
-public boolean getAdvanced() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return false;
-}
-
-/**
- * Returns the receiver's alpha value. The alpha value
- * is between 0 (transparent) and 255 (opaque).
- *
- * @return the alpha value
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public int getAlpha() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return 0xFF;
-}
-
-/**
- * Returns the receiver's anti-aliasing setting value, which will be
- * one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code> or
- * <code>SWT.ON</code>. Note that this controls anti-aliasing for all
- * <em>non-text drawing</em> operations.
- *
- * @return the anti-aliasing setting
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #getTextAntialias
- *
- * @since 3.1
- */
-public int getAntialias() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return SWT.DEFAULT;
-}
-
-/**
- * Returns the background color.
- *
- * @return the receiver's background color
- *
- * @exception SWTException <ul>
- * <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);
-}
-
-/**
- * Returns the background pattern. The default value is
- * <code>null</code>.
- *
- * @return the receiver's background pattern
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Pattern
- *
- * @since 3.1
- */
-public Pattern getBackgroundPattern() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return null;
-}
-
-/**
- * Returns the width of the specified character in the font
- * selected into the receiver.
- * <p>
- * The width is defined as the space taken up by the actual
- * character, not including the leading and tailing whitespace
- * or overhang.
- * </p>
- *
- * @param ch the character to measure
- * @return the width of the character
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns the bounding rectangle of the receiver's clipping
- * region. If no clipping region is set, the return value
- * will be a rectangle which covers the entire bounds of the
- * object the receiver is drawing on.
- *
- * @return the bounding rectangle of the clipping region
- *
- * @exception SWTException <ul>
- * <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);
- }
-}
-
-/**
- * Sets the region managed by the argument to the current
- * clipping region of the receiver.
- *
- * @param region the region to fill with the clipping region
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the region is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the region is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <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);
- if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_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 receiver's fill rule, which will be one of
- * <code>SWT.FILL_EVEN_ODD</code> or <code>SWT.FILL_WINDING</code>.
- *
- * @return the receiver's fill rule
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public int getFillRule() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- //TODO - implement fill rule
- return SWT.FILL_EVEN_ODD;
-}
-
-/**
- * Returns the font currently being used by the receiver
- * to draw and measure text.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <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 data.font;
-}
-
-/**
- * Returns a FontMetrics which contains information
- * about the font currently being used by the receiver
- * to draw and measure text.
- *
- * @return font metrics for the receiver's font
- *
- * @exception SWTException <ul>
- * <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.handle, info);
- return FontMetrics.photon_new(info);
-}
-
-/**
- * Returns the receiver's foreground color.
- *
- * @return the color used for drawing foreground things
- *
- * @exception SWTException <ul>
- * <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);
-}
-
-/**
- * Returns the foreground pattern. The default value is
- * <code>null</code>.
- *
- * @return the receiver's foreground pattern
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Pattern
- *
- * @since 3.1
- */
-public Pattern getForegroundPattern() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return null;
-}
-
-/**
- * Returns the GCData.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>GC</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @return the receiver's GCData
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see GCData
- *
- * @since 3.2
- * @noreference This method is not intended to be referenced by clients.
- */
-public GCData getGCData() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data;
-}
-
-/**
- * Returns the receiver's interpolation setting, which will be one of
- * <code>SWT.DEFAULT</code>, <code>SWT.NONE</code>,
- * <code>SWT.LOW</code> or <code>SWT.HIGH</code>.
- *
- * @return the receiver's interpolation setting
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public int getInterpolation() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return SWT.DEFAULT;
-}
-
-/**
- * Returns the receiver's line attributes.
- *
- * @return the line attributes used for drawing lines
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.3
- */
-public LineAttributes getLineAttributes() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- float[] dashes = null;
- if (data.dashes != null) {
- dashes = new float[data.dashes.length];
- for (int i = 0; i < dashes.length; i++) {
- dashes[i] = data.dashes[i];
- }
- }
- return new LineAttributes(data.lineWidth, data.lineCap, data.lineJoin, data.lineStyle, dashes, 0, 10);
-}
-
-/**
- * Returns the receiver's line cap style, which will be one
- * of the constants <code>SWT.CAP_FLAT</code>, <code>SWT.CAP_ROUND</code>,
- * or <code>SWT.CAP_SQUARE</code>.
- *
- * @return the cap style used for drawing lines
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public int getLineCap() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.lineCap;
-}
-
-/**
- * Returns the receiver's line dash style. The default value is
- * <code>null</code>.
- *
- * @return the line dash style used for drawing lines
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public int[] getLineDash() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- byte[] dashList = data.dashes;
- if (dashList == null) return null;
- int[] dashes = new int[dashList.length];
- for (int i = 0; i < dashes.length; i++) {
- dashes[i] = dashList[i] & 0xFF;
- }
- return dashes;
-}
-
-/**
- * Returns the receiver's line join style, which will be one
- * of the constants <code>SWT.JOIN_MITER</code>, <code>SWT.JOIN_ROUND</code>,
- * or <code>SWT.JOIN_BEVEL</code>.
- *
- * @return the join style used for drawing lines
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public int getLineJoin() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.lineJoin;
-}
-
-/**
- * Returns the receiver's line style, which will be one
- * of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
- * <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
- * <code>SWT.LINE_DASHDOTDOT</code>.
- *
- * @return the style used for drawing lines
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns the width that will be used when drawing lines
- * for all of the figure drawing operations (that is,
- * <code>drawLine</code>, <code>drawRectangle</code>,
- * <code>drawPolyline</code>, and so forth.
- *
- * @return the receiver's line width
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns the receiver's style information.
- * <p>
- * Note that the value which is returned by this method <em>may
- * not match</em> the value which was provided to the constructor
- * when the receiver was created. This can occur when the underlying
- * operating system does not support a particular combination of
- * requested styles.
- * </p>
- *
- * @return the style bits
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public int getStyle () {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.style;
-}
-
-/**
- * Returns the receiver's text drawing anti-aliasing setting value,
- * which will be one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code> or
- * <code>SWT.ON</code>. Note that this controls anti-aliasing
- * <em>only</em> for text drawing operations.
- *
- * @return the anti-aliasing setting
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #getAntialias
- *
- * @since 3.1
- */
-public int getTextAntialias() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return SWT.DEFAULT;
-}
-
-/**
- * Sets the parameter to the transform that is currently being
- * used by the receiver.
- *
- * @param transform the destination to copy the transform into
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Transform
- *
- * @since 3.1
- */
-public void getTransform(Transform transform) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (transform == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (transform.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * Returns <code>true</code> if this GC is drawing in the mode
- * where the resulting color in the destination is the
- * <em>exclusive or</em> of the color values in the source
- * and the destination, and <code>false</code> if it is
- * drawing in the mode where the destination color is being
- * replaced with the source color value.
- *
- * @return <code>true</code> true if the receiver is in XOR mode, and false otherwise
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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;
-}
-
-/**
- * Returns <code>true</code> if the receiver has a clipping
- * region set into it, and <code>false</code> otherwise.
- * If this method returns false, the receiver will draw on all
- * available space in the destination. If it returns true,
- * it will draw only in the area that is covered by the region
- * that can be accessed with <code>getClipping(region)</code>.
- *
- * @return <code>true</code> if the GC has a clipping region, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns <code>true</code> if the GC has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the GC.
- * When a GC has been disposed, it is an error to
- * invoke any other method using the GC.
- *
- * @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
- */
-public boolean isDisposed() {
- return handle == 0;
-}
-
-/**
- * Sets the receiver to always use the operating system's advanced graphics
- * subsystem for all graphics operations if the argument is <code>true</code>.
- * If the argument is <code>false</code>, the advanced graphics subsystem is
- * no longer used, advanced graphics state is cleared and the normal graphics
- * subsystem is used from now on.
- * <p>
- * Normally, the advanced graphics subsystem is invoked automatically when
- * any one of the alpha, antialias, patterns, interpolation, paths, clipping
- * or transformation operations in the receiver is requested. When the receiver
- * is switched into advanced mode, the advanced graphics subsystem performs both
- * advanced and normal graphics operations. Because the two subsystems are
- * different, their output may differ. Switching to advanced graphics before
- * any graphics operations are performed ensures that the output is consistent.
- * </p><p>
- * Advanced graphics may not be installed for the operating system. In this
- * case, this operation does nothing. Some operating system have only one
- * graphics subsystem, so switching from normal to advanced graphics does
- * nothing. However, switching from advanced to normal graphics will always
- * clear the advanced graphics state, even for operating systems that have
- * only one graphics subsystem.
- * </p>
- *
- * @param advanced the new advanced graphics state
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #setAlpha
- * @see #setAntialias
- * @see #setBackgroundPattern
- * @see #setClipping(Path)
- * @see #setForegroundPattern
- * @see #setLineAttributes
- * @see #setInterpolation
- * @see #setTextAntialias
- * @see #setTransform
- * @see #getAdvanced
- *
- * @since 3.1
- */
-public void setAdvanced(boolean advanced) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (!advanced) {
- setAlpha(0xFF);
- setAntialias(SWT.DEFAULT);
- setBackgroundPattern(null);
- setClipping((Rectangle)null);
- setForegroundPattern(null);
- setInterpolation(SWT.DEFAULT);
- setTextAntialias(SWT.DEFAULT);
- setTransform(null);
- }
-}
-
-/**
- * Sets the receiver's alpha value which must be
- * between 0 (transparent) and 255 (opaque).
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- * @param alpha the alpha value
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see #getAdvanced
- * @see #setAdvanced
- *
- * @since 3.1
- */
-public void setAlpha(int alpha) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-}
-
-/**
- * Sets the receiver's anti-aliasing value to the parameter,
- * which must be one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code>
- * or <code>SWT.ON</code>. Note that this controls anti-aliasing for all
- * <em>non-text drawing</em> operations.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param antialias the anti-aliasing setting
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>SWT.DEFAULT</code>,
- * <code>SWT.OFF</code> or <code>SWT.ON</code></li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see #getAdvanced
- * @see #setAdvanced
- * @see #setTextAntialias
- *
- * @since 3.1
- */
-public void setAntialias(int antialias) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (antialias) {
- case SWT.DEFAULT: break;
- case SWT.OFF: break;
- case SWT.ON:
- break;
- default:
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-}
-
-/**
- * Sets the background color. The background color is used
- * for fill operations and as the background color when text
- * is drawn.
- *
- * @param color the new background color for the receiver
- *
- * @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 (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 background pattern. The default value is <code>null</code>.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param pattern the new background pattern
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see Pattern
- * @see #getAdvanced
- * @see #setAdvanced
- *
- * @since 3.1
- */
-public void setBackgroundPattern (Pattern pattern) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pattern == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * Sets the area of the receiver which can be changed
- * by drawing operations to the rectangular area specified
- * by the arguments.
- *
- * @param x the x coordinate of the clipping rectangle
- * @param y the y coordinate of the clipping rectangle
- * @param width the width of the clipping rectangle
- * @param height the height of the clipping rectangle
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Sets the area of the receiver which can be changed
- * by drawing operations to the path specified
- * by the argument.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param path the clipping path.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the path has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see Path
- * @see #getAdvanced
- * @see #setAdvanced
- *
- * @since 3.1
- */
-public void setClipping(Path path) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (path != null && path.isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-}
-
-/**
- * Sets the area of the receiver which can be changed
- * by drawing operations to the rectangular area specified
- * by the argument. Specifying <code>null</code> for the
- * rectangle reverts the receiver's clipping area to its
- * original value.
- *
- * @param rect the clipping rectangle or <code>null</code>
- *
- * @exception SWTException <ul>
- * <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);
- }
-}
-
-/**
- * Sets the area of the receiver which can be changed
- * by drawing operations to the region specified
- * by the argument. Specifying <code>null</code> for the
- * region reverts the receiver's clipping area to its
- * original value.
- *
- * @param region the clipping region or <code>null</code>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <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);
- if (region != null && region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- 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);
- OS.memset(clipRects, 0, 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 receiver's fill rule to the parameter, which must be one of
- * <code>SWT.FILL_EVEN_ODD</code> or <code>SWT.FILL_WINDING</code>.
- *
- * @param rule the new fill rule
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>SWT.FILL_EVEN_ODD</code>
- * or <code>SWT.FILL_WINDING</code></li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void setFillRule(int rule) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (rule) {
- case SWT.FILL_WINDING:
- case SWT.FILL_EVEN_ODD:
- break;
- default:
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- //TODO - implement fill rule
-}
-
-/**
- * Sets the font which will be used by the receiver
- * to draw and measure text to the argument. If the
- * argument is null, then a default font appropriate
- * for the platform will be used instead.
- *
- * @param font the new font for the receiver, or null to indicate a default font
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <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;
- dirtyBits |= DIRTY_FONT;
-}
-
-/**
- * Sets the foreground color. The foreground color is used
- * for drawing operations including when text is drawn.
- *
- * @param color the new foreground color for the receiver
- *
- * @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 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 interpolation setting to the parameter, which
- * must be one of <code>SWT.DEFAULT</code>, <code>SWT.NONE</code>,
- * <code>SWT.LOW</code> or <code>SWT.HIGH</code>.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param interpolation the new interpolation setting
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>SWT.DEFAULT</code>,
- * <code>SWT.NONE</code>, <code>SWT.LOW</code> or <code>SWT.HIGH</code>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see #getAdvanced
- * @see #setAdvanced
- *
- * @since 3.1
- */
-public void setInterpolation(int interpolation) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (interpolation) {
- case SWT.DEFAULT:
- case SWT.NONE:
- case SWT.LOW:
- case SWT.HIGH:
- break;
- default:
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-}
-
-/**
- * Sets the foreground pattern. The default value is <code>null</code>.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- * @param pattern the new foreground pattern
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see Pattern
- * @see #getAdvanced
- * @see #setAdvanced
- *
- * @since 3.1
- */
-public void setForegroundPattern (Pattern pattern) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pattern == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * Sets the receiver's line attributes.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- * @param attributes the line attributes
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the attributes is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if any of the line attributes is not valid</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see LineAttributes
- * @see #getAdvanced
- * @see #setAdvanced
- *
- * @since 3.3
- */
-public void setLineAttributes(LineAttributes attributes) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- //TODO - implement setLineAttributes
-}
-
-/**
- * Sets the receiver's line cap style to the argument, which must be one
- * of the constants <code>SWT.CAP_FLAT</code>, <code>SWT.CAP_ROUND</code>,
- * or <code>SWT.CAP_SQUARE</code>.
- *
- * @param cap the cap style to be used for drawing lines
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void setLineCap(int cap) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (cap) {
- case SWT.CAP_ROUND:
- case SWT.CAP_FLAT:
- case SWT.CAP_SQUARE:
- break;
- default:
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- data.lineCap = cap;
- dirtyBits |= DIRTY_LINECAP;
-}
-
-/**
- * Sets the receiver's line dash style to the argument. The default
- * value is <code>null</code>. If the argument is not <code>null</code>,
- * the receiver's line style is set to <code>SWT.LINE_CUSTOM</code>, otherwise
- * it is set to <code>SWT.LINE_SOLID</code>.
- *
- * @param dashes the dash style to be used for drawing lines
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if any of the values in the array is less than or equal 0</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void setLineDash(int[] dashes) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (dashes != null && dashes.length != 0) {
- byte[] dashList = new byte[dashes.length];
- for (int i = 0; i < dashes.length; i++) {
- dashList[i] = (byte)dashes[i];
- }
- data.dashes = dashList;
- data.lineStyle = SWT.LINE_CUSTOM;
- } else {
- data.dashes = null;
- data.lineStyle = SWT.LINE_SOLID;
- }
- dirtyBits |= DIRTY_LINESTYLE;
-}
-
-/**
- * Sets the receiver's line join style to the argument, which must be one
- * of the constants <code>SWT.JOIN_MITER</code>, <code>SWT.JOIN_ROUND</code>,
- * or <code>SWT.JOIN_BEVEL</code>.
- *
- * @param join the join style to be used for drawing lines
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void setLineJoin(int join) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (join) {
- case SWT.JOIN_MITER:
- case SWT.JOIN_ROUND:
- case SWT.JOIN_BEVEL:
- break;
- default:
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- data.lineJoin = join;
- dirtyBits |= DIRTY_LINEJOIN;
-}
-
-/**
- * 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>,
- * <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
- * <code>SWT.LINE_DASHDOTDOT</code>.
- *
- * @param lineStyle the style to be used for drawing lines
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
- * </ul>
- * @exception SWTException <ul>
- * <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;
- case SWT.LINE_CUSTOM:
- if (data.dashes == null) lineStyle = SWT.LINE_SOLID;
- 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,
- * <code>drawLine</code>, <code>drawRectangle</code>,
- * <code>drawPolyline</code>, and so forth.
- * <p>
- * Note that line width of zero is used as a hint to
- * indicate that the fastest possible line drawing
- * algorithms should be used. This means that the
- * output may be different from line width one.
- * </p>
- *
- * @param lineWidth the width of a line
- *
- * @exception SWTException <ul>
- * <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) {
- Font font = data.font;
- OS.PfLoadMetrics(font.handle);
- OS.PgSetFont(font.handle);
- }
- if ((dirtyBits & DIRTY_CLIPPING) != 0) {
- OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
- }
- if ((dirtyBits & DIRTY_LINECAP) != 0) {
- int cap_style = 0;
- switch (data.lineCap) {
- case SWT.CAP_ROUND:cap_style = OS.Pg_ROUND_CAP; break;
- case SWT.CAP_FLAT:cap_style = OS.Pg_BUTT_CAP; break;
- case SWT.CAP_SQUARE:cap_style = OS.Pg_SQUARE_CAP; break;
- }
- OS.PgSetStrokeCap(cap_style);
- }
- if ((dirtyBits & DIRTY_LINEJOIN) != 0) {
- int join_style = 0;
- switch (data.lineJoin) {
- case SWT.JOIN_ROUND:join_style = OS.Pg_ROUND_JOIN; break;
- case SWT.JOIN_MITER:join_style = OS.Pg_MITER_JOIN; break;
- case SWT.JOIN_BEVEL:join_style = OS.Pg_BEVEL_JOIN; break;
- }
- OS.PgSetStrokeJoin(join_style);
- }
- 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;
- case SWT.LINE_CUSTOM: dashList = data.dashes; break;
- }
- OS.PgSetStrokeDash(dashList, dashList.length, 0x10000);
- }
- if ((dirtyBits & DIRTY_LINEWIDTH) != 0) {
- OS.PgSetStrokeWidth(data.lineWidth);
- }
- if ((dirtyBits & DIRTY_XORMODE) != 0) {
- OS.PgSetDrawMode(data.xorMode ? OS.Pg_DRAWMODE_XOR : OS.Pg_DRAWMODE_OPAQUE);
- }
- dirtyBits = 0;
- }
- return result;
-}
-
-void setGCClipping() {
- int rid = data.rid;
- int widget = data.widget;
- if(OS.QNX_MAJOR >= 6 && OS.QNX_MINOR >= 3)
- {
- if(widget > 0)
- {
- int visibleTiles = OS.PtGetVisibleTiles(widget);
- if(data.clipRects != 0)
- {
- int gcClip = OS.PhRectsToTiles(data.clipRects, data.clipRectsCount);
- PhPoint_t pt = new PhPoint_t();
- PhRect_t tran_rect = new PhRect_t();
- OS.PtWidgetExtent(widget, tran_rect);
- OS.PtWidgetOffset(widget, pt);
- pt.x += tran_rect.ul_x;
- pt.y += tran_rect.ul_y;
- OS.PhTranslateTiles(gcClip, pt);
- int inter = OS.PhIntersectTilings(visibleTiles, gcClip, new short[1]);
- if(inter != 0)
- {
- OS.PgSetMultiClipTiles(inter);
- OS.free(inter);
- }
- OS.free(gcClip);
- } else
- {
- OS.PgSetMultiClipTiles(visibleTiles);
- }
- OS.free(visibleTiles);
- }
- return;
- }
- if(rid == 1)
- OS.PgSetRegion(rid);
- else
- if(widget != 0)
- OS.PgSetRegion(OS.PtWidgetRid(widget));
- else
- if(data.image != null)
- return;
- if(widget == 0)
- return;
- OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
- 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(8);
- OS.memset(clip_rects, 0, 8);
- }
- OS.PgSetClipping((short)clip_rects_count[0], clip_rects);
- OS.free(clip_rects);
-}
-
-void setGCTranslation() {
- PhPoint_t pt = new PhPoint_t ();
- PhRect_t tran_rect = new PhRect_t();
- if (data.widget <= 0 ) return;
- OS.PtWidgetExtent(data.widget, tran_rect) ;
- OS.PtWidgetOffset(data.widget, pt);
- pt.x += tran_rect.ul_x;
- pt.y += tran_rect.ul_y;
- OS.PgSetTranslation(pt,0);
-}
-
-int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings, int[] child_tiles) {
- if(OS.QNX_MAJOR >= 6 && OS.QNX_MINOR >= 3)
- if(widget > 0)
- {
- int visTiles = OS.PtGetVisibleTiles(widget);
- PhPoint_t pt = new PhPoint_t();
- PhRect_t tranRect = new PhRect_t();
- OS.PtWidgetExtent(widget, tranRect);
- OS.PtWidgetOffset(widget, pt);
- pt.x += tranRect.ul_x;
- pt.y += tranRect.ul_y;
- int tranPoint = OS.malloc(4);
- OS.memmove(tranPoint, pt, 4);
- OS.PhDeTranslateTiles(visTiles, tranPoint);
- return visTiles;
- } else
- {
- return 0;
- }
- int child_tile = 0;
- int widget_tile = OS.PhGetTile();
- PhRect_t rect = new PhRect_t();
- int args[] = {
- 1006, 0, 0, 2015, 0, 0
- };
- if(clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow())
- {
- for(int temp_widget = topWidget; (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);
- args[1] = args[4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if((args[1] & 0x100) != 0)
- {
- int basic_flags = args[4];
- OS.memmove(rect, tile, 8);
- if((basic_flags & 1) != 0)
- rect.ul_y++;
- if((basic_flags & 2) != 0)
- rect.lr_y--;
- if((basic_flags & 8) != 0)
- rect.ul_x++;
- if((basic_flags & 4) != 0)
- rect.lr_x--;
- OS.memmove(tile, rect, 8);
- }
- }
-
- OS.PtWidgetCanvas(topWidget, widget_tile);
- OS.PhDeTranslateTiles(child_tile, widget_tile);
- }
- if(clipChildren)
- {
- for(int temp_widget = OS.PtWidgetChildBack(widget); temp_widget != 0; temp_widget = OS.PtWidgetBrotherInFront(temp_widget))
- 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);
- args[1] = args[4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if((args[1] & 0x100) != 0)
- {
- int basic_flags = args[4];
- OS.memmove(rect, tile, 8);
- if((basic_flags & 1) != 0)
- rect.ul_y++;
- if((basic_flags & 2) != 0)
- rect.lr_y--;
- if((basic_flags & 8) != 0)
- rect.ul_x++;
- if((basic_flags & 4) != 0)
- rect.lr_x--;
- OS.memmove(tile, rect, 8);
- }
- }
-
- }
- OS.PtWidgetCanvas(widget, widget_tile);
- OS.PhDeTranslateTiles(widget_tile, widget_tile);
- 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;
- } else
- {
- return widget_tile;
- }
-}
-
-/**
- * Sets the receiver's text anti-aliasing value to the parameter,
- * which must be one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code>
- * or <code>SWT.ON</code>. Note that this controls anti-aliasing only
- * for all <em>text drawing</em> operations.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param antialias the anti-aliasing setting
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>SWT.DEFAULT</code>,
- * <code>SWT.OFF</code> or <code>SWT.ON</code></li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see #getAdvanced
- * @see #setAdvanced
- * @see #setAntialias
- *
- * @since 3.1
- */
-public void setTextAntialias(int antialias) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (antialias) {
- case SWT.DEFAULT: break;
- case SWT.OFF: break;
- case SWT.ON: break;
- default:
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
-}
-
-/**
- * Sets the transform that is currently being used by the receiver. If
- * the argument is <code>null</code>, the current transform is set to
- * the identity transform.
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * </p>
- *
- * @param transform the transform to set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
- * </ul>
- *
- * @see Transform
- * @see #getAdvanced
- * @see #setAdvanced
- *
- * @since 3.1
- */
-public void setTransform(Transform transform) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (transform != null && transform.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * If the argument is <code>true</code>, puts the receiver
- * in a drawing mode where the resulting color in the destination
- * is the <em>exclusive or</em> of the color values in the source
- * and the destination, and if the argument is <code>false</code>,
- * puts the receiver in a drawing mode where the destination color
- * is replaced with the source color value.
- * <p>
- * Note that this mode in fundamentally unsupportable on certain
- * platforms, notably Carbon (Mac OS X). Clients that want their
- * code to run on all platforms need to avoid this method.
- * </p>
- *
- * @param xor if <code>true</code>, then <em>xor</em> mode is used, otherwise <em>source copy</em> mode is used
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @deprecated this functionality is not supported on some platforms
- */
-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.
- * <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
- * @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 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.handle, 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.
- * <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
- * @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 specifying 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 || string.length() == 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.device = data.device;
- 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
deleted file mode 100755
index 04aa2aa616..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class are descriptions of GCs in terms
- * of unallocated platform-specific data fields.
- * <p>
- * <b>IMPORTANT:</b> This class is <em>not</em> part of the public
- * API for SWT. It is marked public only so that it can be shared
- * within the packages provided by SWT. It is not available on all
- * platforms, and should never be called from application code.
- * </p>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class GCData {
- public Device device;
- public int style;
- public Image image;
- public int rid;
- public int widget, topWidget;
- public int foreground = -1;
- public int background = -1;
- public Font font;
- public boolean xorMode;
- public int lineStyle = SWT.LINE_SOLID;
- public int lineCap = SWT.CAP_FLAT;
- public int lineJoin = SWT.JOIN_MITER;
- public int lineWidth = 1;
- public byte[] dashes;
- public int clipRectsCount;
- public int clipRects;
- public boolean paint;
-}
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
deleted file mode 100755
index 756a8d0493..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
+++ /dev/null
@@ -1,1046 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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
- * to paint using methods such as <code>GC.drawImage()</code>
- * and display on widgets with, for example, <code>Button.setImage()</code>.
- * <p>
- * If loaded from a file format that supports it, an
- * <code>Image</code> may have transparency, meaning that certain
- * pixels are specified as being transparent when drawn. Examples
- * of file formats that support transparency are GIF and PNG.
- * </p><p>
- * There are two primary ways to use <code>Images</code>.
- * The first is to load a graphic file from disk and create an
- * <code>Image</code> from it. This is done using an <code>Image</code>
- * constructor, for example:
- * <pre>
- * Image i = new Image(device, "C:\\graphic.bmp");
- * </pre>
- * A graphic file may contain a color table specifying which
- * colors the image was intended to possess. In the above example,
- * these colors will be mapped to the closest available color in
- * SWT. It is possible to get more control over the mapping of
- * colors as the image is being created, using code of the form:
- * <pre>
- * ImageData data = new ImageData("C:\\graphic.bmp");
- * RGB[] rgbs = data.getRGBs();
- * // At this point, rgbs contains specifications of all
- * // the colors contained within this image. You may
- * // allocate as many of these colors as you wish by
- * // using the Color constructor Color(RGB), then
- * // create the image:
- * Image i = new Image(device, data);
- * </pre>
- * <p>
- * Applications which require even greater control over the image
- * loading process should use the support provided in class
- * <code>ImageLoader</code>.
- * </p><p>
- * Application code must explicitly invoke the <code>Image.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- *
- * @see Color
- * @see ImageData
- * @see ImageLoader
- * @see <a href="http://www.eclipse.org/swt/snippets/#image">Image snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, ImageAnalyzer</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public final class Image extends Resource implements Drawable {
-
- /**
- * specifies whether the receiver is a bitmap or an icon
- * (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int type;
-
- /**
- * the handle to the OS image resource
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int handle;
-
- /**
- * specifies the transparent pixel
- */
- int transparentPixel = -1;
-
- /**
- * the GC which is drawing on the image
- */
- GC memGC;
-
- /**
- * specifies the default scanline padding
- */
- static final int DEFAULT_SCANLINE_PAD = 4;
-
-Image (Device device) {
- super(device);
-}
-
-/**
- * Constructs an empty instance of this class with the
- * specified width and height. The result may be drawn upon
- * by creating a GC and using any of its drawing operations,
- * as shown in the following example:
- * <pre>
- * Image i = new Image(device, width, height);
- * GC gc = new GC(i);
- * gc.drawRectangle(0, 0, 50, 50);
- * gc.dispose();
- * </pre>
- * <p>
- * Note: Some platforms may have a limitation on the size
- * of image that can be created (size depends on width, height,
- * and depth). For example, Windows 95, 98, and ME do not allow
- * images larger than 16M.
- * </p>
- *
- * @param device the device on which to create the image
- * @param width the width of the new image
- * @param height the height of the new image
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, int width, int height) {
- super(device);
- init(width, height);
- init();
-}
-
-/**
- * Constructs a new instance of this class based on the
- * provided image, with an appearance that varies depending
- * on the value of the flag. The possible flag values are:
- * <dl>
- * <dt><b>{@link SWT#IMAGE_COPY}</b></dt>
- * <dd>the result is an identical copy of srcImage</dd>
- * <dt><b>{@link SWT#IMAGE_DISABLE}</b></dt>
- * <dd>the result is a copy of srcImage which has a <em>disabled</em> look</dd>
- * <dt><b>{@link SWT#IMAGE_GRAY}</b></dt>
- * <dd>the result is a copy of srcImage which has a <em>gray scale</em> look</dd>
- * </dl>
- *
- * @param device the device on which to create the image
- * @param srcImage the image to use as the source
- * @param flag the style, either <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or is otherwise in an invalid state</li>
- * <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the image is not supported</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, Image srcImage, int flag) {
- super(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;
- break;
- 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.alpha = data.alpha;
- newData.alphaData = data.alphaData;
- newData.maskData = data.maskData;
- newData.maskPad = data.maskPad;
- if (data.transparentPixel != -1) newData.transparentPixel = 254;
-
- /* 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];
- if (pixel != data.transparentPixel) {
- 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;
- int intensity = (red+red+green+green+green+green+green+blue) >> 3;
- if (newData.transparentPixel == intensity) intensity = 255;
- newData.data[offset] = (byte)intensity;
- } else {
- newData.data[offset] = (byte)254;
- }
- offset++;
- }
- }
- }
- init (newData);
- break;
- default:
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- init();
-}
-
-/**
- * Constructs an empty instance of this class with the
- * width and height of the specified rectangle. The result
- * may be drawn upon by creating a GC and using any of its
- * drawing operations, as shown in the following example:
- * <pre>
- * Image i = new Image(device, boundsRectangle);
- * GC gc = new GC(i);
- * gc.drawRectangle(0, 0, 50, 50);
- * gc.dispose();
- * </pre>
- * <p>
- * Note: Some platforms may have a limitation on the size
- * of image that can be created (size depends on width, height,
- * and depth). For example, Windows 95, 98, and ME do not allow
- * images larger than 16M.
- * </p>
- *
- * @param device the device on which to create the image
- * @param bounds a rectangle specifying the image's width and height (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 bounds rectangle is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, Rectangle bounds) {
- super(device);
- if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- init(bounds.width, bounds.height);
- init();
-}
-
-/**
- * Constructs an instance of this class from the given
- * <code>ImageData</code>.
- *
- * @param device the device on which to create the image
- * @param data the image data to create the image from (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 image data is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the ImageData is not supported</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, ImageData data) {
- super(device);
- init(data);
- init();
-}
-
-/**
- * Constructs an instance of this class, whose type is
- * <code>SWT.ICON</code>, from the two given <code>ImageData</code>
- * objects. The two images must be the same size. Pixel transparency
- * in either image will be ignored.
- * <p>
- * The mask image should contain white wherever the icon is to be visible,
- * and black wherever the icon is to be transparent. In addition,
- * the source image should contain black wherever the icon is to be
- * transparent.
- * </p>
- *
- * @param device the device on which to create the icon
- * @param source the color data for the icon
- * @param mask the mask data for the icon
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li>
- * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image(Device device, ImageData source, ImageData mask) {
- super(device);
- 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);
- }
- mask = ImageData.convertMask(mask);
- 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(image);
- init();
-}
-
-/**
- * Constructs an instance of this class by loading its representation
- * from the specified input stream. Throws an error if an error
- * occurs while loading the image, or if the result is an image
- * of an unsupported type. Application code is still responsible
- * for closing the input stream.
- * <p>
- * This constructor is provided for convenience when loading a single
- * image only. If the stream contains multiple images, only the first
- * one will be loaded. To load multiple images, use
- * <code>ImageLoader.load()</code>.
- * </p><p>
- * This constructor may be used to load a resource as follows:
- * </p>
- * <pre>
- * static Image loadImage (Display display, Class clazz, String string) {
- * InputStream stream = clazz.getResourceAsStream (string);
- * if (stream == null) return null;
- * Image image = null;
- * try {
- * image = new Image (display, stream);
- * } catch (SWTException ex) {
- * } finally {
- * try {
- * stream.close ();
- * } catch (IOException ex) {}
- * }
- * return image;
- * }
- * </pre>
- *
- * @param device the device on which to create the image
- * @param stream the input stream to load the image from
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
- * <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data </li>
- * <li>ERROR_UNSUPPORTED_DEPTH - if the image stream describes an image with an unsupported depth</li>
- * <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image (Device device, InputStream stream) {
- super(device);
- init(new ImageData(stream));
- init();
-}
-
-/**
- * Constructs an instance of this class by loading its representation
- * from the file with the specified name. Throws an error if an error
- * occurs while loading the image, or if the result is an image
- * of an unsupported type.
- * <p>
- * This constructor is provided for convenience when loading
- * a single image only. If the specified file contains
- * multiple images, only the first one will be used.
- *
- * @param device the device on which to create the image
- * @param filename the name of the file to load the image from
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_IO - if an IO error occurs while reading from the file</li>
- * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
- * <li>ERROR_UNSUPPORTED_DEPTH - if the image file describes an image with an unsupported depth</li>
- * <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
- * </ul>
- */
-public Image (Device device, String filename) {
- super(device);
- init(new ImageData(filename));
- init();
-}
-
-void destroy() {
- if (memGC != null) memGC.dispose();
- destroyImage(handle);
- handle = 0;
- memGC = null;
-}
-
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof 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.
- * <p>
- * There are certain uses of Images 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.
- * Use this method to check which color will be used in these cases
- * in place of transparency. This value may be set with setBackground().
- * <p>
- *
- * @return the background color of the image, or null if there is no transparency in the image
- *
- * @exception SWTException <ul>
- * <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);
-}
-
-/**
- * Returns the bounds of the receiver. The rectangle will always
- * have x and y values of 0, and the width and height of the
- * image.
- *
- * @return a rectangle specifying the image's bounds
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <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);
-}
-
-/**
- * Returns an <code>ImageData</code> based on the receiver
- * Modifications made to this <code>ImageData</code> will not
- * affect the Image.
- *
- * @return an <code>ImageData</code> containing the image's data and attributes
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
- * </ul>
- *
- * @see ImageData
- */
-public ImageData getImageData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (memGC != null) memGC.flushImage();
- 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 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++) {
- int 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 = 2;
- } 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 that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
-public int hashCode () {
- return handle;
-}
-
-void init(int width, int height) {
- if (width <= 0 || height <= 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- 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(ImageData i) {
- if (i == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- /*
- * 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) && !i.palette.isDirect) {
- 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 = (byte)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>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Image</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- */
-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);
- int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- if ((data.style & mask) == 0) {
- data.style |= SWT.LEFT_TO_RIGHT;
- }
-
- data.device = device;
- data.image = this;
- return pmMC;
-}
-
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Image</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param hDC the platform specific GC handle
- * @param data the platform specific GC data
- */
-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.
- * <p>
- * This method gets the dispose state for the image.
- * When an image has been disposed, it is an error to
- * invoke any other method using the image.
- *
- * @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 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 = (byte)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) {
- Image image = new Image(device);
- image.type = type;
- image.handle = handle;
- 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 + "}";
-}
-
-}
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
deleted file mode 100755
index 1540cb3f41..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
+++ /dev/null
@@ -1,638 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.graphics;
-
-
-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
- * of polygons.
- * <p>
- * Application code must explicitly invoke the <code>Region.dispose()</code>
- * method to release the operating system resources managed by each instance
- * when those instances are no longer required.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: GraphicsExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public final class Region extends Resource {
-
- /**
- * the OS resource for the region
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int handle;
-
- static int EMPTY_REGION = -1;
-
-/**
- * Constructs a new empty region.
- *
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
- * </ul>
- */
-public Region () {
- this(null);
-}
-/**
- * Constructs a new empty region.
- * <p>
- * You must dispose the region when it is no longer required.
- * </p>
- *
- * @param device the device on which to allocate the region
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
- * </ul>
- *
- * @see #dispose
- *
- * @since 3.0
- */
-public Region (Device device) {
- super(device);
- handle = EMPTY_REGION;
- init();
-}
-
-Region(Device device, int handle) {
- super(device);
- this.handle = handle;
-}
-
-/**
- * Adds the given polygon to the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param pointArray points that describe the polygon to merge with the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
-*
- */
-public void add (int[] pointArray) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- // TODO
-}
-
-/**
- * Adds the given rectangle to the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param rect the rectangle to merge with the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void add (Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- add (rect.x, rect.y, rect.width, rect.height);
-}
-
-/**
- * Adds the given rectangle to the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param x the x coordinate of the rectangle
- * @param y the y coordinate of the rectangle
- * @param width the width coordinate of the rectangle
- * @param height the height coordinate of the rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void add (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0 || 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)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);
- if (handle == EMPTY_REGION) handle = tile_ptr;
- else handle = OS.PhAddMergeTiles (handle, tile_ptr, null);
-}
-
-/**
- * Adds all of the polygons which make up the area covered
- * by the argument to the collection of polygons the receiver
- * maintains to describe its area.
- *
- * @param region the region to merge
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <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);
-}
-
-/**
- * Returns <code>true</code> if the point specified by the
- * arguments is inside the area specified by the receiver,
- * and <code>false</code> otherwise.
- *
- * @param x the x coordinate of the point to test for containment
- * @param y the y coordinate of the point to test for containment
- * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <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;
-}
-
-/**
- * Returns <code>true</code> if the given point is inside the
- * area specified by the receiver, and <code>false</code>
- * otherwise.
- *
- * @param pt the point to test for containment
- * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean contains (Point pt) {
- if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
-}
-
-void destroy() {
- 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
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- if (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 polygons the receiver
- * maintains to describe its area.
- *
- * @return a bounding rectangle for the region
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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);
-}
-
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
-public int hashCode () {
- return handle;
-}
-
-/**
- * Intersects the given rectangle to the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param rect the rectangle to intersect with the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void intersect (Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- intersect (rect.x, rect.y, rect.width, rect.height);
-}
-
-/**
- * Intersects the given rectangle to the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param x the x coordinate of the rectangle
- * @param y the y coordinate of the rectangle
- * @param width the width coordinate of the rectangle
- * @param height the height coordinate of the rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void intersect (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (handle == 0 || handle == EMPTY_REGION) return;
- 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(handle, tile_ptr, null);
- OS.PhFreeTiles(tile_ptr);
- OS.PhFreeTiles(handle);
- handle = intersection;
- if (handle == 0) handle = EMPTY_REGION;
-}
-
-/**
- * Intersects all of the polygons which make up the area covered
- * by the argument to the collection of polygons the receiver
- * maintains to describe its area.
- *
- * @param region the region to intersect
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void intersect (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 || handle == EMPTY_REGION) return;
- int intersection = 0;
- if (region.handle != EMPTY_REGION) intersection = OS.PhIntersectTilings(handle, region.handle, null);
- OS.PhFreeTiles(handle);
- handle = intersection;
- if (handle == 0) handle = EMPTY_REGION;
-}
-
-/**
- * Returns <code>true</code> if the rectangle described by the
- * arguments intersects with any of the polygons the receiver
- * maintains to describe its area, and <code>false</code> otherwise.
- *
- * @param x the x coordinate of the origin of the rectangle
- * @param y the y coordinate of the origin of the rectangle
- * @param width the width of the rectangle
- * @param height the height of the rectangle
- * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Rectangle#intersects(Rectangle)
- */
-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 polygons the receiver maintains to describe
- * its area and <code>false</code> otherwise.
- *
- * @param rect the rectangle to test for intersection
- * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Rectangle#intersects(Rectangle)
- */
-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.
- * <p>
- * This method gets the dispose state for the region.
- * When a region has been disposed, it is an error to
- * invoke any other method using the region.
- *
- * @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
- */
-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
- * the receiver does cover some area in the plane.
- *
- * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public boolean isEmpty () {
- return getBounds().isEmpty();
-
-}
-
-public static Region photon_new(Device device, int handle) {
- return new Region(device, handle);
-}
-
-/**
- * Subtracts the given polygon from the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param pointArray points that describe the polygon to merge with the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void subtract (int[] pointArray) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- // TODO
-}
-
-/**
- * Subtracts the given rectangle from the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param rect the rectangle to subtract from the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void subtract (Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- subtract (rect.x, rect.y, rect.width, rect.height);
-}
-
-/**
- * Subtracts the given rectangle from the collection of polygons
- * the receiver maintains to describe its area.
- *
- * @param x the x coordinate of the rectangle
- * @param y the y coordinate of the rectangle
- * @param width the width coordinate of the rectangle
- * @param height the height coordinate of the rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void subtract (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (handle == 0 || handle == EMPTY_REGION) return;
- 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);
- handle = OS.PhClipTilings(handle, tile_ptr, null);
- OS.PhFreeTiles(tile_ptr);
- if (handle == 0) handle = EMPTY_REGION;
-}
-
-/**
- * Subtracts all of the polygons which make up the area covered
- * by the argument from the collection of polygons the receiver
- * maintains to describe its area.
- *
- * @param region the region to subtract
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public void subtract (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 || handle == EMPTY_REGION) return;
- if (region.handle == EMPTY_REGION) return;
- handle = OS.PhClipTilings(handle, region.handle, null);
- if (handle == 0) handle = EMPTY_REGION;
-}
-
-/**
- * Translate all of the polygons the receiver maintains to describe
- * its area by the specified point.
- *
- * @param x the x coordinate of the point to translate
- * @param y the y coordinate of the point to translate
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void translate (int x, int y) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (handle == 0 || handle == EMPTY_REGION) return;
- PhPoint_t pt = new PhPoint_t();
- pt.x = (short)x;
- pt.y = (short)y;
- OS.PhTranslateTiles (handle, pt);
-}
-
-/**
- * Translate all of the polygons the receiver maintains to describe
- * its area by the specified point.
- *
- * @param pt the point to translate
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public void translate (Point pt) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- translate (pt.x, pt.y);
-}
-
-/**
- * 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 + "}";
-}
-}
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
deleted file mode 100755
index bde2826420..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.internal;
-
-import java.io.UnsupportedEncodingException;
-
-
-/**
- * This class implements the conversions between unicode characters
- * and the <em>platform supported</em> representation for characters.
- * <p>
- * Note that, unicode characters which can not be found in the platform
- * encoding will be converted to an arbitrary platform specific character.
- * </p>
- */
-
-public final class Converter {
- 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;
- }
-}
-}
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
deleted file mode 100755
index 291029074d..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
+++ /dev/null
@@ -1,662 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
- * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
- * may be specified.
- * </p><p>
- * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
- * </p><p>
- * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
- * when the ARROW style is specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#button">Button snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Button extends Control {
- String text = "";
- Image image;
- boolean grayed;
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#ARROW
- * @see SWT#CHECK
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#TOGGLE
- * @see SWT#FLAT
- * @see SWT#UP
- * @see SWT#DOWN
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @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 | SWT.TOGGLE)) != 0) {
- return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0);
- }
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
- return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0);
- }
- if ((style & SWT.ARROW) != 0) {
- style |= SWT.NO_FOCUS;
- 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 the user, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the control is selected by the user.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-void click () {
- click (handle);
-}
-
-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;
- 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
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the alignment will indicate the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>).
- *
- * @return the alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getAlignment () {
- checkWidget();
- if ((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 <code>true</code> if the receiver is grayed,
- * and false otherwise. When the widget does not have
- * the <code>CHECK</code> style, return false.
- *
- * @return the grayed state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.4
- */
-public boolean getGrayed () {
- checkWidget();
- if ((style & SWT.CHECK) == 0) return false;
- return grayed;
-}
-
-/**
- * Returns the receiver's image if it has one, or null
- * if it does not.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget();
- return image;
-}
-
-/**
- * Returns <code>true</code> if the receiver is selected,
- * and false otherwise.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed in. If the receiver is of any other type,
- * this method returns false.
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getSelection () {
- checkWidget();
- if ((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 or if the receiver is
- * an <code>ARROW</code> button.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget();
- if ((style & SWT.ARROW) != 0) return "";
- return text;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = display.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 by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (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
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the argument indicates the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>).
- *
- * @param alignment the new alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setAlignment (int alignment) {
- checkWidget();
- if ((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>.
- *
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed in.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (boolean selected) {
- checkWidget();
- if ((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 grayed state of the receiver. This state change
- * only applies if the control was created with the SWT.CHECK
- * style.
- *
- * @param grayed the new grayed state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public void setGrayed (boolean grayed) {
- checkWidget ();
- if ((style & SWT.CHECK) == 0) return;
- this.grayed = grayed;
-}
-
-/**
- * Sets the receiver's image to the argument, which may be
- * <code>null</code> indicating that no image should be displayed.
- * <p>
- * Note that a Button can display an image and text simultaneously
- * on Windows (starting with XP), GTK+ and OSX. On other platforms,
- * a Button that has an image and text set into it will display the
- * image or text that was set most recently.
- * </p>
- * @param image the image to display on the receiver (may be <code>null</code>)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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>
- * This method sets the button label. The label may include
- * the mnemonic character but must not contain line delimiters.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp;' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasized in a platform specific
- * manner. The mnemonic indicator character '&amp;' can be
- * escaped by doubling it in the string, causing a single
- * '&amp;' to be displayed.
- * </p><p>
- * Note that a Button can display an image and text simultaneously
- * on Windows (starting with XP), GTK+ and OSX. On other platforms,
- * a Button that has an image and text set into it will display the
- * image or text that was set most recently.
- * </p>
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.ARROW) != 0) return;
- text = string;
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
- char mnemonic = fixMnemonic (text);
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- int ptr1 = OS.malloc (buffer.length);
- OS.memmove (ptr1, 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, ptr1, 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 (ptr1);
- OS.free (ptr2);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- int code = super.traversalCode (key_sym, ke);
- if ((style & SWT.RADIO) != 0) code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
- 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
deleted file mode 100755
index acd420000a..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class provide a surface for drawing
- * arbitrary graphics.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * This class may be subclassed by custom control implementors
- * who are building controls that are <em>not</em> constructed
- * from aggregates of other controls. That is, they are either
- * painted using SWT graphics calls or are handled by native
- * methods.
- * </p>
- *
- * @see Composite
- * @see <a href="http://www.eclipse.org/swt/snippets/#canvas">Canvas snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public class Canvas extends Composite {
- Caret caret;
- IME ime;
-
-Canvas () {
- /* Do nothing */
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Canvas (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Returns the caret.
- * <p>
- * The caret for the control is automatically hidden
- * and shown when the control is painted or resized,
- * when focus is gained or lost and when an the control
- * is scrolled. To avoid drawing on top of the caret,
- * the programmer must hide and show the caret when
- * drawing in the window any other time.
- * </p>
- *
- * @return the caret for the receiver, may be null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Caret getCaret () {
- checkWidget();
- return caret;
-}
-
-/**
- * Returns the IME.
- *
- * @return the IME
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.4
- */
-public IME getIME () {
- checkWidget ();
- return ime;
-}
-
-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;
-}
-
-/**
- * Fills the interior of the rectangle specified by the arguments,
- * with the receiver's background.
- *
- * @param gc the gc where the rectangle is to be filled
- * @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
- * @param height the height of the rectangle to be filled
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.2
- */
-public void drawBackground (GC gc, int x, int y, int width, int height) {
- checkWidget ();
- if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- super.drawBackground (gc, x, y, width, height);
-}
-
-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 releaseChildren (boolean destroy) {
- if (caret != null) {
- caret.release (false);
- caret = null;
- }
- if (ime != null) {
- ime.release (false);
- ime = null;
- }
- super.releaseChildren (destroy);
-}
-
-/**
- * Scrolls a rectangular area of the receiver by first copying
- * the source area to the destination and then causing the area
- * of the source which is not covered by the destination to
- * be repainted. Children that intersect the rectangle are
- * optionally moved during the operation. In addition, outstanding
- * paint events are flushed before the source area is copied to
- * ensure that the contents of the canvas are drawn correctly.
- *
- * @param destX the x coordinate of the destination
- * @param destY the y coordinate of the destination
- * @param x the x coordinate of the source
- * @param y the y coordinate of the source
- * @param width the width of the area
- * @param height the height of the area
- * @param all <code>true</code>if children should be scrolled, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
- checkWidget();
- if (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 (all) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- Rectangle rect = child.getBounds ();
- if (Math.min(x + width, rect.x + rect.width) >= Math.max (x, rect.x) &&
- Math.min(y + height, rect.y + rect.height) >= Math.max (y, rect.y)) {
- child.setLocation (rect.x + deltaX, rect.y + deltaY);
- }
- }
- }
- 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>
- * The caret for the control is automatically hidden
- * and shown when the control is painted or resized,
- * when focus is gained or lost and when an the control
- * is scrolled. To avoid drawing on top of the caret,
- * the programmer must hide and show the caret when
- * drawing in the window any other time.
- * </p>
- * @param caret the new caret for the receiver, may be null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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();
- if (caret != null) caret.setFont (font);
- super.setFont (font);
-}
-
-/**
- * Sets the receiver's IME.
- *
- * @param ime the new IME for the receiver, may be null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the IME has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public void setIME (IME ime) {
- checkWidget ();
- if (ime != null && ime.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- this.ime = ime;
-}
-}
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
deleted file mode 100755
index dae8448165..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
+++ /dev/null
@@ -1,515 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#caret">Caret snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Canvas tab</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-// 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);
- PhPoint_t pt = new PhPoint_t ();
- PhRect_t tran_rect = new PhRect_t();
- int disjoint = OS.PtFindDisjoint( handle );
- if( disjoint != 0 )
- OS.PgSetRegion( OS.PtWidgetRid( disjoint ) );
- OS.PtWidgetExtent(handle, tran_rect) ;
- OS.PtWidgetOffset(handle, pt);
- pt.x += tran_rect.ul_x;
- pt.y += tran_rect.ul_y;
- OS.PgSetTranslation(pt,0);
- int clip = OS.PtGetVisibleTiles(handle);
- if ( clip > 0 )
- OS.PgSetMultiClipTiles(clip);
- OS.PgSetDrawMode (OS.Pg_DrawModeDSx);
- 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);
- OS.PhFreeTiles(clip);
- return true;
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent (or its display if its parent is null).
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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);
-}
-
-/**
- * Returns the font that the receiver will use to paint textual information.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Font getFont () {
- checkWidget();
- if (font != null) return font;
- return parent.getFont ();
-}
-
-/**
- * Returns the image that the receiver will use to paint the caret.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget();
- return image;
-}
-
-/**
- * Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null).
- *
- * @return the receiver's location
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getLocation () {
- checkWidget();
- return new Point (x, y);
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Canvas</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Canvas getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns a point describing the receiver's size.
- *
- * @return the receiver's size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getVisible () {
- checkWidget();
- 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 releaseParent () {
- super.releaseParent ();
- 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
- * <code>y</code> arguments are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBounds (int x, int y, int width, int height) {
- checkWidget();
- if (this.x == x && this.y == y && this.width == width && this.height == height) return;
- boolean isFocus = isFocusCaret ();
- if (isFocus && isVisible) hideCaret ();
- this.x = x; this.y = y;
- this.width = width; this.height = height;
- if (isFocus && isVisible) 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
- * kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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
- * which is a filled rectangle if the argument is null
- *
- * @param image the new image (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- boolean isFocus = isFocusCaret ();
- if (isFocus && isVisible) hideCaret ();
- this.image = image;
- if (isFocus && isVisible) showCaret ();
-}
-
-/**
- * Sets the receiver's location to the point specified by
- * the arguments which are relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLocation (int x, int y) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-
-/**
- * Sets the receiver's location to the point specified by
- * the argument which is relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param location the new location for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- *
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSize (int width, int height) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-
-/**
- * Sets the receiver's size to the point specified by the argument.
- *
- * @param size the new extent for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSize (Point size) {
- checkWidget();
- if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
-}
-
-/**
- * Marks the receiver as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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
deleted file mode 100755
index 225a5743a6..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class ColorDialog extends Dialog {
- RGB rgb;
-
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a composite control which will be the parent of the new instance
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ColorDialog (Shell parent) {
- this (parent, SWT.APPLICATION_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ColorDialog (Shell parent, int style) {
- super (parent, checkStyle (parent, style));
- checkSubclass ();
-}
-
-/**
- * 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 receiver visible and brings it to the front
- * of the display.
- *
- * @return the selected color, or null if the dialog was
- * cancelled, no color was selected, or an error
- * occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 = (short) 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;
-}
-
-/**
- * Sets 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 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/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
deleted file mode 100755
index 8fc948adb5..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
+++ /dev/null
@@ -1,1400 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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
- * enter a new value by typing it into an editable text
- * field. Often, <code>Combo</code>s are used in the same place
- * where a single selection <code>List</code> widget could
- * be used but space is limited. A <code>Combo</code> takes
- * less space than a <code>List</code> widget and shows
- * similar information.
- * <p>
- * Note: Since <code>Combo</code>s can contain both a list
- * and an editable text field, it is possible to confuse methods
- * which access one versus the other (compare for example,
- * <code>clearSelection()</code> and <code>deselectAll()</code>).
- * The API documentation is careful to indicate either "the
- * receiver's list" or the "the receiver's text field" to
- * distinguish between the two cases.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>DefaultSelection, Modify, Selection, Verify</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles DROP_DOWN and SIMPLE may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see List
- * @see <a href="http://www.eclipse.org/swt/snippets/#combo">Combo snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see SWT#READ_ONLY
- * @see SWT#SIMPLE
- * @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;
- 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
- * deselected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void deselect (int index) {
- checkWidget();
- 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>
- * Note: To clear the selection in the receiver's text field,
- * use <code>clearSelection()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #clearSelection
- */
-public void deselectAll () {
- checkWidget();
- 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.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
-}
-
-/**
- * Adds the argument to the receiver's list at the given
- * zero-relative index.
- * <p>
- * Note: To add an item at the end of the list, use the
- * result of calling <code>getItemCount()</code> as the
- * index or use <code>add(String)</code>.
- * </p>
- *
- * @param string the new item
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
- }
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
- */
-public void addModifyListener (ModifyListener listener) {
- checkWidget();
- if (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 user changes the receiver's selection, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the user changes the combo's list selection.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- 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
- * it one of the messages defined in the <code>VerifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VerifyListener
- * @see #removeVerifyListener
- *
- * @since 3.1
- */
-public void addVerifyListener (VerifyListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Verify, 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
- * text field is editable, this has the effect of placing the
- * i-beam at the start of the text.
- * <p>
- * Note: To clear the selected items in the receiver's list,
- * use <code>deselectAll()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #deselectAll
- */
-public void clearSelection () {
- checkWidget();
- 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 SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 () {
- 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
- * of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget();
- 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.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemHeight () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
-/**
- * Returns a (possibly empty) array of <code>String</code>s which are
- * the items in the receiver's list.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 <code>true</code> if the receiver's list is visible,
- * and <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's list'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>
- *
- * @since 3.4
- */
-public boolean getListVisible () {
- checkWidget ();
- return false;
-}
-
-String getNameText () {
- return getText ();
-}
-
-/**
- * Returns the orientation of the receiver.
- *
- * @return the orientation style
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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.2
- */
-public int getOrientation () {
- checkWidget();
- return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
-}
-
-/**
- * Returns a <code>Point</code> whose x coordinate is the
- * character position representing the start of the selection
- * in the receiver's text field, and whose y coordinate is the
- * character position representing the end of the selection.
- * An "empty" selection is indicated by the x and y coordinates
- * having the same value.
- * <p>
- * Indexing is zero based. The range of a selection is from
- * 0..N where N is the number of characters in the widget.
- * </p>
- *
- * @return a point representing the selection start and end
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSelection () {
- checkWidget();
- if (((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.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionIndex () {
- checkWidget();
- 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, or an empty string if there are no
- * contents.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget();
- 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.
- *
- * @return the text height
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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
- * by <code>setTextLimit()</code>, it will be the constant
- * <code>Combo.LIMIT</code>.
- *
- * @return the text limit
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #LIMIT
- */
-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];
-}
-
-/**
- * Gets the number of items that are visible in the drop
- * down portion of the receiver's list.
- * <p>
- * Note: This operation is a hint and is not supported on
- * platforms that do not have this concept.
- * </p>
- *
- * @return the number of items that are visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.0
- */
-public int getVisibleItemCount () {
- checkWidget ();
- int [] args = new int [] {OS.Pt_ARG_CBOX_MAX_VISIBLE_COUNT, 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 = display.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
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (String string) {
- checkWidget();
- 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
- * to the argument, and returns the index of that item. If
- * no item is found or the starting index is out of range,
- * returns -1.
- *
- * @param string the search item
- * @param start the zero-relative index at which to begin the search
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (String string, int start) {
- checkWidget();
- if (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
- * indices (inclusive).
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (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);
- 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.
- *
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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,
- * and removes that item from the list.
- *
- * @param string the item to remove
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 and clear the
- * contents of receiver's text field.
- * <p>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void removeAll () {
- checkWidget();
- 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.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #addModifyListener
- */
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (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 user changes the receiver's selection.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is verified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VerifyListener
- * @see #addVerifyListener
- *
- * @since 3.1
- */
-public void removeVerifyListener (VerifyListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Verify, listener);
-}
-
-/**
- * Selects the item at the given zero-relative index in the receiver's
- * list. If the item at the index was already selected, it remains
- * selected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- *
- * @param index the index for the item
- * @param string the new text for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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.
- *
- * @param items the array of items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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 setItems (String [] items) {
- checkWidget();
- if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<items.length; i++) {
- if (items [i] == null) error (SWT.ERROR_INVALID_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);
-}
-
-/**
- * Marks the receiver's list as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public void setListVisible (boolean visible) {
- checkWidget ();
-}
-
-/**
- * Sets the orientation of the receiver, which must be one
- * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
- * <p>
- *
- * @param orientation new orientation style
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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.2
- */
-public void setOrientation (int orientation) {
- checkWidget();
-}
-
-/**
- * Sets the selection in the receiver's text field to the
- * range specified by the argument whose x coordinate is the
- * start of the selection and whose y coordinate is the end
- * of the selection.
- *
- * @param selection a point representing the new selection start and end
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (Point selection) {
- checkWidget();
- if (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.
- * <p>
- * This call is ignored when the receiver is read only and
- * the given string is not in the receiver's list.
- * </p>
- * <p>
- * Note: The text field in a <code>Combo</code> is typically
- * only capable of displaying a single line of text. Thus,
- * setting the text to a string containing line breaks or
- * other special characters will probably cause it to
- * display incorrectly.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (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.
- * <p>
- * To reset this value to the default, use <code>setTextLimit(Combo.LIMIT)</code>.
- * Specifying a limit value larger than <code>Combo.LIMIT</code> sets the
- * receiver's limit to <code>Combo.LIMIT</code>.
- * </p>
- * @param limit new text limit
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #LIMIT
- */
-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 ((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;
-}
-
-/**
- * Sets the number of items that are visible in the drop
- * down portion of the receiver's list.
- * <p>
- * Note: This operation is a hint and is not supported on
- * platforms that do not have this concept.
- * </p>
- *
- * @param count the new number of items to be visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.0
- */
-public void setVisibleItemCount (int visibleCount) {
- checkWidget ();
- if (visibleCount < 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_CBOX_MAX_VISIBLE_COUNT, visibleCount, 0);
-}
-
-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
deleted file mode 100755
index e87c651833..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
+++ /dev/null
@@ -1,1165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP, EMBEDDED, DOUBLE_BUFFERED</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
- * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
- * They can be used with <code>Composite</code> if you are drawing your own, but their
- * behavior is undefined if they are used with subclasses of <code>Composite</code> other
- * than <code>Canvas</code>.
- * </p><p>
- * Note: The <code>CENTER</code> style, although undefined for composites, has the
- * same value as <code>EMBEDDED</code> which is used to embed widgets from other
- * widget toolkits into SWT. On some operating systems (GTK, Motif), this may cause
- * the children of this composite to be obscured.
- * </p><p>
- * This class may be subclassed by custom control implementors
- * who are building controls that are constructed from aggregates
- * of other controls.
- * </p>
- *
- * @see Canvas
- * @see <a href="http://www.eclipse.org/swt/snippets/#composite">Composite snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public class Composite extends Scrollable {
- Layout layout;
- Control [] tabList;
- int cornerHandle;
- int layoutCount, backgroundMode;
-
-Composite () {
- /* Do nothing */
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#NO_BACKGROUND
- * @see SWT#NO_FOCUS
- * @see SWT#NO_MERGE_PAINTS
- * @see SWT#NO_REDRAW_RESIZE
- * @see SWT#NO_RADIO_GROUP
- * @see SWT#EMBEDDED
- * @see SWT#DOUBLE_BUFFERED
- * @see Widget#getStyle
- */
-public Composite (Composite parent, int style) {
- super (parent, style);
-}
-
-static int checkStyle (int style) {
- style &= SWT.TRANSPARENT;
- return 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;
-}
-
-/**
- * Clears any data that has been cached by a Layout for all widgets that
- * are in the parent hierarchy of the changed control up to and including the
- * receiver. If an ancestor does not have a layout, it is skipped.
- *
- * @param changed an array of controls that changed state and require a recalculation of size
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li>
- * <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.1
- */
-public void changed (Control[] changed) {
- checkWidget ();
- if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT);
- for (int i=0; i<changed.length; i++) {
- Control control = changed [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- boolean ancestor = false;
- Composite composite = control.parent;
- while (composite != null) {
- ancestor = composite == this;
- if (ancestor) break;
- composite = composite.parent;
- }
- if (!ancestor) error (SWT.ERROR_INVALID_PARENT);
- }
- for (int i=0; i<changed.length; i++) {
- Control child = changed [i];
- Composite composite = child.parent;
- while (child != this) {
- if (composite.layout == null || !composite.layout.flushCache (child)) {
- composite.state |= LAYOUT_CHANGED;
- }
- child = composite;
- composite = child.parent;
- }
- }
-}
-
-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) {
- changed |= (state & LAYOUT_CHANGED) != 0;
- size = layout.computeSize (this, wHint, hHint, changed);
- state &= ~LAYOUT_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 () {
- 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);
- 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 drawBackground (GC gc, int x, int y, int width, int height) {
- Color oldColor = gc.getBackground();
- gc.setBackground(getBackground());
- gc.fillRectangle(x, y, width, height);
- gc.setBackground(oldColor);
-}
-
-void drawWidget (int widget, int damage) {
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_BACKGROUND) == 0) {
-
- /*
- * Note that QNX 6.2.1 provides full widget hierarchy clipping in paint.
- */
- if (!(OS.QNX_MAJOR > 6 || (OS.QNX_MAJOR == 6 && (OS.QNX_MINOR > 2 || (OS.QNX_MINOR == 2 && OS.QNX_MICRO >= 1))))) {
- /* Get the clipping tiles for children and siblings */
- int clip_tile = getClipping (handle, topHandle (), true, true);
- if (clip_tile == 0) return;
-
- /* 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.memset(clip_rects, 0, PhRect_t.sizeof);
- }
- OS.PgSetMultiClip (clip_rects_count[0], clip_rects);
- OS.free (clip_rects);
- }
-
- /* Draw the widget */
- super.drawWidget (widget, damage);
-
- if (!(OS.QNX_MAJOR > 6 || (OS.QNX_MAJOR == 6 && (OS.QNX_MINOR > 2 || (OS.QNX_MINOR == 2 && OS.QNX_MICRO >= 1))))) {
- /* Reset the clipping */
- OS.PgSetMultiClip (0, 0);
- }
- }
- } else {
- super.drawWidget (widget, damage);
- }
-}
-
-Composite findDeferredControl () {
- return layoutCount > 0 ? this : parent.findDeferredControl ();
-}
-
-void fixTabList (Control control) {
- if (tabList == null) return;
- int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == control) count++;
- }
- if (count == 0) return;
- Control [] newList = null;
- int length = tabList.length - count;
- if (length != 0) {
- newList = new Control [length];
- int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] != control) {
- newList [index++] = tabList [i];
- }
- }
- }
- tabList = newList;
-}
-
-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 the receiver's background drawing mode. This
- * will be one of the following constants defined in class
- * <code>SWT</code>:
- * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>,
- * <code>INHERTIT_FORCE</code>.
- *
- * @return the background mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- *
- * @since 3.2
- */
-public int getBackgroundMode () {
- checkWidget ();
- return backgroundMode;
-}
-
-/**
- * Returns a (possibly empty) array containing the receiver's children.
- * Children are returned in the order that they are drawn. The topmost
- * control appears at the beginning of the array. Subsequent controls
- * draw beneath this control and appear later in the array.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of children, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return an array of children
- *
- * @see Control#moveAbove
- * @see Control#moveBelow
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Control [] getChildren () {
- checkWidget();
- 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.
- *
- * @return the receiver's layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Layout getLayout () {
- checkWidget();
- return layout;
-}
-
-/**
- * Returns <code>true</code> if the receiver has deferred
- * the performing of layout, and <code>false</code> otherwise.
- *
- * @return the receiver's deferred layout 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 #setLayoutDeferred(boolean)
- * @see #isLayoutDeferred()
- *
- * @since 3.1
- */
-public boolean getLayoutDeferred () {
- checkWidget ();
- return layoutCount > 0 ;
-}
-
-boolean hasBorder () {
- return (style & SWT.BORDER) != 0;
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) == 2;
-}
-
-boolean hooksKeys () {
- return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
-}
-
-/**
- * Returns <code>true</code> if the receiver or any ancestor
- * up to and including the receiver's nearest ancestor shell
- * has deferred the performing of layouts. Otherwise, <code>false</code>
- * is returned.
- *
- * @return the receiver's deferred layout 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 #setLayoutDeferred(boolean)
- * @see #getLayoutDeferred()
- *
- * @since 3.1
- */
-public boolean isLayoutDeferred () {
- checkWidget ();
- return findDeferredControl () != null;
-}
-
-/**
- * Gets the (possibly empty) 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;
-}
-
-/**
- * If the receiver has a layout, asks the layout to <em>lay out</em>
- * (that is, set the size and location of) the receiver's children.
- * If the receiver does not have a layout, do nothing.
- * <p>
- * This is equivalent to calling <code>layout(true)</code>.
- * </p>
- * <p>
- * Note: Layout is different from painting. If a child is
- * moved or resized such that an area in the parent is
- * exposed, then the parent will paint. If no child is
- * affected, the parent will not paint.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void layout () {
- checkWidget ();
- layout (true);
-}
-
-/**
- * If the receiver has a layout, asks the layout to <em>lay out</em>
- * (that is, set the size and location of) the receiver's children.
- * If the argument is <code>true</code> the layout must not rely
- * on any information it has cached about the immediate children. If it
- * is <code>false</code> the layout may (potentially) optimize the
- * work it is doing by assuming that none of the receiver's
- * children has changed state since the last layout.
- * If the receiver does not have a layout, do nothing.
- * <p>
- * If a child is resized as a result of a call to layout, the
- * resize event will invoke the layout of the child. The layout
- * will cascade down through all child widgets in the receiver's widget
- * tree until a child is encountered that does not resize. Note that
- * a layout due to a resize will not flush any cached information
- * (same as <code>layout(false)</code>).
- * </p>
- * <p>
- * Note: Layout is different from painting. If a child is
- * moved or resized such that an area in the parent is
- * exposed, then the parent will paint. If no child is
- * affected, the parent will not paint.
- * </p>
- *
- * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void layout (boolean changed) {
- checkWidget ();
- if (layout == null) return;
- layout (changed, false);
-}
-
-/**
- * If the receiver has a layout, asks the layout to <em>lay out</em>
- * (that is, set the size and location of) the receiver's children.
- * If the changed argument is <code>true</code> the layout must not rely
- * on any information it has cached about its children. If it
- * is <code>false</code> the layout may (potentially) optimize the
- * work it is doing by assuming that none of the receiver's
- * children has changed state since the last layout.
- * If the all argument is <code>true</code> the layout will cascade down
- * through all child widgets in the receiver's widget tree, regardless of
- * whether the child has changed size. The changed argument is applied to
- * all layouts. If the all argument is <code>false</code>, the layout will
- * <em>not</em> cascade down through all child widgets in the receiver's widget
- * tree. However, if a child is resized as a result of a call to layout, the
- * resize event will invoke the layout of the child. Note that
- * a layout due to a resize will not flush any cached information
- * (same as <code>layout(false)</code>).
- * </p>
- * <p>
- * Note: Layout is different from painting. If a child is
- * moved or resized such that an area in the parent is
- * exposed, then the parent will paint. If no child is
- * affected, the parent will not paint.
- * </p>
- *
- * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
- * @param all <code>true</code> if all children in the receiver's widget tree should be laid out, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.1
- */
-public void layout (boolean changed, boolean all) {
- checkWidget ();
- if (layout == null && !all) return;
- markLayout (changed, all);
- updateLayout (all);
-}
-
-/**
- * Forces a lay out (that is, sets the size and location) of all widgets that
- * are in the parent hierarchy of the changed control up to and including the
- * receiver. The layouts in the hierarchy must not rely on any information
- * cached about the changed control or any of its ancestors. The layout may
- * (potentially) optimize the work it is doing by assuming that none of the
- * peers of the changed control have changed state since the last layout.
- * If an ancestor does not have a layout, skip it.
- * <p>
- * Note: Layout is different from painting. If a child is
- * moved or resized such that an area in the parent is
- * exposed, then the parent will paint. If no child is
- * affected, the parent will not paint.
- * </p>
- *
- * @param changed a control that has had a state change which requires a recalculation of its size
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li>
- * <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.1
- */
-public void layout (Control [] changed) {
- checkWidget ();
- if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT);
- for (int i=0; i<changed.length; i++) {
- Control control = changed [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- boolean ancestor = false;
- Composite composite = control.parent;
- while (composite != null) {
- ancestor = composite == this;
- if (ancestor) break;
- composite = composite.parent;
- }
- if (!ancestor) error (SWT.ERROR_INVALID_PARENT);
- }
- int updateCount = 0;
- Composite [] update = new Composite [16];
- for (int i=0; i<changed.length; i++) {
- Control child = changed [i];
- Composite composite = child.parent;
- while (child != this) {
- if (composite.layout != null) {
- composite.state |= LAYOUT_NEEDED;
- if (!composite.layout.flushCache (child)) {
- composite.state |= LAYOUT_CHANGED;
- }
- }
- if (updateCount == update.length) {
- Composite [] newUpdate = new Composite [update.length + 16];
- System.arraycopy (update, 0, newUpdate, 0, update.length);
- update = newUpdate;
- }
- child = update [updateCount++] = composite;
- composite = child.parent;
- }
- }
- for (int i=updateCount-1; i>=0; i--) {
- update [i].updateLayout (false);
- }
-}
-
-void markLayout (boolean changed, boolean all) {
- if (layout != null) {
- state |= LAYOUT_NEEDED;
- if (changed) state |= LAYOUT_CHANGED;
- }
- if (all) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- children [i].markLayout (changed, all);
- }
- }
-}
-
-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);
-}
-
-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 && hooksKeys ()) {
- if (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 */
- Event event = new Event ();
- event.x = display.dragStartX;
- event.y = display.dragStartY;
- postEvent (SWT.DragDetect, event);
- }
- return OS.Pt_CONTINUE;
-}
-
-void releaseChildren (boolean destroy) {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child != null && !child.isDisposed ()) {
- child.release (false);
- }
- }
- super.releaseChildren (destroy);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- cornerHandle = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- layout = null;
- tabList = null;
-}
-
-void removeControl (Control control) {
- fixTabList (control);
-}
-
-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], true);
-}
-
-void resizeClientArea (int width, int height, boolean events) {
- 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);
- }
-
- if (events) {
- sendEvent (SWT.Resize);
- }
-}
-
-/**
- * Sets the background drawing mode to the argument which should
- * be one of the following constants defined in class <code>SWT</code>:
- * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>,
- * <code>INHERIT_FORCE</code>.
- *
- * @param mode the new background mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- *
- * @since 3.2
- */
-public void setBackgroundMode (int mode) {
- checkWidget ();
- backgroundMode = mode;
-}
-
-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, false);
- if (events) sendEvent (SWT.Resize);
- if (layout != null) {
- markLayout (false, false);
- updateLayout (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.
- *
- * @param layout the receiver's new layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLayout (Layout layout) {
- checkWidget();
- this.layout = layout;
-}
-
-/**
- * If the argument is <code>true</code>, causes subsequent layout
- * operations in the receiver or any of its children to be ignored.
- * No layout of any kind can occur in the receiver or any of its
- * children until the flag is set to false.
- * Layout operations that occurred while the flag was
- * <code>true</code> are remembered and when the flag is set to
- * <code>false</code>, the layout operations are performed in an
- * optimized manner. Nested calls to this method are stacked.
- *
- * @param defer the new defer 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 #layout(boolean)
- * @see #layout(Control[])
- *
- * @since 3.1
- */
-public void setLayoutDeferred (boolean defer) {
- if (!defer) {
- if (--layoutCount == 0) {
- if ((state & LAYOUT_CHILD) != 0 || (state & LAYOUT_NEEDED) != 0) {
- updateLayout (true);
- }
- }
- } else {
- layoutCount++;
- }
-}
-
-boolean setTabGroupFocus () {
- if (isTabItem ()) return setTabItemFocus ();
- boolean takeFocus = (style & SWT.NO_FOCUS) == 0;
- 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;
-}
-
-/**
- * Sets the tabbing order for the specified controls to
- * match the order that they occur in the argument list.
- *
- * @param tabList the ordered list of controls representing the tab order or null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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);
-}
-
-void updateLayout (boolean all) {
- Composite parent = findDeferredControl ();
- if (parent != null) {
- parent.state |= LAYOUT_CHILD;
- return;
- }
- if ((state & LAYOUT_NEEDED) != 0) {
- boolean changed = (state & LAYOUT_CHANGED) != 0;
- state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
- layout.layout (this, changed);
- }
- if (all) {
- state &= ~LAYOUT_CHILD;
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- children [i].updateLayout (all);
- }
- }
-}
-
-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
deleted file mode 100755
index 2a58676f3f..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
+++ /dev/null
@@ -1,3286 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>BORDER</dd>
- * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
- * <dt><b>Events:</b>
- * <dd>DragDetect, FocusIn, FocusOut, Help, KeyDown, KeyUp, MenuDetect, MouseDoubleClick, MouseDown, MouseEnter,
- * MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize, Traverse</dd>
- * </dl>
- * </p><p>
- * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#control">Control snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public abstract class Control extends Widget implements Drawable {
- Composite parent;
- Cursor cursor;
- Font font;
- Menu menu;
- Object layoutData;
- String toolTipText;
- Image backgroundImage;
- Region region;
- 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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#LEFT_TO_RIGHT
- * @see SWT#RIGHT_TO_LEFT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Control (Composite parent, int style) {
- super (parent, style);
- this.parent = parent;
- createWidget (0);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is moved or resized, by sending
- * it one of the messages defined in the <code>ControlListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #removeControlListener
- */
-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 a drag gesture occurs, by sending it
- * one of the messages defined in the <code>DragDetectListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragDetectListener
- * @see #removeDragDetectListener
- *
- * @since 3.3
- */
-public void addDragDetectListener (DragDetectListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.DragDetect,typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control gains or loses focus, by sending
- * it one of the messages defined in the <code>FocusListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see FocusListener
- * @see #removeFocusListener
- */
-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,
- * by sending it one of the messages defined in the
- * <code>HelpListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see HelpListener
- * @see #removeHelpListener
- */
-public void addHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Help, typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when keys are pressed and released on the system keyboard, by sending
- * it one of the messages defined in the <code>KeyListener</code>
- * interface.
- * <p>
- * When a key listener is added to a control, the control
- * will take part in widget traversal. By default, all
- * traversal keys (such as the tab key and so on) are
- * delivered to the control. In order for a control to take
- * part in traversal, it should listen for traversal events.
- * Otherwise, the user can traverse into a control but not
- * out. Note that native controls such as table and tree
- * implement key traversal in the operating system. It is
- * not necessary to add traversal listeners for these controls,
- * unless you want to override the default traversal.
- * </p>
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the platform-specific context menu trigger
- * has occurred, by sending it one of the messages defined in
- * the <code>MenuDetectListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MenuDetectListener
- * @see #removeMenuDetectListener
- *
- * @since 3.3
- */
-public void addMenuDetectListener (MenuDetectListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.MenuDetect, typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when mouse buttons are pressed and released, by sending
- * it one of the messages defined in the <code>MouseListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseListener
- * @see #removeMouseListener
- */
-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 moves, by sending it one of the
- * messages defined in the <code>MouseMoveListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseMoveListener
- * @see #removeMouseMoveListener
- */
-public void addMouseMoveListener (MouseMoveListener listener) {
- checkWidget();
- if (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 mouse passes or hovers over controls, by sending
- * it one of the messages defined in the <code>MouseTrackListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseTrackListener
- * @see #removeMouseTrackListener
- */
-public void addMouseTrackListener (MouseTrackListener listener) {
- checkWidget();
- if (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 wheel is scrolled, by sending
- * it one of the messages defined in the
- * <code>MouseWheelListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseWheelListener
- * @see #removeMouseWheelListener
- *
- * @since 3.3
- */
-public void addMouseWheelListener (MouseWheelListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.MouseWheel, typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver needs to be painted, by sending it
- * one of the messages defined in the <code>PaintListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see PaintListener
- * @see #removePaintListener
- */
-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
- * one of the messages defined in the <code>TraverseListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see TraverseListener
- * @see #removeTraverseListener
- */
-public void addTraverseListener (TraverseListener listener) {
- checkWidget();
- if (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.
- *
- * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setFocus
- */
-public boolean forceFocus () {
- checkWidget();
- /*
- * 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;
- shell.bringToTop (false);
- OS.PtContainerGiveFocus (handle, null);
- return hasFocus ();
-}
-
-void checkBuffered () {
- style &= ~SWT.DOUBLE_BUFFERED;
-}
-
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a control is the size that it would
- * best be displayed at. The width hint and height hint arguments
- * allow the caller to ask a control questions such as "Given a particular
- * width, how high does the control need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @return the preferred size of the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack(boolean)
- * @see "computeTrim, getClientArea for controls that implement them"
- */
-public Point computeSize (int wHint, int hHint) {
- return computeSize (wHint, hHint, true);
-}
-
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> of a control is the size that it would
- * best be displayed at. The width hint and height hint arguments
- * allow the caller to ask a control questions such as "Given a particular
- * width, how high does the control need to be to show all of the contents?"
- * To indicate that the caller does not wish to constrain a particular
- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
- * </p><p>
- * If the changed flag is <code>true</code>, it indicates that the receiver's
- * <em>contents</em> have changed, therefore any caches that a layout manager
- * containing the control may have been keeping need to be flushed. When the
- * control is resized, the changed flag will be <code>false</code>, so layout
- * manager caches can be retained.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
- * @return the preferred size of the control.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack(boolean)
- * @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);
- checkBuffered ();
- setZOrder ();
- realizeWidget ();
- setDefaultFont ();
-}
-
-int defaultBackground () {
- return display.WIDGET_BACKGROUND;
-}
-
-byte [] defaultFont () {
- return display.TEXT_FONT;
-}
-
-int defaultForeground () {
- return display.WIDGET_FOREGROUND;
-}
-
-boolean drawGripper (int x, int y, int width, int height, boolean vertical) {
- return false;
-}
-
-/**
- * Detects a drag and drop gesture. This method is used
- * to detect a drag gesture when called from within a mouse
- * down listener.
- *
- * <p>By default, a drag is detected when the gesture
- * occurs anywhere within the client area of a control.
- * Some controls, such as tables and trees, override this
- * behavior. In addition to the operating system specific
- * drag gesture, they require the mouse to be inside an
- * item. Custom widget writers can use <code>setDragDetect</code>
- * to disable the default detection, listen for mouse down,
- * and then call <code>dragDetect()</code> from within the
- * listener to conditionally detect a drag.
- * </p>
- *
- * @param event the mouse down event
- *
- * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when the event is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragDetectListener
- * @see #addDragDetectListener
- *
- * @see #getDragDetect
- * @see #setDragDetect
- *
- * @since 3.3
- */
-public boolean dragDetect (Event event) {
- checkWidget ();
- if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
-}
-
-/**
- * Detects a drag and drop gesture. This method is used
- * to detect a drag gesture when called from within a mouse
- * down listener.
- *
- * <p>By default, a drag is detected when the gesture
- * occurs anywhere within the client area of a control.
- * Some controls, such as tables and trees, override this
- * behavior. In addition to the operating system specific
- * drag gesture, they require the mouse to be inside an
- * item. Custom widget writers can use <code>setDragDetect</code>
- * to disable the default detection, listen for mouse down,
- * and then call <code>dragDetect()</code> from within the
- * listener to conditionally detect a drag.
- * </p>
- *
- * @param event the mouse down event
- *
- * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT when the event is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragDetectListener
- * @see #addDragDetectListener
- *
- * @see #getDragDetect
- * @see #setDragDetect
- *
- * @since 3.3
- */
-public boolean dragDetect (MouseEvent event) {
- checkWidget ();
- if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
-}
-
-boolean dragDetect (int button, int count, int stateMask, int x, int y) {
- //TODO - not implemented
- return false;
-}
-
-int drawProc (int widget, int damage) {
- if (widget <=0) return OS.Pt_CONTINUE;
- drawWidget (widget, damage );
- if (!hooks(SWT.Paint) && !filters (SWT.Paint)) return OS.Pt_CONTINUE;
- /* Send the paint event */
- PhPoint_t pt = new PhPoint_t ();
- PhRect_t widRect = new PhRect_t();
- OS.PtWidgetExtent(widget, widRect) ;
- OS.PtWidgetOffset(widget, pt);
- pt.x += widRect.ul_x;
- pt.y += widRect.ul_y;
- damage = OS.PhCopyTiles( damage );
- PhTile_t tile = new PhTile_t ();
- OS.memmove (tile, damage, PhTile_t.sizeof);
- int transPoint = OS.malloc ( PhPoint_t.sizeof);
- OS.memmove(transPoint, pt, PhPoint_t.sizeof);
- OS.PhDeTranslateTiles(damage, transPoint);
- OS.free(transPoint);
- OS.memmove (tile, damage, PhTile_t.sizeof);
- boolean noMerge = (style & SWT.NO_MERGE_PAINTS) != 0 && (state & CANVAS) != 0;
- if (tile.next != 0 && noMerge)
- {
- OS.memmove (tile, tile.next, PhTile_t.sizeof);
- while (tile.next != 0)
- {
- Event event = new Event ();
- event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
- event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
- event.x = tile.rect_ul_x;
- event.y = tile.rect_ul_y;
- 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;
- if ( tile.next != 0 )
- OS.memmove (tile, tile.next, PhTile_t.sizeof);
- }
- }
- else
- {
- int rect1 = OS.malloc (PhRect_t.sizeof);
- int rect2 = OS.malloc (PhRect_t.sizeof);
- OS.memmove (rect1, tile, PhRect_t.sizeof);
- OS.memmove (rect2, widRect, PhRect_t.sizeof);
- int inter = OS.PhRectIntersect(rect1, rect2);
- if ( inter == 1 )
- {
- OS.memmove(widRect, rect1, PhRect_t.sizeof);
- Event event = new Event ();
- event.x = widRect.ul_x;
- event.y = widRect.ul_y;
- event.width = widRect.lr_x - widRect.ul_x + 1;
- event.height = widRect.lr_y - widRect.ul_y + 1;
- GC gc = event.gc = new GC (this);
- gc.setClipping(event.x, event.y, event.width, event.height );
- sendEvent (SWT.Paint, event);
- gc.dispose ();
- event.gc = null;
- }
- OS.free(rect1);
- OS.free(rect2);
- }
- OS.PhFreeTiles( damage );
- return OS.Pt_CONTINUE;
-}
-
-void drawWidget (int widget, int damage) {
- int widgetClass = widgetClass ();
- if (widgetClass != 0) OS.PtSuperClassDraw (widgetClass, handle, damage);
-}
-
-void enableWidget (boolean enabled) {
- 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);
-}
-
-/**
- * Returns the accessible object for the receiver.
- * If this is the first time this object is requested,
- * then the object is created and returned.
- *
- * @return the accessible object
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Accessible#addAccessibleListener
- * @see Accessible#addAccessibleControlListener
- *
- * @since 2.0
- */
-public Accessible getAccessible () {
- checkWidget ();
- if (accessible == null) {
- accessible = Accessible.internal_new_Accessible (this);
- }
- return accessible;
-}
-
-/**
- * Returns the receiver's background color.
- * <p>
- * Note: This operation is a hint and may be overridden by the platform.
- * For example, on some versions of Windows the background of a TabFolder,
- * is a gradient rather than a solid color.
- * </p>
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Color getBackground () {
- checkWidget();
- int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return Color.photon_new (display, args [1]);
-}
-
-/**
- * Returns the receiver's background image.
- *
- * @return the background image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.2
- */
-public Image getBackgroundImage () {
- checkWidget ();
- return backgroundImage;
-}
-
-/**
- * Returns the font that the receiver will use to paint textual information.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Font getFont () {
- checkWidget();
- if (font != null) return font;
- 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 (display, font);
-}
-
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Color getForeground () {
- checkWidget();
- int [] args = {OS.Pt_ARG_COLOR, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return Color.photon_new (display, args [1]);
-}
-
-/**
- * Returns the receiver's border width.
- *
- * @return the border width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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),
- * unless the receiver is a shell. In this case, the location is
- * relative to the display.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle getBounds () {
- checkWidget();
- 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 receiver's cursor, or null if it has not been set.
- * <p>
- * When the mouse pointer passes over a control its appearance
- * is changed to match the control's cursor.
- * </p>
- *
- * @return the receiver's cursor or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.3
- */
-public Cursor getCursor () {
- checkWidget ();
- return cursor;
-}
-
-/**
- * Returns <code>true</code> if the receiver is detecting
- * drag gestures, and <code>false</code> otherwise.
- *
- * @return the receiver's drag detect 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>
- *
- * @since 3.3
- */
-public boolean getDragDetect () {
- checkWidget ();
- //TODO - not implemented
- return true;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> otherwise. A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #isEnabled
- */
-public boolean getEnabled () {
- checkWidget ();
- return (state & DISABLED) == 0;
-}
-
-/**
- * Returns layout data which is associated with the receiver.
- *
- * @return the receiver's layout data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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), unless
- * the receiver is a shell. In this case, the point is
- * relative to the display.
- *
- * @return the receiver's location
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getLocation () {
- checkWidget();
- 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
- * menu that is displayed when the user requests one for
- * the control. The sequence of key strokes, button presses
- * and/or button releases that are used to request a pop up
- * menu is platform specific.
- *
- * @return the receiver's menu
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Menu getMenu () {
- checkWidget();
- return menu;
-}
-
-/**
- * Returns the receiver's monitor.
- *
- * @return the receiver's monitor
- *
- * @since 3.0
- */
-public Monitor getMonitor () {
- checkWidget();
- Monitor [] monitors = display.getMonitors ();
- if (monitors.length == 1) return monitors [0];
- int index = -1, value = -1;
- Rectangle bounds = getBounds ();
- if (this != getShell ()) {
- bounds = display.map (this.parent, null, bounds);
- }
- for (int i=0; i<monitors.length; i++) {
- Rectangle rect = bounds.intersection (monitors [i].getBounds ());
- int area = rect.width * rect.height;
- if (area > 0 && area > value) {
- index = i;
- value = area;
- }
- }
- if (index >= 0) return monitors [index];
- int centerX = bounds.x + bounds.width / 2, centerY = bounds.y + bounds.height / 2;
- for (int i=0; i<monitors.length; i++) {
- Rectangle rect = monitors [i].getBounds ();
- int x = centerX < rect.x ? rect.x - centerX : centerX > rect.x + rect.width ? centerX - rect.x - rect.width : 0;
- int y = centerY < rect.y ? rect.y - centerY : centerY > rect.y + rect.height ? centerY - rect.y - rect.height : 0;
- int distance = x * x + y * y;
- if (index == -1 || distance < value) {
- index = i;
- value = distance;
- }
- }
- return monitors [index];
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Composite</code>
- * or null when the receiver is a shell that was created with null or
- * a display for a parent.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Composite getParent () {
- checkWidget();
- 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.
- * 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 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.
- *
- * @return the receiver's tool tip text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
-/**
- * Returns the region that defines the shape of the control,
- * or null if the control has the default shape.
- *
- * @return the region that defines the shape of the shell (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public Region getRegion () {
- checkWidget ();
- return region;
-}
-
-/**
- * Returns the receiver's shell. For all controls other than
- * shells, this simply returns the control's nearest ancestor
- * shell. Shells return themselves, even if they are children
- * of other shells.
- *
- * @return the receiver's shell
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getParent
- */
-public Shell getShell () {
- checkWidget();
- return parent.getShell ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible, and
- * <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 = display.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>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Control</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- */
-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 mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- if ((data.style & mask) == 0) {
- data.style |= style & (mask | SWT.MIRRORED);
- }
- int [] args = {OS.Pt_ARG_COLOR, 0, 0, OS.Pt_ARG_FILL_COLOR, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- data.device = display;
- data.widget = handle;
- int disjoint = OS.PtFindDisjoint( handle );
- if( disjoint != 0 )
- OS.PgSetRegion( OS.PtWidgetRid( disjoint ) );
- data.topWidget = topHandle ();
- data.foreground = args [1];
- data.background = args [4];
- data.font = getFont ();
- return phGC;
-}
-
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Control</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param hDC the platform specific GC handle
- * @param data the platform specific GC data
- */
-public void internal_dispose_GC (int phGC, GCData data) {
- checkWidget ();
- OS.PgDestroyGC(phGC);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * ancestors up to and including the receiver's nearest ancestor
- * shell are enabled. Otherwise, <code>false</code> is returned.
- * 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 has the user-interface
- * focus, and <code>false</code> otherwise.
- *
- * @return the receiver's focus state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean isFocusControl () {
- checkWidget();
- return hasFocus ();
-}
-
-/**
- * Returns <code>true</code> if the underlying operating
- * system supports this reparenting, otherwise <code>false</code>
- *
- * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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
- * ancestors up to and including the receiver's nearest ancestor
- * shell are visible. Otherwise, <code>false</code> is returned.
- *
- * @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);
-}
-
-void markLayout (boolean changed, boolean all) {
- /* Do nothing */
-}
-
-Decorations menuShell () {
- return parent.menuShell ();
-}
-
-/**
- * Moves the receiver above the specified control in the
- * drawing order. If the argument is null, then the receiver
- * is moved to the top of the drawing order. The control at
- * the top of the drawing order will not be covered by other
- * controls even if they occupy intersecting areas.
- *
- * @param control the sibling control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#moveBelow
- * @see Composite#getChildren
- */
-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
- * is moved to the bottom of the drawing order. The control at
- * the bottom of the drawing order will be covered by all other
- * controls which occupy intersecting areas.
- *
- * @param control the sibling control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#moveAbove
- * @see Composite#getChildren
- */
-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
- * from its layout, if there is one.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #computeSize(int, int, boolean)
- */
-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
- * from its layout, if there is one.
- * <p>
- * If the changed flag is <code>true</code>, it indicates that the receiver's
- * <em>contents</em> have changed, therefore any caches that a layout manager
- * containing the control may have been keeping need to be flushed. When the
- * control is resized, the changed flag will be <code>false</code>, so layout
- * manager caches can be retained.
- * </p>
- *
- * @param changed whether or not the receiver's contents have changed
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #computeSize(int, int, boolean)
- */
-public void pack (boolean changed) {
- checkWidget();
- setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
-}
-
-/**
- * Prints the receiver and all children.
- *
- * @param gc the gc where the drawing occurs
- * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public boolean print (GC gc) {
- checkWidget ();
- if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- return false;
-}
-
-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);
- switch ((int) ev.subtype) {
- case OS.Ph_EV_PTR_ENTER:
- case OS.Ph_EV_PTR_ENTER_FROM_CHILD:{
- Event event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, SWT.MouseEnter, pe, ev);
- sendEvent (SWT.MouseEnter, event);
- break;
- }
- case OS.Ph_EV_PTR_LEAVE:
- case OS.Ph_EV_PTR_LEAVE_TO_CHILD: {
- Event event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, SWT.MouseExit, pe, ev);
- sendEvent (SWT.MouseExit, event);
- break;
- }
- case OS.Ph_EV_PTR_STEADY: {
- Event event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, SWT.MouseHover, pe, ev);
- 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.count = pe.click_count;
- event.time = ev.timestamp;
- setMouseState (event, SWT.MouseDown, pe, ev);
- postEvent (SWT.MouseDown, event);
- if (pe.click_count == 2) {
- Event clickEvent = new Event ();
- clickEvent.count = pe.click_count;
- clickEvent.time = ev.timestamp;
- setMouseState (clickEvent, SWT.MouseDoubleClick, pe, ev);
- postEvent (SWT.MouseDoubleClick, clickEvent);
- }
- if (event.button == 3) {
- Event menuEvent = new Event ();
- menuEvent.x = pe.pos_x;
- menuEvent.y = pe.pos_y;
- sendEvent (SWT.MenuDetect, menuEvent);
- if (menuEvent.doit) {
- if (menu != null && !menu.isDisposed ()) {
- if (menuEvent.x != event.x || menuEvent.y != event.y) {
- menu.setLocation (menuEvent.x, menuEvent.y);
- }
- menu.setVisible (true);
- }
- }
- }
- display.dragStartX = pe.pos_x + ev.translation_x;
- display.dragStartY = pe.pos_y + ev.translation_y;
- /*
- * 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.count = pe.click_count;
- event.time = ev.timestamp;
- setMouseState (event, SWT.MouseUp, 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, SWT.MouseMove, 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_CONSUME;
- }
- }
- }
-
- Event event = new Event ();
- event.time = ev.timestamp;
- if (!setKeyState (event, type, ke)) return OS.Pt_PROCESS;
- 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;
- }
- sendEvent (type, event);
- // widget could be disposed at this point
- if (isDisposed ()) return OS.Pt_CONSUME;
- return event.doit ? OS.Pt_PROCESS :OS.Pt_CONSUME;
-}
-
-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, SWT.MouseMove, 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.display;
- 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 releaseHandle () {
- super.releaseHandle ();
- parent = null;
-}
-
-void releaseParent () {
- super.releaseParent ();
- parent.removeControl (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
- toolTipHandle = 0;
- if (menu != null && !menu.isDisposed ()) {
- menu.dispose ();
- }
- menu = null;
- cursor = null;
- layoutData = null;
- region = null;
-}
-
-/**
- * Causes the entire bounds of the receiver to be marked
- * as needing to be redrawn. The next time a paint request
- * is processed, the control will be completely painted,
- * including the background.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #update()
- * @see PaintListener
- * @see SWT#Paint
- * @see SWT#NO_BACKGROUND
- * @see SWT#NO_REDRAW_RESIZE
- * @see SWT#NO_MERGE_PAINTS
- * @see SWT#DOUBLE_BUFFERED
- */
-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.
- * The next time a paint request is processed, that area of
- * the receiver will be painted, including the background.
- * If the <code>all</code> flag is <code>true</code>, any
- * children of the receiver which intersect with the specified
- * area will also paint their intersecting areas. If the
- * <code>all</code> flag is <code>false</code>, the children
- * will not be painted.
- *
- * @param x the x coordinate of the area to draw
- * @param y the y coordinate of the area to draw
- * @param width the width of the area to draw
- * @param height the height of the area to draw
- * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #update()
- * @see PaintListener
- * @see SWT#Paint
- * @see SWT#NO_BACKGROUND
- * @see SWT#NO_REDRAW_RESIZE
- * @see SWT#NO_MERGE_PAINTS
- * @see SWT#DOUBLE_BUFFERED
- */
-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.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when a drag gesture occurs.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DragDetectListener
- * @see #addDragDetectListener
- *
- * @since 3.3
- */
-public void removeDragDetectListener(DragDetectListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.DragDetect, listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control gains or loses focus.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the help events are generated for the control.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when keys are pressed and released on the system keyboard.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the platform-specific context menu trigger has
- * occurred.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MenuDetectListener
- * @see #addMenuDetectListener
- *
- * @since 3.3
- */
-public void removeMenuDetectListener (MenuDetectListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.MenuDetect, listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when mouse buttons are pressed and released.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the mouse moves.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the mouse passes or hovers over controls.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the mouse wheel is scrolled.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseWheelListener
- * @see #addMouseWheelListener
- *
- * @since 3.3
- */
-public void removeMouseWheelListener (MouseWheelListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.MouseWheel, listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver needs to be painted.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when traversal events occur.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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;
-}
-
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the arguments. The <code>x</code> and
- * <code>y</code> arguments are relative to the receiver's
- * parent (or its display if its parent is null), unless
- * the receiver is a shell. In this case, the <code>x</code>
- * and <code>y</code> arguments are relative to the display.
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause that
- * value to be set to zero instead.
- * </p>
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBounds (int x, int y, int width, int height) {
- checkWidget();
- 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
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause that
- * value to be set to zero instead.
- * </p>
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBounds (Rectangle rect) {
- if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
-}
-
-/**
- * If the argument is <code>true</code>, causes the receiver to have
- * all mouse events delivered to it until the method is called with
- * <code>false</code> as the argument. Note that on some platforms,
- * a mouse button must currently be down for capture to be assigned.
- *
- * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCapture (boolean capture) {
- checkWidget();
-}
-
-/**
- * Sets the receiver's cursor to the cursor specified by the
- * argument, or to the default cursor for that kind of control
- * if the argument is null.
- * <p>
- * When the mouse pointer passes over a control its appearance
- * is changed to match the control's cursor.
- * </p>
- *
- * @param cursor the new cursor (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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;
- }
- this.cursor = cursor;
- 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);
- }
-}
-
-/**
- * Sets the receiver's drag detect state. If the argument is
- * <code>true</code>, the receiver will detect drag gestures,
- * otherwise these gestures will be ignored.
- *
- * @param dragDetect the new drag detect 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>
- *
- * @since 3.3
- */
-public void setDragDetect (boolean dragDetect) {
- checkWidget ();
- //TODO - not implemented
-}
-
-/**
- * Enables the receiver if the argument is <code>true</code>,
- * and disables it otherwise. A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEnabled (boolean enabled) {
- checkWidget ();
- if (enabled) {
- if ((state & DISABLED) == 0) return;
- state &= ~DISABLED;
- } else {
- if ((state & DISABLED) != 0) return;
- state |= DISABLED;
- }
- enableWidget (enabled);
-}
-
-/**
- * Causes the receiver to have the <em>keyboard focus</em>,
- * such that all keyboard events will be delivered to it. Focus
- * reassignment will respect applicable platform constraints.
- *
- * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #forceFocus
- */
-public boolean setFocus () {
- checkWidget();
- if ((style & SWT.NO_FOCUS) != 0) return false;
- return forceFocus ();
-}
-
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- * <p>
- * Note: This operation is a hint and may be overridden by the platform.
- * For example, on Windows the background of a Button cannot be changed.
- * </p>
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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);
-}
-
-/**
- * Sets the receiver's background image to the image specified
- * by the argument, or to the default system color for the control
- * if the argument is null. The background image is tiled to fill
- * the available space.
- * <p>
- * Note: This operation is a hint and may be overridden by the platform.
- * For example, on Windows the background of a Button cannot be changed.
- * </p>
- * @param image the new image (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if the argument is not a bitmap</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.2
- */
-public void setBackgroundImage (Image image) {
- checkWidget ();
- if (image != null) {
- if (image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (image.type != SWT.BITMAP) error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (backgroundImage == image) return;
- backgroundImage = image;
-}
-
-void setBackgroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
-}
-
-void setDefaultFont () {
- 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
- * kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 ();
- }
- this.font = font;
- 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
- * if the argument is null.
- * <p>
- * Note: This operation is a hint and may be overridden by the platform.
- * </p>
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- *
- * @param layoutData the new layout data for the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLayoutData (Object layoutData) {
- checkWidget();
- this.layoutData = layoutData;
-}
-
-/**
- * Sets the receiver's location to the point specified by
- * the arguments which are relative to the receiver's
- * parent (or its display if its parent is null), unless
- * the receiver is a shell. In this case, the point is
- * relative to the display.
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLocation (int x, int y) {
- checkWidget();
- setBounds (x, y, 0, 0, true, false, true);
-}
-
-/**
- * Sets the receiver's location to the point specified by
- * the arguments which are relative to the receiver's
- * parent (or its display if its parent is null), unless
- * the receiver is a shell. In this case, the point is
- * relative to the display.
- *
- * @param location the new location for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-
-/**
- * Sets the receiver's pop up menu to the argument.
- * All controls may optionally have a pop up
- * menu that is displayed when the user requests one for
- * the control. The sequence of key strokes, button presses
- * and/or button releases that are used to request a pop up
- * menu is platform specific.
- * <p>
- * Note: Disposing of a control that has a pop up menu will
- * dispose of the menu. To avoid this behavior, set the
- * menu to null before the control is disposed.
- * </p>
- *
- * @param menu the new pop up menu
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- * Returns <code>true</code> if the parent is successfully changed.
- *
- * @param parent the new parent for the control.
- * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * <li>ERROR_NULL_ARGUMENT - if the parent is <code>null</code></li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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 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>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause them to be
- * set to zero instead.
- * </p>
- *
- * @param size the new size for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSize (Point size) {
- checkWidget();
- if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
-}
-
-boolean setTabGroupFocus () {
- return setTabItemFocus ();
-}
-
-boolean setTabItemFocus () {
- if (!isShowing ()) return false;
- return forceFocus ();
-}
-
-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
- * can occur in the receiver until the flag is set to true.
- * Graphics operations that occurred while the flag was
- * <code>false</code> are lost. When the flag is set to <code>true</code>,
- * the entire widget is marked as needing to be redrawn. Nested calls
- * to this method are stacked.
- * <p>
- * Note: This operation is a hint and may not be supported on some
- * platforms or for some widgets.
- * </p>
- *
- * @param redraw the new redraw state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #redraw(int, int, int, int, boolean)
- * @see #update()
- */
-public void setRedraw (boolean redraw) {
- checkWidget();
- if (redraw) {
- OS.PtContainerRelease (handle);
- } else {
- OS.PtContainerHold (handle);
- }
-}
-
-/**
- * Sets the shape of the control to the region specified
- * by the argument. When the argument is null, the
- * default shape of the control is restored.
- *
- * @param region the region that defines the shape of the control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public void setRegion (Region region) {
- checkWidget ();
- if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- // TODO implement setRegion
- this.region = region;
-}
-/**
- * Sets the receiver's size to the point specified by the arguments.
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause that
- * value to be set to zero instead.
- * </p>
- *
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSize (int width, int height) {
- checkWidget();
- 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.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setVisible (boolean visible) {
- checkWidget ();
- int topHandle = topHandle ();
- int oldFlags = OS.PtWidgetFlags (topHandle);
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if ((oldFlags & OS.Pt_DELAY_REALIZE) == flags) return;
- if (visible) {
- sendEvent (SWT.Show);
- if (isDisposed ()) return;
- OS.PtRealizeWidget (topHandle);
- } else {
- OS.PtUnrealizeWidget (topHandle);
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the FocusOut
- * event that is triggered by PtUnrealizeWidget if the widget
- * being hidden has focus. If this happens, just return.
- */
- if (isDisposed ()) return;
- sendEvent(SWT.Hide);
- }
-}
-
-/**
- * Sets the receiver's tool tip text to the argument, which
- * may be null indicating that the default tool tip for the
- * control will be shown. For a control that has a default
- * tool tip, such as the Tree control on Windows, setting
- * the tool tip text to an empty string replaces the default,
- * causing no tool tip text to be shown.
- * <p>
- * The mnemonic indicator (character '&amp;') is not displayed in a tool tip.
- * To display a single '&amp;' in the tool tip, the character '&amp;' can be
- * escaped by doubling it in the string.
- * </p>
- *
- * @param string the new tool tip text (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setToolTipText (String string) {
- checkWidget();
- 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;
- }
- }
- }
- }
-}
-
-/**
- * Returns a point which is the result of converting the
- * argument, which is specified in display relative coordinates,
- * to coordinates relative to the receiver.
- * <p>
- * @param x the x coordinate to be translated
- * @param y the y coordinate to be translated
- * @return the translated coordinates
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 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,
- * to coordinates relative to the receiver.
- * <p>
- * @param point the point to be translated (must not be null)
- * @return the translated coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point toControl (Point point) {
- checkWidget();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toControl (point.x, point.y);
-}
-
-/**
- * Returns a point which is the result of converting the
- * argument, which is specified in coordinates relative to
- * the receiver, to display relative coordinates.
- * <p>
- * @param x the x coordinate to be translated
- * @param y the y coordinate to be translated
- * @return the translated coordinates
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 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
- * the receiver, to display relative coordinates.
- * <p>
- * @param point the point to be translated (must not be null)
- * @return the translated coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point toDisplay (Point point) {
- checkWidget();
- if (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;
- event.detail = detail;
- if (!setKeyState (event, SWT.Traverse, phEvent)) return false;
- 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 true;
- 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:
- * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>,
- * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>,
- * <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>.
- *
- * @param traversal the type of traversal
- * @return true if the traversal succeeded
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean traverse (int traversal) {
- checkWidget ();
- 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 ()) {
- 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.
- */
- if (index == length) return false;
- 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
- * to be processed before this method returns. If there
- * are no outstanding paint request, this method does
- * nothing.
- * <p>
- * Note: This method does not cause a redraw.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #redraw()
- * @see #redraw(int, int, int, int, boolean)
- * @see PaintListener
- * @see SWT#Paint
- */
-public void update () {
- checkWidget();
- OS.PtFlush ();
-}
-
-void updateLayout (boolean all) {
- /* Do nothing */
-}
-
-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
deleted file mode 100755
index cab73999ad..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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
- * level shells or dialogs. Class <code>Shell</code>
- * shares a significant amount of code with this class,
- * and is a subclass.
- * <p>
- * IMPORTANT: This class was intended to be abstract and
- * should <em>never</em> be referenced or instantiated.
- * Instead, the class <code>Shell</code> should be used.
- * </p>
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * Note: The styles supported by this class must be treated
- * as <em>HINT</em>s, since the window manager for the
- * desktop on which the instance is visible has ultimate
- * control over the appearance and behavior of decorations.
- * For example, some window managers only support resizable
- * windows and will always assume the RESIZE style, even if
- * it is not set.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see #getMinimized
- * @see #getMaximized
- * @see Shell
- * @see SWT
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Decorations extends Canvas {
- Menu menuBar;
- Menu [] menus;
- String text = "";
- Image image;
- Image [] images = new Image [0];
- 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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#ON_TOP
- * @see SWT#TOOL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Decorations (Composite parent, int style) {
- super (parent, style);
-}
-
-static int checkStyle (int style) {
- if ((style & SWT.NO_TRIM) != 0) {
- style &= ~(SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.BORDER);
- }
- 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 (boolean force) {
- moveAbove (null);
-}
-
-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.
- *
- * @return the default button or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setDefaultButton(Button)
- */
-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
- * displayed by the window manager when the instance is
- * marked as iconified, and may also be displayed somewhere
- * in the trim when the instance is in normal or maximized
- * states.
- * <p>
- * Note: This method will return null if called before
- * <code>setImage()</code> is called. It does not provide
- * access to a window manager provided, "default" image
- * even if one exists.
- * </p>
- *
- * @return the image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget();
- return image;
-}
-
-/**
- * Returns the receiver's images if they had previously been
- * set using <code>setImages()</code>. Images are typically
- * displayed by the window manager when the instance is
- * marked as iconified, and may also be displayed somewhere
- * in the trim when the instance is in normal or maximized
- * states. Depending where the icon is displayed, the platform
- * chooses the icon with the "best" attributes. It is expected
- * that the array will contain the same icon rendered at different
- * sizes, with different depth and transparency attributes.
- *
- * <p>
- * Note: This method will return an empty array if called before
- * <code>setImages()</code> is called. It does not provide
- * access to a window manager provided, "default" image
- * even if one exists.
- * </p>
- *
- * @return the images
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.0
- */
-public Image [] getImages () {
- checkWidget ();
- if (images == null) return new Image [0];
- Image [] result = new Image [images.length];
- System.arraycopy (images, 0, result, 0, images.length);
- return result;
-}
-
-/**
- * Returns <code>true</code> if the receiver is currently
- * maximized, and false otherwise.
- * <p>
- *
- * @return the maximized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMaximized
- */
-public boolean getMaximized () {
- checkWidget();
- return false;
-}
-
-/**
- * Returns <code>true</code> if the receiver is currently
- * minimized, and false otherwise.
- * <p>
- *
- * @return the minimized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMinimized
- */
-public boolean getMinimized () {
- checkWidget();
- return false;
-}
-
-/**
- * Returns the receiver's menu bar if one had previously
- * been set, otherwise returns null.
- *
- * @return the menu bar or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Menu getMenuBar () {
- checkWidget();
- 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
- * <em>title</em>. If the text has not previously been set,
- * returns an empty string.
- *
- * @return the text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget();
- return text;
-}
-
-boolean hasBorder () {
- return false;
-}
-
-boolean isTabGroup () {
- return true;
-}
-
-boolean isTabItem () {
- return false;
-}
-
-Decorations menuShell () {
- return this;
-}
-
-void releaseChildren (boolean destroy) {
- if (menuBar != null) {
- menuBar.release (false);
- menuBar = null;
- }
- super.releaseChildren (destroy);
- if (menus != null) {
- for (int i=0; i<menus.length; i++) {
- Menu menu = menus [i];
- if (menu != null && !menu.isDisposed ()) {
- menu.release (false);
- }
- }
- menus = null;
- }
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- image = null;
- images = null;
- 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, false);
-}
-
-/**
- * If the argument is not null, sets the receiver's default
- * button to the argument, and if the argument is null, sets
- * the receiver's default button to the first button which
- * was set as the receiver's default button (called the
- * <em>saved default button</em>). If no default button had
- * previously been set, or the saved default button was
- * disposed, the receiver's default button will be set to
- * null.
- * <p>
- * The default button is the button that is selected when
- * the receiver is active and the user presses ENTER.
- * </p>
- *
- * @param button the new default button
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDefaultButton (Button button) {
- checkWidget();
- if (button != null) {
- if (button.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (button.menuShell () != this) error (SWT.ERROR_INVALID_PARENT);
- }
- setDefaultButton (button, true);
-}
-void setDefaultButton (Button button, boolean save) {
- if (button == null) {
- if (defaultButton == saveDefault) {
- if (save) saveDefault = null;
- return;
- }
- } else {
- 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
- * manager when the instance is marked as iconified, and
- * may also be displayed somewhere in the trim when the
- * instance is in normal or maximized states.
- *
- * @param image the new image (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- this.image = image;
-}
-
-/**
- * Sets the receiver's images to the argument, which may
- * be an empty array. Images are typically displayed by the
- * window manager when the instance is marked as iconified,
- * and may also be displayed somewhere in the trim when the
- * instance is in normal or maximized states. Depending where
- * the icon is displayed, the platform chooses the icon with
- * the "best" attributes. It is expected that the array will
- * contain the same icon rendered at different sizes, with
- * different depth and transparency attributes.
- *
- * @param images the new image array
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the images is null or has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- */
-public void setImages (Image [] images) {
- checkWidget();
- if (images == null) error(SWT.ERROR_INVALID_ARGUMENT);
- for (int i = 0; i < images.length; i++) {
- if (images [i] == null || images [i].isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- }
- this.images = images;
-}
-
-/**
- * Sets the maximized state of the receiver.
- * If the argument is <code>true</code> causes the receiver
- * to switch to the maximized state, and if the argument is
- * <code>false</code> and the receiver was previously maximized,
- * causes the receiver to switch back to either the minimized
- * or normal states.
- * <p>
- * Note: The result of intermixing calls to <code>setMaximized(true)</code>
- * and <code>setMinimized(true)</code> will vary by platform. Typically,
- * the behavior will match the platform user's expectations, but not
- * always. This should be avoided if possible.
- * </p>
- *
- * @param maximized the new maximized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMinimized
- */
-public void setMaximized (boolean maximized) {
- checkWidget();
-}
-
-/**
- * Sets the receiver's menu bar to the argument, which
- * may be null.
- *
- * @param menu the new menu bar
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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
- * to switch to the minimized state, and if the argument is
- * <code>false</code> and the receiver was previously minimized,
- * causes the receiver to switch back to either the maximized
- * or normal states.
- * <p>
- * Note: The result of intermixing calls to <code>setMaximized(true)</code>
- * and <code>setMinimized(true)</code> will vary by platform. Typically,
- * the behavior will match the platform user's expectations, but not
- * always. This should be avoided if possible.
- * </p>
- *
- * @param minimized the new maximized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMaximized
- */
-public void setMinimized (boolean minimized) {
- checkWidget();
-}
-
-/**
- * Sets the receiver's text, which is the string that the
- * window manager will typically display as the receiver's
- * <em>title</em>, to the argument, which must not be null.
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (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
deleted file mode 100755
index 4b48d8b5ce..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#directorydialog">DirectoryDialog snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class DirectoryDialog extends Dialog {
- String message = "", filterPath = "";
-
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a shell which will be the parent of the new instance
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public DirectoryDialog (Shell parent) {
- this (parent, SWT.APPLICATION_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of dialog to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public DirectoryDialog (Shell parent, int style) {
- super (parent, checkStyle (parent, style));
- checkSubclass ();
-}
-
-/**
- * Returns the path which the dialog will use to filter
- * the directories it shows.
- *
- * @return the filter path
- *
- * @see #setFilterPath
- */
-public String getFilterPath () {
- return filterPath;
-}
-
-/**
- * Returns the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @return the message
- */
-public String getMessage () {
- return message;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the selected directory,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-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 filterPath = new String (Converter.mbcsToWcs (null, path));
-}
-
-/**
- * Sets the path that the dialog will use to filter
- * the directories it shows to the argument, which may
- * be null. If the string is null, then the operating
- * system's default filter path will be used.
- * <p>
- * Note that the path string is platform dependent.
- * For convenience, either '/' or '\' can be used
- * as a path separator.
- * </p>
- *
- * @param string the filter path
- */
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
-/**
- * Sets the dialog's message, which is a description of
- * the purpose for which it was opened. This message will be
- * visible on the dialog while it is open.
- *
- * @param string the message
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- */
-public void setMessage (String string) {
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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
deleted file mode 100755
index f94fb76b3c..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
+++ /dev/null
@@ -1,2737 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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
- * system. Their most important function is to implement
- * the SWT event loop in terms of the platform event model.
- * They also provide various methods for accessing information
- * about the operating system, and have overall control over
- * the operating system resources which SWT allocates.
- * <p>
- * Applications which are built with SWT will <em>almost always</em>
- * require only a single display. In particular, some platforms
- * which SWT supports will not allow more than one <em>active</em>
- * display. In other words, some platforms do not support
- * creating a new display if one already exists that has not been
- * sent the <code>dispose()</code> message.
- * <p>
- * In SWT, the thread which creates a <code>Display</code>
- * instance is distinguished as the <em>user-interface thread</em>
- * for that display.
- * </p>
- * The user-interface thread for a particular display has the
- * following special attributes:
- * <ul>
- * <li>
- * The event loop for that display must be run from the thread.
- * </li>
- * <li>
- * Some SWT API methods (notably, most of the public methods in
- * <code>Widget</code> and its subclasses), may only be called
- * from the thread. (To support multi-threaded user-interface
- * applications, class <code>Display</code> provides inter-thread
- * communication methods which allow threads other than the
- * user-interface thread to request that it perform operations
- * on their behalf.)
- * </li>
- * <li>
- * The thread is not allowed to construct other
- * <code>Display</code>s until that display has been disposed.
- * (Note that, this is in addition to the restriction mentioned
- * above concerning platform support for multiple displays. Thus,
- * the only way to have multiple simultaneously active displays,
- * even on platforms which support it, is to have multiple threads.)
- * </li>
- * </ul>
- * Enforcing these attributes allows SWT to be implemented directly
- * on the underlying operating system's event model. This has
- * numerous benefits including smaller footprint, better use of
- * resources, safer memory management, clearer program logic,
- * better performance, and fewer overall operating system threads
- * required. The down side however, is that care must be taken
- * (only) when constructing multi-threaded applications to use the
- * inter-thread communication mechanisms which this class provides
- * when required.
- * </p><p>
- * All SWT API methods which may only be called from the user-interface
- * thread are distinguished in their documentation by indicating that
- * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
- * SWT exception.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Close, Dispose, Settings</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- * @see #syncExec
- * @see #asyncExec
- * @see #wake
- * @see #readAndDispatch
- * @see #sleep
- * @see Device#dispose
- * @see <a href="http://www.eclipse.org/swt/snippets/#display">Display snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Display extends Device {
-
- /* TEMPORARY CODE FOR EMULATED TABLE */
- int textHighlightThickness = 0;
-
- /* TEMPORARY CODE FOR EMBEDDED */
- 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;
-
- /* System Tray */
- Tray tray;
-
- /* Drag origin */
- int dragStartX, dragStartY;
-
- /* 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.Pk_????, SWT.COMMAND},
-// {OS.Pk_????, SWT.COMMAND},
-
-// {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_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},
- {OS.Pk_F13, SWT.F13},
- {OS.Pk_F14, SWT.F14},
- {OS.Pk_F15, SWT.F15},
-
- /* Numeric Keypad Keys */
- {OS.Pk_KP_Multiply, SWT.KEYPAD_MULTIPLY},
- {OS.Pk_KP_Add, SWT.KEYPAD_ADD},
- {OS.Pk_KP_Enter, SWT.KEYPAD_CR},
- {OS.Pk_KP_Subtract, SWT.KEYPAD_SUBTRACT},
- {OS.Pk_KP_Decimal, SWT.KEYPAD_DECIMAL},
- {OS.Pk_KP_Divide, SWT.KEYPAD_DIVIDE},
- {OS.Pk_KP_0, SWT.KEYPAD_0},
- {OS.Pk_KP_1, SWT.KEYPAD_1},
- {OS.Pk_KP_2, SWT.KEYPAD_2},
- {OS.Pk_KP_3, SWT.KEYPAD_3},
- {OS.Pk_KP_4, SWT.KEYPAD_4},
- {OS.Pk_KP_5, SWT.KEYPAD_5},
- {OS.Pk_KP_6, SWT.KEYPAD_6},
- {OS.Pk_KP_7, SWT.KEYPAD_7},
- {OS.Pk_KP_8, SWT.KEYPAD_8},
- {OS.Pk_KP_9, SWT.KEYPAD_9},
- {OS.Pk_KP_Equal, SWT.KEYPAD_EQUAL},
-
- /* Other keys */
- {OS.Pk_Caps_Lock, SWT.CAPS_LOCK},
- {OS.Pk_Num_Lock, SWT.NUM_LOCK},
- {OS.Pk_Scroll_Lock, SWT.SCROLL_LOCK},
- {OS.Pk_Pause, SWT.PAUSE},
- {OS.Pk_Break, SWT.BREAK},
- {OS.Pk_Print, SWT.PRINT_SCREEN},
- {OS.Pk_Help, SWT.HELP},
-
- };
-
- /* Multiple Displays. */
- static Display Default;
- static Display [] Displays = new Display [4];
-
- /* Window Classes */
- int ClassesPtr;
- int PtButton;
- int PtList;
- int PtLabel;
- int PtToggleButton;
- int PtComboBox;
- int PtText;
- int PtMultiText;
- int PtScrollbar;
- int PtContainer;
- int PtProgress;
- int PtPanelGroup;
- int PtSlider;
- int PtSeparator;
- int PtToolbar;
- int PtNumericInteger;
-
- /* 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;
-
- /* System Cursors */
- Cursor [] cursors = new Cursor [SWT.CURSOR_HAND + 1];
-
- /* 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>
- * Note: The resulting display is marked as the <em>current</em>
- * display. If this is the first display which has been
- * constructed since the application started, it is also
- * marked as the <em>default</em> display.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if called from a thread that already created an existing display</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see #getCurrent
- * @see #getDefault
- * @see Widget#checkSubclass
- * @see Shell
- */
-public Display () {
- this (null);
-}
-
-/**
- * Constructs a new instance of this class using the parameter.
- *
- * @param data the device data
- */
-public Display (DeviceData data) {
- super (data);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when an event of the given type occurs anywhere
- * in a widget. The event type is one of the event constants
- * defined in class <code>SWT</code>. When the event does occur,
- * the listener is notified by sending it the <code>handleEvent()</code>
- * message.
- * <p>
- * Setting the type of an event to <code>SWT.None</code> from
- * within the <code>handleEvent()</code> method can be used to
- * change the event type and stop subsequent Java listeners
- * from running. Because event filters run before other listeners,
- * event filters can both block other listeners and set arbitrary
- * fields within an event. For this reason, event filters are both
- * powerful and dangerous. They should generally be avoided for
- * performance, debugging and code maintenance reasons.
- * </p>
- *
- * @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>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #removeFilter
- * @see #removeListener
- *
- * @since 3.0
- */
-public 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 notified when an event of the given type occurs. The event
- * type is one of the event constants defined in class <code>SWT</code>.
- * 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>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @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);
-}
-
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The caller of this method continues
- * to run in parallel, and is not notified when the
- * runnable has completed. Specifying <code>null</code> as the
- * runnable simply wakes the user-interface thread when run.
- * <p>
- * Note that at the time the runnable is invoked, widgets
- * that have the receiver as their display may have been
- * disposed. Therefore, it is necessary to check for this
- * case inside the runnable before accessing the widget.
- * </p>
- *
- * @param runnable code to run on the user-interface thread or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #syncExec
- */
-public void asyncExec (Runnable runnable) {
- synchronized (Device.class) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.asyncExec (runnable);
- }
-}
-
-/**
- * Causes the system hardware to emit a short sound
- * (if it supports this capability).
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public void beep () {
- checkDevice ();
- OS.PtBeep ();
-}
-
-protected void checkDevice () {
- if (thread == null) error (SWT.ERROR_WIDGET_DISPOSED);
- if (thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
-}
-
-static void checkDisplay (Thread thread, boolean multiple) {
- synchronized (Device.class) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] != null) {
- if (!multiple) SWT.error (SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]");
- if (Displays [i].thread == thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- }
- }
-}
-
-/**
- * Checks that this class can be subclassed.
- * <p>
- * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Widget#checkSubclass
- */
-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>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Device#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 ();
-}
-
-/**
- * Creates the device in the operating system. If the device
- * does not have a handle, this method may do nothing depending
- * on the device.
- * <p>
- * This method is called before <code>init</code>.
- * </p>
- *
- * @param data the DeviceData which describes the receiver
- *
- * @see #init
- */
-protected void create (DeviceData data) {
- checkSubclass ();
- checkDisplay (thread = Thread.currentThread (), false);
- createDisplay (data);
- register (this);
- if (Default == null) Default = this;
-}
-
-void createDisplay (DeviceData data) {
- OS.PtInit (null);
- OS.PgSetDrawBufferSize (DrawBufferSize);
- app_context = OS.PtCreateAppContext ();
-}
-
-static void deregister (Display display) {
- synchronized (Device.class) {
- for (int i=0; i<Displays.length; i++) {
- if (display == Displays [i]) Displays [i] = null;
- }
- }
-}
-
-/**
- * Destroys the device in the operating system and releases
- * the device's handle. If the device does not have a handle,
- * this method may do nothing depending on the device.
- * <p>
- * This method is called after <code>release</code>.
- * </p>
- * @see Device#dispose
- * @see #release
- */
-protected void destroy () {
- if (this == Default) Default = null;
- deregister (this);
- 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
- * receiver is disposed. Specifying a <code>null</code> runnable
- * is ignored.
- *
- * @param runnable code to run at dispose time.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-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
- * is not a user-interface thread for any display. Specifying
- * <code>null</code> as the thread will return <code>null</code>
- * for the display.
- *
- * @param thread the user-interface thread
- * @return the display for the given thread
- */
-public static Display findDisplay (Thread thread) {
- synchronized (Device.class) {
- 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
- * represents it in the currently running application, if
- * such exists, or null if no matching widget can be found.
- * <p>
- * <b>IMPORTANT:</b> This method should not be called from
- * application code. The arguments are platform-specific.
- * </p>
- *
- * @param handle the handle for the widget
- * @return the SWT widget that the handle represents
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Widget findWidget (int handle) {
- checkDevice ();
- return WidgetTable.get (handle);
-}
-
-/**
- * Given the operating system handle for a widget,
- * and widget-specific id, returns the instance of
- * the <code>Widget</code> subclass which represents
- * the handle/id pair in the currently running application,
- * if such exists, or null if no matching widget can be found.
- * <p>
- * <b>IMPORTANT:</b> This method should not be called from
- * application code. The arguments are platform-specific.
- * </p>
- *
- * @param handle the handle for the widget
- * @param id the id for the subwidget (usually an item)
- * @return the SWT widget that the handle/id pair represents
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.1
- */
-public Widget findWidget (int handle, int id) {
- checkDevice ();
- return null;
-}
-
-/**
- * Given a widget and a widget-specific id, returns the
- * instance of the <code>Widget</code> subclass which represents
- * the widget/id pair in the currently running application,
- * if such exists, or null if no matching widget can be found.
- *
- * @param widget the widget
- * @param id the id for the subwidget (usually an item)
- * @return the SWT subwidget (usually an item) that the widget/id pair represents
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.3
- */
-public Widget findWidget (Widget widget, int id) {
- checkDevice ();
- return null;
-}
-
-/**
- * Returns the currently active <code>Shell</code>, or null
- * if no shell belonging to the currently running application
- * is active.
- *
- * @return the active shell or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</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;
-}
-
-/**
- * Returns the control which the on-screen pointer is currently
- * over top of, or null if it is not currently over one of the
- * controls built by the currently running application.
- *
- * @return the control under the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</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;
-}
-
-/**
- * Returns an array containing the recommended cursor sizes.
- *
- * @return the array of cursor sizes
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public Point [] getCursorSizes () {
- checkDevice ();
- return new Point [] {new Point (16, 16), new Point (32, 32)};
-}
-
-/**
- * Returns the location of the on-screen pointer relative
- * to the top left corner of the screen.
- *
- * @return the cursor location
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</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);
-}
-
-/**
- * Returns the display which the currently running thread is
- * the user-interface thread for, or null if the currently
- * running thread is not a user-interface thread for any display.
- *
- * @return the current display
- */
-public static Display getCurrent () {
- return findDisplay (Thread.currentThread ());
-}
-
-/**
- * Returns the default display. One is created (making the
- * thread that invokes this method its user-interface thread)
- * if it did not already exist.
- *
- * @return the default display
- */
-public static Display getDefault () {
- synchronized (Device.class) {
- 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
- * to set the name used for resource lookup. Specifying
- * <code>null</code> for the name clears it.
- *
- * @param name the new app name or <code>null</code>
- */
-public static void setAppName (String name) {
- /* Do nothing */
-}
-
-/**
- * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>.
- * The button dismissal alignment is the ordering that should be used when positioning the
- * default dismissal button for a dialog. For example, in a dialog that contains an OK and
- * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the
- * button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>,
- * the button ordering should be CANCEL/OK.
- *
- * @return the button dismissal order
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1
- */
-public int getDismissalAlignment () {
- checkDevice ();
- return SWT.RIGHT;
-}
-
-/**
- * Returns the longest duration, in milliseconds, between
- * two mouse button clicks that will be considered a
- * <em>double click</em> by the underlying operating system.
- *
- * @return the double click time
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-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
- * any of the controls built by the currently running
- * application.
- *
- * @return the control under the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</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 ();
-}
-
-/**
- * Returns true when the high contrast mode is enabled.
- * Otherwise, false is returned.
- * <p>
- * Note: This operation is a hint and is not supported on
- * platforms that do not have this concept.
- * </p>
- *
- * @return the high contrast mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public boolean getHighContrast () {
- checkDevice ();
- return false;
-}
-
-/**
- * Returns the maximum allowed depth of icons on this display, in bits per pixel.
- * On some platforms, this may be different than the actual depth of the display.
- *
- * @return the maximum icon depth
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Device#getDepth
- */
-public int getIconDepth () {
- return getDepth ();
-}
-
-/**
- * Returns an array containing the recommended icon sizes.
- *
- * @return the array of icon sizes
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Decorations#setImages(Image[])
- *
- * @since 3.0
- */
-public Point [] getIconSizes () {
- checkDevice ();
- return new Point [] {new Point (15, 15), new Point (43, 43)};
-}
-
-int getMessageCount () {
- return synchronizer.getMessageCount ();
-}
-
-/**
- * Returns an array of monitors attached to the device.
- *
- * @return the array of monitors
- *
- * @since 3.0
- */
-public Monitor [] getMonitors () {
- checkDevice ();
- int cnt = OS.PhQueryRids (0, 0, 0, OS.Ph_GRAFX_REGION, 0, 0, null, null, 0);
- int [] rids = new int [cnt];
- cnt = OS.PhQueryRids (0, 0, 0, OS.Ph_GRAFX_REGION, 0, 0, null, rids, rids.length);
- PhRect_t rect = new PhRect_t ();
- Monitor [] monitors = new Monitor [cnt];
- for (int i = 0; i < cnt; i++) {
- Monitor monitor = new Monitor ();
- monitor.handle = rids [i];
- OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, rids [i], OS.PhInputGroup (0), rect);
- monitor.x = rect.ul_x;
- monitor.y = rect.ul_y;
- monitor.width = rect.lr_x - rect.ul_x + 1;
- monitor.height = rect.lr_y - rect.ul_y + 1;
- OS.PhWindowQueryVisible (OS.Ph_QUERY_WORKSPACE, rids [i], OS.PhInputGroup (0), rect);
- monitor.clientX = rect.ul_x;
- monitor.clientY = rect.ul_y;
- monitor.clientWidth = rect.lr_x - rect.ul_x + 1;
- monitor.clientHeight = rect.lr_y - rect.ul_y + 1;
- monitors [i] = monitor;
- }
- return monitors;
-}
-
-/**
- * Returns the primary monitor for that device.
- *
- * @return the primary monitor
- *
- * @since 3.0
- */
-public Monitor getPrimaryMonitor () {
- checkDevice ();
- /*
- * Note. Photon does not define a primary monitor.
- * The workaround is to arbitrarily return the first
- * monitor whose coordinates are (0, 0), or the first
- * monitor returned by getMonitors().
- */
- Monitor [] monitors = getMonitors ();
- if (monitors.length == 1) return monitors [0];
- for (int i = 0; i < monitors.length; i++) {
- Monitor monitor = monitors [i];
- if (monitor.x == 0 && monitor.y == 0) return monitor;
- }
- return monitors [0];
-}
-
-/**
- * Returns a (possibly empty) array containing all shells which have
- * not been disposed and have the receiver as their display.
- *
- * @return the receiver's shells
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</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.display) {
- 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.display) {
- result [index++] = shell;
- }
- }
- return result;
-}
-
-/**
- * Returns the matching standard color for the given
- * constant, which should be one of the color constants
- * specified in class <code>SWT</code>. Any value other
- * than one of the SWT color constants which is passed
- * in will result in the color black. This color should
- * not be free'd because it was allocated by the system,
- * not the application.
- *
- * @param id the color constant
- * @return the matching color
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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);
-}
-
-/**
- * Returns the matching standard platform cursor for the given
- * constant, which should be one of the cursor constants
- * specified in class <code>SWT</code>. This cursor should
- * not be free'd because it was allocated by the system,
- * not the application. A value of <code>null</code> will
- * be returned if the supplied constant is not an SWT cursor
- * constant.
- *
- * @param id the SWT cursor constant
- * @return the corresponding cursor or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see SWT#CURSOR_ARROW
- * @see SWT#CURSOR_WAIT
- * @see SWT#CURSOR_CROSS
- * @see SWT#CURSOR_APPSTARTING
- * @see SWT#CURSOR_HELP
- * @see SWT#CURSOR_SIZEALL
- * @see SWT#CURSOR_SIZENESW
- * @see SWT#CURSOR_SIZENS
- * @see SWT#CURSOR_SIZENWSE
- * @see SWT#CURSOR_SIZEWE
- * @see SWT#CURSOR_SIZEN
- * @see SWT#CURSOR_SIZES
- * @see SWT#CURSOR_SIZEE
- * @see SWT#CURSOR_SIZEW
- * @see SWT#CURSOR_SIZENE
- * @see SWT#CURSOR_SIZESE
- * @see SWT#CURSOR_SIZESW
- * @see SWT#CURSOR_SIZENW
- * @see SWT#CURSOR_UPARROW
- * @see SWT#CURSOR_IBEAM
- * @see SWT#CURSOR_NO
- * @see SWT#CURSOR_HAND
- *
- * @since 3.0
- */
-public Cursor getSystemCursor (int id) {
- checkDevice ();
- if (!(0 <= id && id < cursors.length)) return null;
- if (cursors [id] == null) {
- cursors [id] = new Cursor (this, id);
- }
- return cursors [id];
-}
-
-/**
- * Returns a reasonable font for applications to use.
- * On some platforms, this will match the "default font"
- * or "system font" if such can be found. This font
- * should not be free'd because it was allocated by the
- * system, not the application.
- * <p>
- * Typically, applications which want the default look
- * should simply not set the font on the widgets they
- * create. Widgets are always created with the correct
- * default font for the class of user-interface component
- * they represent.
- * </p>
- *
- * @return a font
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Font getSystemFont () {
- checkDevice ();
- byte [] font = defaultFont != null ? defaultFont : TEXT_FONT;
- return Font.photon_new (this, font);
-}
-
-/**
- * Returns the matching standard platform image for the given
- * constant, which should be one of the icon constants
- * specified in class <code>SWT</code>. This image should
- * not be free'd because it was allocated by the system,
- * not the application. A value of <code>null</code> will
- * be returned either if the supplied constant is not an
- * SWT icon constant or if the platform does not define an
- * image that corresponds to the constant.
- *
- * @param id the SWT icon constant
- * @return the corresponding image or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see SWT#ICON_ERROR
- * @see SWT#ICON_INFORMATION
- * @see SWT#ICON_QUESTION
- * @see SWT#ICON_WARNING
- * @see SWT#ICON_WORKING
- *
- * @since 3.0
- */
-public Image getSystemImage (int id) {
- checkDevice ();
- return null;
-}
-
-/**
- * Returns the single instance of the system tray or null
- * when there is no system tray available for the platform.
- *
- * @return the system tray or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- */
-public Tray getSystemTray () {
- checkDevice ();
- return null;
-}
-
-/**
- * Gets the synchronizer used by the display.
- *
- * @return the receiver's synchronizer
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.4
- */
-public Synchronizer getSynchronizer () {
- checkDevice ();
- return synchronizer;
-}
-
-/**
- * Returns the thread that has invoked <code>syncExec</code>
- * or null if no such runnable is currently being invoked by
- * the user-interface thread.
- * <p>
- * Note: If a runnable invoked by asyncExec is currently
- * running, this method will return null.
- * </p>
- *
- * @return the receiver's sync-interface thread
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Thread getSyncThread () {
- synchronized (Device.class) {
- 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
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Thread getThread () {
- synchronized (Device.class) {
- 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);
-}
-
-/**
- * Initializes any internal resources needed by the
- * device.
- * <p>
- * This method is called after <code>create</code>.
- * </p>
- *
- * @see #create
- */
-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,
- OS.PtCreateWidgetClass (OS.PtNumericInteger (), 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;
- PtNumericInteger = ClassesPtr + 216;
-}
-
-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 ();
- if (runAsyncMessages (false)) wakeThread ();
- }
- return OS.Pt_CONTINUE;
-}
-
-/**
- * Invokes platform specific functionality to allocate a new GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Display</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
- * </ul>
- */
-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);
- int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
- if ((data.style & mask) == 0) {
- data.style |= SWT.LEFT_TO_RIGHT;
- }
-
- data.device = this;
- data.rid = OS.Ph_DEV_RID;
- return phGC;
-}
-
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Display</code>. It is marked public only so that it
- * can be shared within the packages provided by SWT. It is not
- * available on all platforms, and should never be called from
- * application code.
- * </p>
- *
- * @param hDC the platform specific GC handle
- * @param data the platform specific GC data
- */
-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.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility to provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @return the value of the property or null if it has not been set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #setData(String, Object)
- * @see #disposeExec(Runnable)
- */
-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
- * set. The <em>display specific data</em> is a single,
- * unnamed field that is stored with every display.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the display specific data needs to
- * be notified when the display is disposed of, it is the
- * application's responsibility to provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @return the display specific data
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #setData(Object)
- * @see #disposeExec(Runnable)
- */
-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);
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param point to be mapped
- * @return point with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Point map (Control from, Control to, Point point) {
- checkDevice ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, point.x, point.y);
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param x coordinates to be mapped
- * @param y coordinates to be mapped
- * @return point with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Point map (Control from, Control to, int x, int y) {
- checkDevice ();
- if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- Point point = new Point (x, y);
- if (from == to) return point;
- if (from != null) {
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (from.handle, position_x, position_y);
- point.x += position_x [0];
- point.y += position_y [0];
- }
- if (to != null) {
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (to.handle, position_x, position_y);
- point.x -= position_x [0];
- point.y -= position_y [0];
- }
- return point;
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param rectangle to be mapped
- * @return rectangle with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Rectangle map (Control from, Control to, Rectangle rectangle) {
- checkDevice ();
- if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);
- return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
-}
-
-/**
- * Maps a point from one coordinate system to another.
- * When the control is null, coordinates are mapped to
- * the display.
- * <p>
- * NOTE: On right-to-left platforms where the coordinate
- * systems are mirrored, special care needs to be taken
- * when mapping coordinates from one control to another
- * to ensure the result is correctly mirrored.
- *
- * Mapping a point that is the origin of a rectangle and
- * then adding the width and height is not equivalent to
- * mapping the rectangle. When one control is mirrored
- * and the other is not, adding the width and height to a
- * point that was mapped causes the rectangle to extend
- * in the wrong direction. Mapping the entire rectangle
- * instead of just one point causes both the origin and
- * the corner of the rectangle to be mapped.
- * </p>
- *
- * @param from the source <code>Control</code> or <code>null</code>
- * @param to the destination <code>Control</code> or <code>null</code>
- * @param x coordinates to be mapped
- * @param y coordinates to be mapped
- * @param width coordinates to be mapped
- * @param height coordinates to be mapped
- * @return rectangle with mapped coordinates
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1.2
- */
-public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
- checkDevice ();
- if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- Rectangle rect = new Rectangle (x, y, width, height);
- if (from == to) return rect;
- if (from != null) {
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (from.handle, position_x, position_y);
- rect.x += position_x [0];
- rect.y += position_y [0];
- }
- if (to != null) {
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (to.handle, position_x, position_y);
- rect.x -= position_x [0];
- rect.y -= position_y [0];
- }
- return rect;
-}
-
-/**
- * Generate a low level system event.
- *
- * <code>post</code> is used to generate low level keyboard
- * and mouse events. The intent is to enable automated UI
- * testing by simulating the input from the user. Most
- * SWT applications should never need to call this method.
- * <p>
- * Note that this operation can fail when the operating system
- * fails to generate the event for any reason. For example,
- * this can happen when there is no such key or mouse button
- * or when the system event queue is full.
- * </p>
- * <p>
- * <b>Event Types:</b>
- * <p>KeyDown, KeyUp
- * <p>The following fields in the <code>Event</code> apply:
- * <ul>
- * <li>(in) type KeyDown or KeyUp</li>
- * <p> Either one of:
- * <li>(in) character a character that corresponds to a keyboard key</li>
- * <li>(in) keyCode the key code of the key that was typed,
- * as defined by the key code constants in class <code>SWT</code></li>
- * </ul>
- * <p>MouseDown, MouseUp</p>
- * <p>The following fields in the <code>Event</code> apply:
- * <ul>
- * <li>(in) type MouseDown or MouseUp
- * <li>(in) button the button that is pressed or released
- * </ul>
- * <p>MouseMove</p>
- * <p>The following fields in the <code>Event</code> apply:
- * <ul>
- * <li>(in) type MouseMove
- * <li>(in) x the x coordinate to move the mouse pointer to in screen coordinates
- * <li>(in) y the y coordinate to move the mouse pointer to in screen coordinates
- * </ul>
- * <p>MouseWheel</p>
- * <p>The following fields in the <code>Event</code> apply:
- * <ul>
- * <li>(in) type MouseWheel
- * <li>(in) detail either SWT.SCROLL_LINE or SWT.SCROLL_PAGE
- * <li>(in) count the number of lines or pages to scroll
- * </ul>
- * </dl>
- *
- * @param event the event to be generated
- *
- * @return true if the event was generated or false otherwise
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the event is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 3.0
- *
- */
-public boolean post (Event event) {
- synchronized (Device.class) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- return false;
- }
-}
-
-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) wakeThread ();
-}
-
-/**
- * Reads an event from the operating system's event queue,
- * dispatches it appropriately, and returns <code>true</code>
- * if there is potentially more work to do, or <code>false</code>
- * if the caller can sleep until another event is placed on
- * the event queue.
- * <p>
- * In addition to checking the system event queue, this method also
- * checks if any inter-thread messages (created by <code>syncExec()</code>
- * or <code>asyncExec()</code>) are waiting to be processed, and if
- * so handles them before returning.
- * </p>
- *
- * @return <code>false</code> if the caller can sleep upon return from this method
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
- * </ul>
- *
- * @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 (false);
- } else {
- runDeferredEvents ();
- }
- OS.PtRelease ();
- OS.PtHold ();
- return isDisposed () || result;
-}
-
-static void register (Display display) {
- synchronized (Device.class) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] == null) {
- Displays [i] = display;
- return;
- }
- }
- Display [] newDisplays = new Display [Displays.length + 4];
- System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
- newDisplays [Displays.length] = display;
- Displays = newDisplays;
- }
-}
-
-/**
- * Releases any internal resources back to the operating
- * system and clears all fields except the device handle.
- * <p>
- * Disposes all shells which are currently open on the display.
- * After this method has been invoked, all related related shells
- * will answer <code>true</code> when sent the message
- * <code>isDisposed()</code>.
- * </p><p>
- * When a device is destroyed, resources that were acquired
- * on behalf of the programmer need to be returned to the
- * operating system. For example, if the device allocated a
- * font to be used as the system font, this font would be
- * freed in <code>release</code>. Also,to assist the garbage
- * collector and minimize the amount of memory that is not
- * reclaimed when the programmer keeps a reference to a
- * disposed device, all fields except the handle are zero'd.
- * The handle is needed by <code>destroy</code>.
- * </p>
- * This method is called before <code>destroy</code>.
- *
- * @see Device#dispose
- * @see #destroy
- */
-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.display) shell.dispose ();
- }
- }
- if (tray != null) tray.dispose ();
- tray = null;
- 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 = (byte)OS.Ph_RELEASE_IMAGE_ALL;
- OS.memmove(nullImage, phImage, PhImage_t.sizeof);
- OS.PhReleaseImage(nullImage);
- OS.free(nullImage);
- nullImage = 0;
- }
-
- /* Release the System Cursors */
- for (int i = 0; i < cursors.length; i++) {
- if (cursors [i] != null) cursors [i].dispose ();
- }
- cursors = null;
-
- /* Release references */
- thread = null;
- data = null;
- keys = null;
- values = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when an event of the given type occurs anywhere in
- * a widget. The event type is one of the event constants defined
- * in class <code>SWT</code>.
- *
- * @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 SWT
- * @see #addFilter
- * @see #addListener
- *
- * @since 3.0
- */
-public 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 notified when an event of the given type occurs. The event type
- * is one of the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @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 (boolean all) {
- return synchronizer.runAsyncMessages (all);
-}
-
-boolean runDeferredEvents () {
- boolean run = false;
- /*
- * 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 ()) {
- run = true;
- 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 run;
-}
-
-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);
- }
-}
-
-/**
- * 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 x the new x coordinate for the cursor
- * @param y the new y coordinate for the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.1
- */
-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
- *
- * @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
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @since 2.0
- */
-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.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #getData(String)
- * @see #disposeExec(Runnable)
- */
-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.
- * The <em>display specific data</em> is a single,
- * unnamed field that is stored with every display.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the display specific data needs to
- * be notified when the display is disposed of, it is the
- * application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param data the new display specific data
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #getData()
- * @see #disposeExec(Runnable)
- */
-public void setData (Object data) {
- checkDevice ();
- this.data = data;
-}
-
-/**
- * Sets the synchronizer used by the display to be
- * the argument, which can not be null.
- *
- * @param synchronizer the new synchronizer for the display (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
- * </ul>
- */
-public void setSynchronizer (Synchronizer synchronizer) {
- checkDevice ();
- if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (synchronizer == this.synchronizer) return;
- Synchronizer oldSynchronizer;
- synchronized (Device.class) {
- oldSynchronizer = this.synchronizer;
- this.synchronizer = synchronizer;
- }
- if (oldSynchronizer != null) {
- oldSynchronizer.runAsyncMessages(true);
- }
-}
-
-/**
- * Causes the user-interface thread to <em>sleep</em> (that is,
- * to be put in a state where it does not consume CPU cycles)
- * until an event is received or it is otherwise awakened.
- *
- * @return <code>true</code> if an event requiring dispatching was placed on the queue.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #wake
- */
-public boolean sleep () {
- checkDevice ();
- if (getMessageCount () != 0) return true;
- OS.PtFlush ();
- 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
- * reasonable opportunity. The thread which calls this method
- * is suspended until the runnable completes. Specifying <code>null</code>
- * as the runnable simply wakes the user-interface thread.
- * <p>
- * Note that at the time the runnable is invoked, widgets
- * that have the receiver as their display may have been
- * disposed. Therefore, it is necessary to check for this
- * case inside the runnable before accessing the widget.
- * </p>
- *
- * @param runnable code to run on the user-interface thread or <code>null</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #asyncExec
- */
-public void syncExec (Runnable runnable) {
- Synchronizer synchronizer;
- synchronized (Device.class) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer = this.synchronizer;
- }
- 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
- * number of milliseconds have elapsed. If milliseconds is less
- * than zero, the runnable is not executed.
- * <p>
- * Note that at the time the runnable is invoked, widgets
- * that have the receiver as their display may have been
- * disposed. Therefore, it is necessary to check for this
- * case inside the runnable before accessing the widget.
- * </p>
- *
- * @param milliseconds the delay before running the runnable
- * @param runnable code to run on the user-interface thread
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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;
-}
-
-/**
- * Forces all outstanding paint requests for the display
- * to be processed before this method returns.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @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.display) {
- 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
- * method may be called from any thread.
- *
- * @exception SWTException <ul>
- * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #sleep
- */
-public void wake () {
- synchronized (Device.class) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- if (thread == Thread.currentThread ()) return;
- wakeThread ();
- }
-}
-
-void wakeThread () {
-// 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
deleted file mode 100755
index 09559bb192..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SAVE, OPEN, MULTI</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles SAVE and OPEN may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#filedialog">FileDialog snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class FileDialog extends Dialog {
- String [] filterNames = new String [0];
- String [] filterExtensions = new String [0];
- String filterPath = "", fileName = "";
- int filterIndex = -1;
- boolean overwrite = false;
- static final String FILTER = "*";
-
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a shell which will be the parent of the new instance
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public FileDialog (Shell parent) {
- this (parent, SWT.APPLICATION_MODAL);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of dialog to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SAVE
- * @see SWT#OPEN
- * @see SWT#MULTI
- */
-public FileDialog (Shell parent, int style) {
- super (parent, checkStyle (parent, style));
- checkSubclass ();
-}
-
-/**
- * Returns the path of the first file that was
- * selected in the dialog relative to the filter path, or an
- * empty string if no such file has been selected.
- *
- * @return the relative path of the file
- */
-public String getFileName () {
- return fileName;
-}
-
-/**
- * Returns a (possibly empty) array with the paths of all files
- * that were selected in the dialog relative to the filter path.
- *
- * @return the relative paths of the files
- */
-public String [] getFileNames () {
- if (fileName.length () == 0) return new String [0];
- 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;
-}
-
-/**
- * Get the 0-based index of the file extension filter
- * which was selected by the user, or -1 if no filter
- * was selected.
- * <p>
- * This is an index into the FilterExtensions array and
- * the FilterNames array.
- * </p>
- *
- * @return index the file extension filter index
- *
- * @see #getFilterExtensions
- * @see #getFilterNames
- *
- * @since 3.4
- */
-public int getFilterIndex () {
- return filterIndex;
-}
-
-/**
- * Returns the names that describe the filter extensions
- * which the dialog will use to filter the files it shows.
- *
- * @return the list of filter names
- */
-public String [] getFilterNames () {
- return filterNames;
-}
-
-/**
- * Returns the directory path that the dialog will use, or an empty
- * string if this is not set. File names in this path will appear
- * in the dialog, filtered according to the filter extensions.
- *
- * @return the directory path string
- *
- * @see #setFilterExtensions
- */
-public String getFilterPath () {
- return filterPath;
-}
-
-/**
- * Returns the flag that the dialog will use to
- * determine whether to prompt the user for file
- * overwrite if the selected file already exists.
- *
- * @return true if the dialog will prompt for file overwrite, false otherwise
- *
- * @since 3.4
- */
-public boolean getOverwrite () {
- return overwrite;
-}
-
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a string describing the absolute path of the first selected file,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public String open () {
- int 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);
- filterIndex = filterExtensions == null || filterExtensions.length == 0 ? -1 : 0;
- }
- return fullPath;
-}
-
-/**
- * Set the initial filename which the dialog will
- * select by default when opened to the argument,
- * which may be null. The name will be prefixed with
- * the filter path when one is supplied.
- *
- * @param string the file name
- */
-public void setFileName (String string) {
- fileName = string;
-}
-
-/**
- * Set the file extensions which the dialog will
- * use to filter the files it shows to the argument,
- * which may be null.
- * <p>
- * The strings are platform specific. For example, on
- * some platforms, an extension filter string is typically
- * of the form "*.extension", where "*.*" matches all files.
- * For filters with multiple extensions, use semicolon as
- * a separator, e.g. "*.jpg;*.png".
- * </p>
- *
- * @param extensions the file extension filter
- *
- * @see #setFilterNames to specify the user-friendly
- * names corresponding to the extensions
- */
-public void setFilterExtensions (String [] extensions) {
- filterExtensions = extensions;
-}
-
-/**
- * Set the 0-based index of the file extension filter
- * which the dialog will use initially to filter the files
- * it shows to the argument.
- * <p>
- * This is an index into the FilterExtensions array and
- * the FilterNames array.
- * </p>
- *
- * @param index the file extension filter index
- *
- * @see #setFilterExtensions
- * @see #setFilterNames
- *
- * @since 3.4
- */
-public void setFilterIndex (int index) {
- filterIndex = index;
-}
-
-/**
- * Sets the names that describe the filter extensions
- * which the dialog will use to filter the files it shows
- * to the argument, which may be null.
- * <p>
- * Each name is a user-friendly short description shown for
- * its corresponding filter. The <code>names</code> array must
- * be the same length as the <code>extensions</code> array.
- * </p>
- *
- * @param names the list of filter names, or null for no filter names
- *
- * @see #setFilterExtensions
- */
-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
- * path will appear in the dialog, filtered according
- * to the filter extensions. If the string is null,
- * then the operating system's default filter path
- * will be used.
- * <p>
- * Note that the path string is platform dependent.
- * For convenience, either '/' or '\' can be used
- * as a path separator.
- * </p>
- *
- * @param string the directory path
- *
- * @see #setFilterExtensions
- */
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
-/**
- * Sets the flag that the dialog will use to
- * determine whether to prompt the user for file
- * overwrite if the selected file already exists.
- *
- * @param overwrite true if the dialog will prompt for file overwrite, false otherwise
- *
- * @since 3.4
- */
-public void setOverwrite (boolean overwrite) {
- //this.overwrite = overwrite;
-}
-}
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
deleted file mode 100755
index cc914ff2c2..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class FontDialog extends Dialog {
- FontData fontData;
- RGB rgb;
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a shell which will be the parent of the new instance
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public FontDialog (Shell parent) {
- this (parent, SWT.APPLICATION_MODAL);
-}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of dialog to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public FontDialog (Shell parent, int style) {
- super (parent, checkStyle (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
- * @deprecated use #getFontList ()
- */
-public FontData getFontData () {
- return fontData;
-}
-/**
- * Returns a FontData set describing the font that was
- * selected in the dialog, or null if none is available.
- *
- * @return the FontData for the selected font, or null
- * @since 2.1.1
- */
-public FontData [] getFontList () {
- if (fontData == null) return null;
- FontData [] result = new FontData [1];
- result [0] = fontData;
- return result;
-}
-/**
- * Returns an RGB describing the color that was selected
- * in the dialog, or null if none is available.
- *
- * @return the RGB value for the selected color, or null
- *
- * @see PaletteData#getRGBs
- *
- * @since 2.1
- */
-public RGB getRGB () {
- return rgb;
-}
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return a FontData object describing the font that was selected,
- * or null if the dialog was cancelled or an error occurred
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public FontData open () {
- 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();
- byte [] buffer = new byte[OS.MAX_FONT_TAG];
- if (OS.PfGenerateFontName(description, osStyle, size, buffer) != 0) font = buffer;
- }
- 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
- * the platform choose one.
- *
- * @param fontData the FontData to use initially, or null
- * @deprecated use #setFontList (FontData [])
- */
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-/**
- * Sets the set of FontData objects describing the font to
- * be selected by default in the dialog, or null to let
- * the platform choose one.
- *
- * @param fontData the set of FontData objects to use initially, or null
- * to let the platform select a default when open() is called
- *
- * @see Font#getFontData
- *
- * @since 2.1.1
- */
-public void setFontList (FontData [] fontData) {
- if (fontData != null && fontData.length > 0) {
- this.fontData = fontData [0];
- } else {
- this.fontData = null;
- }
-}
-/**
- * Sets the RGB describing the color to be selected by default
- * in the dialog, or null to let the platform choose one.
- *
- * @param rgb the RGB value to use initially, or null to let
- * the platform select a default when open() is called
- *
- * @see PaletteData#getRGBs
- *
- * @since 2.1
- */
-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
deleted file mode 100755
index 2abdc6a410..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <p>
- * Shadow styles are hints and may not be honoured
- * by the platform. To create a group with the
- * default shadow style for the platform, do not
- * specify a shadow style.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the above styles may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Group extends Composite {
- String text = "";
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SHADOW_ETCHED_IN
- * @see SWT#SHADOW_ETCHED_OUT
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @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) {
- changed |= (state & LAYOUT_CHANGED) != 0;
- size = layout.computeSize (this, wHint, hHint, changed);
- state &= ~LAYOUT_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;
- 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 () {
- 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
- * been set, returns an empty string.
- *
- * @return the text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget();
- return text;
-}
-
-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,
- * which may not be null. The string may include the mnemonic character.
- * </p>
- * Mnemonics are indicated by an '&amp;' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, focus is assigned
- * to the first child of the group. On most platforms, the
- * mnemonic appears underlined but may be emphasised in a
- * platform specific manner. The mnemonic indicator character
- * '&amp;' can be escaped by doubling it in the string, causing
- * a single '&amp;' to be displayed.
- * </p>
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- text = string;
- int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA;
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
- fixMnemonic (text);
- byte [] buffer = Converter.wcsToMbcs (null, text, 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
deleted file mode 100755
index e1b7191c87..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * When SEPARATOR is specified, displays a single
- * vertical or horizontal line.
- * <p>
- * Shadow styles are hints and may not be honored
- * by the platform. To create a separator label
- * with the default shadow style for the platform,
- * do not specify a shadow style.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd>
- * <dd>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
- * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of SHADOW_IN, SHADOW_OUT and SHADOW_NONE may be specified.
- * SHADOW_NONE is a HINT. Only one of HORIZONTAL and VERTICAL may be specified.
- * Only one of CENTER, LEFT and RIGHT may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#label">Label snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SEPARATOR
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @see SWT#CENTER
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#WRAP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Label (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style |= SWT.NO_FOCUS;
- if ((style & SWT.SEPARATOR) != 0) {
- style = checkBits (style, SWT.VERTICAL, SWT.HORIZONTAL, 0, 0, 0, 0);
- return checkBits (style, SWT.SHADOW_OUT, SWT.SHADOW_IN, SWT.SHADOW_NONE, 0, 0, 0);
- }
- 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) {
- 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;
- 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
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is a <code>SEPARATOR</code> label, in
- * which case, <code>NONE</code> is returned.
- *
- * @return the alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getAlignment () {
- checkWidget();
- if ((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.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget();
- return image;
-}
-
-String getNameText () {
- return getText ();
-}
-
-/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set or if the receiver is
- * a <code>SEPARATOR</code> label.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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>
- * or <code>CENTER</code>. If the receiver is a <code>SEPARATOR</code>
- * label, the argument is ignored and the alignment is not changed.
- *
- * @param alignment the new alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setAlignment (int alignment) {
- checkWidget();
- if ((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 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.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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>
- * This method sets the widget label. The label may include
- * the mnemonic character and line delimiters.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp;' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, focus is assigned
- * to the control that follows the label. On most platforms,
- * the mnemonic appears underlined but may be emphasised in a
- * platform specific manner. The mnemonic indicator character
- * '&amp;' can be escaped by doubling it in the string, causing
- * a single '&amp;' to be displayed.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- text = string;
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
- char mnemonic = fixMnemonic (text);
- /* 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;
- string = display.wrapText (new String (text), font, width);
- buffer = Converter.wcsToMbcs (null, string, true);
- } else {
- buffer = Converter.wcsToMbcs (null, text, true);
- }
- int ptr1 = OS.malloc (buffer.length);
- OS.memmove (ptr1, 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, ptr1, 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 (ptr1);
- OS.free (ptr2);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- return 0;
-}
-
-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/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Link.java
deleted file mode 100644
index 4864a59b91..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Link.java
+++ /dev/null
@@ -1,680 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-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 text with
- * links.
- * <p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#link">Link snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.1
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Link extends Control {
- String text;
- TextLayout layout;
- Color linkColor, disabledColor;
- Point [] offsets;
- Point selection;
- String [] ids;
- int [] mnemonics;
- int focusIndex;
-
- static final RGB LINK_FOREGROUND = new RGB (0, 51, 153);
- static final RGB LINK_DISABLED_FOREGROUND = new RGB (172, 168, 153);
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Link (Composite parent, int style) {
- super (parent, style);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is selected by the user, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the control is selected by the user.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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 ();
- if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
- if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
- int width, height;
- int layoutWidth = layout.getWidth ();
- //TEMPORARY CODE
- if (wHint == 0) {
- layout.setWidth (1);
- Rectangle rect = layout.getBounds ();
- width = 0;
- height = rect.height;
- } else {
- layout.setWidth (wHint);
- Rectangle rect = layout.getBounds ();
- width = rect.width;
- height = rect.height;
- }
- layout.setWidth (layoutWidth);
- if (wHint != SWT.DEFAULT) width = wHint;
- if (hHint != SWT.DEFAULT) height = hHint;
- int border = getBorderWidth ();
- width += border * 2;
- height += border * 2;
- return new Point (width, height);
-}
-
-void createHandle (int index) {
- SWT.error(SWT.ERROR_NOT_IMPLEMENTED);//tmp code
- state |= HANDLE;
- int clazz = display.PtContainer;
- int parentHandle = parent.parentingHandle ();
- int [] args = {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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);
-
- layout = new TextLayout (display);
- linkColor = new Color (display, LINK_FOREGROUND);
- disabledColor = new Color (display, LINK_DISABLED_FOREGROUND);
- offsets = new Point [0];
- ids = new String [0];
- mnemonics = new int [0];
- selection = new Point (-1, -1);
- focusIndex = -1;
-}
-
-void createWidget (int index) {
- super.createWidget (index);
- text = "";
- //TODO accessibility
-}
-
-void drawWidget(int widget, int damage) {
- //super.drawWidget(widget, damage);
- int selStart = selection.x;
- int selEnd = selection.y;
- if (selStart > selEnd) {
- selStart = selection.y;
- selEnd = selection.x;
- }
- // temporary code to disable text selection
- selStart = selEnd = -1;
- GCData data = new GCData();
- if (OS.QNX_MAJOR > 6 || (OS.QNX_MAJOR == 6 && (OS.QNX_MINOR > 2 || (OS.QNX_MINOR == 2 && OS.QNX_MICRO >= 1)))) {
- data.paint = true;
- }
- GC gc = GC.photon_new (this, data);
- //set clipping on the GC?
- if ((state & DISABLED) != 0) gc.setForeground (disabledColor);
- layout.draw (gc, 0, 0, selStart, selEnd, null, null);
- if (hasFocus () && focusIndex != -1) {
- Rectangle [] rects = getRectangles (focusIndex);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rectangle = rects [i];
- gc.drawFocus (rectangle.x, rectangle.y, rectangle.width, rectangle.height);
- }
- }
- gc.dispose ();
-}
-
-String getNameText () {
- return getText ();
-}
-
-Rectangle [] getRectangles (int linkIndex) {
- int lineCount = layout.getLineCount ();
- Rectangle [] rects = new Rectangle [lineCount];
- int [] lineOffsets = layout.getLineOffsets ();
- Point point = offsets [linkIndex];
- int lineStart = 1;
- while (point.x > lineOffsets [lineStart]) lineStart++;
- int lineEnd = 1;
- while (point.y > lineOffsets [lineEnd]) lineEnd++;
- int index = 0;
- if (lineStart == lineEnd) {
- rects [index++] = layout.getBounds (point.x, point.y);
- } else {
- rects [index++] = layout.getBounds (point.x, lineOffsets [lineStart]-1);
- rects [index++] = layout.getBounds (lineOffsets [lineEnd-1], point.y);
- if (lineEnd - lineStart > 1) {
- for (int i = lineStart; i < lineEnd - 1; i++) {
- rects [index++] = layout.getLineBounds (i);
- }
- }
- }
- if (rects.length != index) {
- Rectangle [] tmp = new Rectangle [index];
- System.arraycopy (rects, 0, tmp, 0, index);
- rects = tmp;
- }
- return rects;
-}
-
-/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget ();
- return text;
-}
-
-void enableWidget (boolean enabled) {
- super.enableWidget (enabled);
- TextStyle linkStyle = new TextStyle (null, enabled ? linkColor : disabledColor, null);
- linkStyle.underline = true;
- for (int i = 0; i < offsets.length; i++) {
- Point point = offsets [i];
- layout.setStyle (linkStyle, point.x, point.y);
- }
- redraw ();
-}
-
-String parse (String string) {
- int length = string.length ();
- offsets = new Point [length / 4];
- ids = new String [length / 4];
- mnemonics = new int [length / 4 + 1];
- StringBuffer result = new StringBuffer ();
- char [] buffer = new char [length];
- string.getChars (0, string.length (), buffer, 0);
- int index = 0, state = 0, linkIndex = 0;
- int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0;
- while (index < length) {
- char c = Character.toLowerCase (buffer [index]);
- switch (state) {
- case 0:
- if (c == '<') {
- tagStart = index;
- state++;
- }
- break;
- case 1:
- if (c == 'a') state++;
- break;
- case 2:
- switch (c) {
- case 'h':
- state = 7;
- break;
- case '>':
- linkStart = index + 1;
- state++;
- break;
- default:
- if (Character.isWhitespace(c)) break;
- else state = 13;
- }
- break;
- case 3:
- if (c == '<') {
- endtagStart = index;
- state++;
- }
- break;
- case 4:
- state = c == '/' ? state + 1 : 3;
- break;
- case 5:
- state = c == 'a' ? state + 1 : 3;
- break;
- case 6:
- if (c == '>') {
- mnemonics [linkIndex] = parseMnemonics (buffer, start, tagStart, result);
- int offset = result.length ();
- parseMnemonics (buffer, linkStart, endtagStart, result);
- offsets [linkIndex] = new Point (offset, result.length () - 1);
- if (ids [linkIndex] == null) {
- ids [linkIndex] = new String (buffer, linkStart, endtagStart - linkStart);
- }
- linkIndex++;
- start = tagStart = linkStart = endtagStart = refStart = index + 1;
- state = 0;
- } else {
- state = 3;
- }
- break;
- case 7:
- state = c == 'r' ? state + 1 : 0;
- break;
- case 8:
- state = c == 'e' ? state + 1 : 0;
- break;
- case 9:
- state = c == 'f' ? state + 1 : 0;
- break;
- case 10:
- state = c == '=' ? state + 1 : 0;
- break;
- case 11:
- if (c == '"') {
- state++;
- refStart = index + 1;
- } else {
- state = 0;
- }
- break;
- case 12:
- if (c == '"') {
- ids[linkIndex] = new String (buffer, refStart, index - refStart);
- state = 2;
- }
- break;
- case 13:
- if (Character.isWhitespace (c)) {
- state = 0;
- } else if (c == '='){
- state++;
- }
- break;
- case 14:
- state = c == '"' ? state + 1 : 0;
- break;
- case 15:
- if (c == '"') state = 2;
- break;
- default:
- state = 0;
- break;
- }
- index++;
- }
- if (start < length) {
- int tmp = parseMnemonics (buffer, start, tagStart, result);
- int mnemonic = parseMnemonics (buffer, Math.max (tagStart, linkStart), length, result);
- if (mnemonic == -1) mnemonic = tmp;
- mnemonics [linkIndex] = mnemonic;
- } else {
- mnemonics [linkIndex] = -1;
- }
- if (offsets.length != linkIndex) {
- Point [] newOffsets = new Point [linkIndex];
- System.arraycopy (offsets, 0, newOffsets, 0, linkIndex);
- offsets = newOffsets;
- String [] newIDs = new String [linkIndex];
- System.arraycopy (ids, 0, newIDs, 0, linkIndex);
- ids = newIDs;
- int [] newMnemonics = new int [linkIndex + 1];
- System.arraycopy (mnemonics, 0, newMnemonics, 0, linkIndex + 1);
- mnemonics = newMnemonics;
- }
- return result.toString ();
-}
-
-int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
- int mnemonic = -1, index = start;
- while (index < end) {
- if (buffer [index] == '&') {
- if (index + 1 < end && buffer [index + 1] == '&') {
- result.append (buffer [index]);
- index++;
- } else {
- mnemonic = result.length();
- }
- } else {
- result.append (buffer [index]);
- }
- index++;
- }
- return mnemonic;
-}
-
-int Ph_EV_BUT_PRESS (int widget, int info) {
- int result = super.Ph_EV_BUT_PRESS (widget, 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 result;
-
- if (focusIndex != -1) setFocus ();
- int x = pe.pos_x + ev.translation_x;
- int y = pe.pos_y + ev.translation_y;
- int offset = layout.getOffset (x, y, null);
- int oldSelectionX = selection.x;
- int oldSelectionY = selection.y;
- selection.x = offset;
- selection.y = -1;
- if (oldSelectionX != -1 && oldSelectionY != -1) {
- if (oldSelectionX > oldSelectionY) {
- int temp = oldSelectionX;
- oldSelectionX = oldSelectionY;
- oldSelectionY = temp;
- }
- Rectangle rect = layout.getBounds (oldSelectionX, oldSelectionY);
- redraw (rect.x, rect.y, rect.width, rect.height, false);
- }
- for (int j = 0; j < offsets.length; j++) {
- Rectangle [] rects = getRectangles (j);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects [i];
- if (rect.contains (x, y)) {
- if (j != focusIndex) {
- focusIndex = j;
- redraw ();
- }
- return result;
- }
- }
- }
- return result;
-}
-
-int Ph_EV_BUT_RELEASE (int widget, int info) {
- int result = super.Ph_EV_BUT_PRESS (widget, info);
- if (focusIndex == -1) return result;
- 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 result;
-
- int x = pe.pos_x + ev.translation_x;
- int y = pe.pos_y + ev.translation_y;
- Rectangle [] rects = getRectangles (focusIndex);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects [i];
- if (rect.contains (x, y)) {
- Event event = new Event ();
- event.text = ids [focusIndex];
- sendEvent (SWT.Selection, event);
- return result;
- }
- }
- return result;
-}
-
-int Ph_EV_DRAG (int widget, int info) {
- int result = super.Ph_EV_DRAG (widget, 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);
- int x = pe.pos_x + ev.translation_x;
- int y = pe.pos_y + ev.translation_y;
-
-// if (pe.buttons != OS.Ph_BUTTON_SELECT) return result;//??
- if ((pe.button_state & OS.Ph_BUTTON_SELECT) != 0) {
- int oldSelection = selection.y;
- selection.y = layout.getOffset (x, y, null);
- if (selection.y != oldSelection) {
- int newSelection = selection.y;
- if (oldSelection > newSelection) {
- int temp = oldSelection;
- oldSelection = newSelection;
- newSelection = temp;
- }
- Rectangle rect = layout.getBounds (oldSelection, newSelection);
- redraw (rect.x, rect.y, rect.width, rect.height, false);
- }
- } else {
- for (int j = 0; j < offsets.length; j++) {
- Rectangle [] rects = getRectangles (j);
- for (int i = 0; i < rects.length; i++) {
- Rectangle rect = rects [i];
- if (rect.contains (x, y)) {
- setCursor (display.getSystemCursor (SWT.CURSOR_HAND));
- return result;
- }
- }
- }
- setCursor (null);
- }
- return result;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- int result = super.Pt_CB_GOT_FOCUS (widget, info);
- redraw ();
- return result;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- int result = super.Pt_CB_LOST_FOCUS (widget, info);
- redraw ();
- return result;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (layout != null) layout.dispose ();
- layout = null;
- if (linkColor != null) linkColor.dispose ();
- linkColor = null;
- if (disabledColor != null) disabledColor.dispose ();
- disabledColor = null;
- offsets = null;
- ids = null;
- mnemonics = null;
- text = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is selected by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget ();
- if (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) {
- layout.setWidth (width > 0 ? width : -1);
- }
- return result;
-}
-
-public void setFont (Font font) {
- super.setFont (font);
- layout.setFont (font);
-}
-
-/**
- * Sets the receiver's text.
- * <p>
- * The string can contain both regular text and hyperlinks. A hyperlink
- * is delimited by an anchor tag, &lt;A&gt; and &lt;/A&gt;. Within an
- * anchor, a single HREF attribute is supported. When a hyperlink is
- * selected, the text field of the selection event contains either the
- * text of the hyperlink or the value of its HREF, if one was specified.
- * In the rare case of identical hyperlinks within the same string, the
- * HREF attribute can be used to distinguish between them. The string may
- * include the mnemonic character and line delimiters. The only delimiter
- * the HREF attribute supports is the quotation mark (").
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (string.equals (text)) return;
- text = string;
- layout.setText (parse (string));
- focusIndex = offsets.length > 0 ? 0 : -1;
- selection.x = selection.y = -1;
- boolean enabled = (state & DISABLED) == 0;
- TextStyle linkStyle = new TextStyle (null, enabled ? linkColor : disabledColor, null);
- linkStyle.underline = true;
- for (int i = 0; i < offsets.length; i++) {
- Point point = offsets [i];
- layout.setStyle (linkStyle, point.x, point.y);
- }
- TextStyle mnemonicStyle = new TextStyle (null, null, null);
- mnemonicStyle.underline = true;
- for (int i = 0; i < mnemonics.length; i++) {
- int mnemonic = mnemonics [i];
- if (mnemonic != -1) {
- layout.setStyle (mnemonicStyle, mnemonic, mnemonic);
- }
- }
- redraw ();
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean translated = super.translateTraversal (key_sym, phEvent);
- if (translated) return translated;
- if (focusIndex == -1) return translated;
- if (phEvent != null) {
- switch (key_sym) {
- case OS.Pk_Return:
- Event event = new Event ();
- event.text = ids [focusIndex];
- sendEvent (SWT.Selection, event);
- break;
- case OS.Pk_Tab:
- boolean next = (phEvent.key_mods & OS.Pk_KM_Shift) == 0;
- if (next) {
- if (focusIndex < offsets.length - 1) {
- focusIndex++;
- redraw ();
- }
- } else {
- if (focusIndex > 0) {
- focusIndex--;
- redraw ();
- }
- }
- break;
- }
- }
- return translated;
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- if (offsets.length == 0) return 0;
- int code = super.traversalCode (key_sym, ke);
- if (key_sym == OS.Pk_Tab && ke != null) {
- boolean next = (ke.key_mods & OS.Pk_KM_Shift) == 0;
- if (next && focusIndex < offsets.length - 1) {
- return code & ~SWT.TRAVERSE_TAB_NEXT;
- }
- if (!next && focusIndex > 0) {
- return code & ~SWT.TRAVERSE_TAB_PREVIOUS;
- }
- }
- return code;
-}
-
-}
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
deleted file mode 100755
index 48b66e5b7f..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
+++ /dev/null
@@ -1,1259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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 notification
- * when a string is selected. A list may be single or multi select.
- * <p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SINGLE, MULTI</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection</dd>
- * </dl>
- * <p>
- * Note: Only one of SINGLE and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#list">List snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class List extends Scrollable {
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @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);
-}
-
-/**
- * Adds the argument to the end of the receiver's list.
- *
- * @param string the new item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the user changes the receiver's selection, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the selection changes.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * </p>
- *
- * @param listener the listener which should be notified when the user changes the receiver's selection
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- 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.
- * <p>
- * Note: To add an item at the end of the list, use the
- * result of calling <code>getItemCount()</code> as the
- * index or use <code>add(String)</code>.
- * </p>
- *
- * @param string the new item
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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;
- }
-
- 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;
- 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 () {
- return display.LIST_BACKGROUND;
-}
-
-byte [] defaultFont () {
- return display.LIST_FONT;
-}
-
-int defaultForeground () {
- 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
- * deselected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void deselect (int index) {
- checkWidget();
- if (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
- * is selected, it is deselected. If the item at the index
- * was not selected, it remains deselected. The range of the
- * indices is inclusive. Indices that are out of range are ignored.
- *
- * @param start the start index of the items to deselect
- * @param end the end index of the items to deselect
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void deselect (int start, int end) {
- checkWidget();
- if (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
- * is selected, it is deselected. If the item at the index
- * was not selected, it remains deselected. Indices that are out
- * of range and duplicate indices are ignored.
- *
- * @param indices the array of indices for the items to deselect
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void deselect (int [] indices) {
- checkWidget();
- if (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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void deselectAll () {
- checkWidget();
- 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 currently
- * has the focus in the receiver, or -1 if no item has focus.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getFocusIndex () {
- return getSelectionIndex ();
-}
-
-/**
- * Returns the item at the given, zero-relative index in the
- * receiver. Throws an exception if the index is out of range.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget();
- 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 list.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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);
- OS.memset(ptr, 0, 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 a (possibly empty) array of <code>String</code>s which
- * are the items in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver's list
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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. The order of the items is unspecified.
- * An empty array indicates that no items are selected.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its selection, so modifying the array will
- * not affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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.
- *
- * @return the number of selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionCount () {
- 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.
- *
- * @return the index of the selected item or -1
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionIndex () {
- checkWidget();
- 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 order of the indices is unspecified.
- * The array is empty if no items are selected.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its selection, so modifying the array will
- * not affect the receiver.
- * </p>
- * @return the array of indices of the selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int [] getSelectionIndices () {
- 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
- * scrolled or new items are added or removed.
- *
- * @return the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTopIndex () {
- checkWidget();
- 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 = display.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>
- * The list is searched starting at 0 until an
- * item is found that is equal to the search item.
- * If no item is found, -1 is returned. Indexing
- * is zero based.
- *
- * @param string the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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
- * to the argument, and returns the index of that item. If
- * no item is found or the starting index is out of range,
- * returns -1.
- *
- * @param string the search item
- * @param start the zero-relative index at which to start the search
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (String string, int start) {
- checkWidget();
- if (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
- * range are ignored.
- *
- * @param index the index of the item
- * @return the selection state of the item at the index
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean isSelected (int index) {
- checkWidget();
- 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.
- *
- * @param index the index for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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,
- * and removes that item from the list.
- *
- * @param string the item to remove
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (String string) {
- checkWidget();
- int index = indexOf (string, 0);
- if (index == -1) error (SWT.ERROR_INVALID_ARGUMENT);
- remove (index);
-}
-
-/**
- * Removes the items from the receiver at the given
- * zero-relative indices.
- *
- * @param indices the array of indices of the items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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 remove (int [] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (indices.length == 0) return;
- int [] newIndices = new int [indices.length];
- System.arraycopy (indices, 0, newIndices, 0, indices.length);
- sort (newIndices);
- int start = newIndices [newIndices.length - 1], end = newIndices [0];
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- if (!(0 <= start && start <= end && end < count)) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- int last = -1;
- for (int i=0; i<newIndices.length; i++ ) {
- int index = newIndices [i];
- if (last != index) {
- int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
- if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
- last = index;
- }
- }
-}
-
-/**
- * Removes the items from the receiver which are
- * between the given zero-relative start and end
- * indices (inclusive).
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void remove (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);
- 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>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void removeAll () {
- checkWidget();
- OS.PtListDeleteAllItems (handle);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the user changes the receiver's selection.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Selects the items in the range specified by the given zero-relative
- * indices in the receiver. The range of indices is inclusive.
- * The current selection is not cleared before the new items are selected.
- * <p>
- * If an item in the given range is not selected, it is selected.
- * If an item in the given range was already selected, it remains selected.
- * Indices that are out of range are ignored and no items will be selected
- * if start is greater than end.
- * If the receiver is single-select and there is more than one item in the
- * given range, then all indices are ignored.
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see List#setSelection(int,int)
- */
-public void select (int start, int end) {
- checkWidget ();
- if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && 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 (count == 0 || start >= count) return;
- start = Math.max (0, start);
- end = Math.min (end, count - 1);
- if ((style & SWT.SINGLE) != 0) {
- select (start);
- return;
- }
- int gotoIndex = -1;
- for (int index=end; index>=start; index--) {
- 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.
- * The current selection is not cleared before the new items are selected.
- * <p>
- * If the item at a given index is not selected, it is selected.
- * If the item at a given index was already selected, it remains selected.
- * Indices that are out of range and duplicate indices are ignored.
- * If the receiver is single-select and multiple indices are specified,
- * then all indices are ignored.
- *
- * @param indices the array of indices for the items to select
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see List#setSelection(int[])
- */
-public void select (int [] indices) {
- checkWidget ();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- int length = indices.length;
- if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) 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<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
- * selected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void select (int index) {
- checkWidget();
- if (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 of the items in the receiver.
- * <p>
- * If the receiver is single-select, do nothing.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void selectAll () {
- checkWidget();
- if ((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.
- *
- * @param index the index for the item
- * @param string the new text for the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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.
- *
- * @param items the array of items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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 setItems (String [] items) {
- checkWidget();
- if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<items.length; i++) {
- if (items [i] == null) error (SWT.ERROR_INVALID_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 in the range specified by the given zero-relative
- * indices in the receiver. The range of indices is inclusive.
- * The current selection is cleared before the new items are selected.
- * <p>
- * Indices that are out of range are ignored and no items will be selected
- * if start is greater than end.
- * If the receiver is single-select and there is more than one item in the
- * given range, then all indices are ignored.
- *
- * @param start the start index of the items to select
- * @param end the end index of the items to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see List#deselectAll()
- * @see List#select(int,int)
- */
-public void setSelection (int start, int end) {
- checkWidget ();
- if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) {
- deselectAll ();
- 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 (count == 0 || start >= count) {
- deselectAll ();
- return;
- }
- start = Math.max (0, start);
- end = Math.min (end, count - 1);
- 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.
- * The current selection is first cleared, then the new item is selected.
- * Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @see List#deselectAll()
- * @see List#select(int)
- */
-public void setSelection (int index) {
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (index);
-}
-
-/**
- * Selects the items at the given zero-relative indices in the receiver.
- * The current selection is cleared before the new items are selected.
- * <p>
- * Indices that are out of range and duplicate indices are ignored.
- * If the receiver is single-select and multiple indices are specified,
- * then all indices are ignored.
- *
- * @param indices the indices of the items to select
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see List#deselectAll()
- * @see List#select(int[])
- */
-public void setSelection(int[] indices) {
- checkWidget ();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- deselectAll ();
- int length = indices.length;
- if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
- select (indices);
-}
-
-/**
- * Sets the receiver's selection to be the given array of items.
- * The current selection is cleared before the new items are selected.
- * <p>
- * Items that are not in the receiver are ignored.
- * If the receiver is single-select and multiple items are specified,
- * then all items are ignored.
- *
- * @param items the array of items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see List#deselectAll()
- * @see List#select(int[])
- * @see List#setSelection(int[])
- */
-public void setSelection (String [] items) {
- checkWidget ();
- if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- int length = items.length;
- if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) {
- deselectAll ();
- return;
- }
- if ((style & SWT.MULTI) != 0) deselectAll ();
- for (int i=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) 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
- * are scrolled or new items are added and removed.
- *
- * @param index the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTopIndex (int index) {
- checkWidget();
- 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
- * the selection is visible.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void showSelection () {
- checkWidget();
- 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
deleted file mode 100755
index 6234527894..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
+++ /dev/null
@@ -1,844 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP</dd>
- * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Help, Hide, Show </dd>
- * </dl>
- * <p>
- * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
- * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#menu">Menu snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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
- * will be a popup menu on the given parent's shell.
- * <p>
- * After constructing a menu, it can be set into its parent
- * using <code>parent.setMenu(menu)</code>. In this case, the parent may
- * be any control in the same widget tree as the parent.
- * </p>
- *
- * @param parent a control which will be the parent of the new instance (cannot be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#POP_UP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Menu (Control parent) {
- this (checkNull (parent).menuShell (), SWT.POP_UP);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Decorations</code>) and a style value
- * describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * After constructing a menu or menuBar, it can be set into its parent
- * using <code>parent.setMenu(menu)</code> or <code>parent.setMenuBar(menuBar)</code>.
- * </p>
- *
- * @param parent a decorations control which will be the parent of the new instance (cannot be null)
- * @param style the style of menu to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BAR
- * @see SWT#DROP_DOWN
- * @see SWT#POP_UP
- * @see SWT#NO_RADIO_GROUP
- * @see SWT#LEFT_TO_RIGHT
- * @see SWT#RIGHT_TO_LEFT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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
- * for the instance so that the instance will be a drop-down
- * menu on the given parent's parent.
- * <p>
- * After constructing a drop-down menu, it can be set into its parentMenu
- * using <code>parentMenu.setMenu(menu)</code>.
- * </p>
- *
- * @param parentMenu a menu which will be the parent of the new instance (cannot be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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
- * for the instance so that the instance will be a drop-down
- * menu on the given parent's parent menu.
- * <p>
- * After constructing a drop-down menu, it can be set into its parentItem
- * using <code>parentItem.setMenu(menu)</code>.
- * </p>
- *
- * @param parentItem a menu item which will be the parent of the new instance (cannot be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#DROP_DOWN
- * @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);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when help events are generated for the control,
- * by sending it one of the messages defined in the
- * <code>HelpListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see HelpListener
- * @see #removeHelpListener
- */
-public void addHelpListener (HelpListener listener) {
- checkWidget();
- if (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
- * one of the messages defined in the <code>MenuListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MenuListener
- * @see #removeMenuListener
- */
-public void addMenuListener (MenuListener listener) {
- checkWidget();
- if (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.
- *
- * @return the default menu item.
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public MenuItem getDefaultItem () {
- checkWidget();
- return defaultItem;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> otherwise. A disabled menu 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 #isEnabled
- */
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
-/**
- * Returns the number of items contained in the receiver.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget();
- 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.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public MenuItem getItem (int index) {
- checkWidget();
- if (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 a (possibly empty) array of <code>MenuItem</code>s which
- * are the items in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public MenuItem [] getItems () {
- checkWidget();
- 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>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Decorations getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns the receiver's parent item, which must be a
- * <code>MenuItem</code> or null when the receiver is a
- * root.
- *
- * @return the receiver's parent item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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
- * root.
- *
- * @return the receiver's parent item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Menu getParentMenu () {
- checkWidget();
- if (cascade != null) return cascade.parent;
- return null;
-}
-
-/**
- * Returns the receiver's shell. For all controls other than
- * shells, this simply returns the control's nearest ancestor
- * shell. Shells return themselves, even if they are children
- * of other shells.
- *
- * @return the receiver's shell
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getParent
- */
-public Shell getShell () {
- checkWidget();
- return parent.getShell ();
-}
-
-/*public*/ Point getSize () {
- checkWidget();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (handle, area);
- return new Point (area.size_w, area.size_h);
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible, and
- * <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getVisible () {
- checkWidget();
- return OS.PtWidgetIsRealized (handle);
-}
-
-void hookEvents () {
- int windowProc = display.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
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param item the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (MenuItem item) {
- checkWidget();
- if (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 menu 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 () && parent.isEnabled ();
- }
- 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 releaseChildren (boolean destroy) {
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
- MenuItem item = items [i];
- if (item != null && !item.isDisposed ()) {
- item.release (false);
- }
- }
- super.releaseChildren (destroy);
-}
-
-void releaseParent () {
- super.releaseParent ();
- if (cascade != null) cascade.setMenu (null);
- if ((style & SWT.BAR) != 0 && this == parent.menuBar) {
- parent.setMenuBar (null);
- }
-}
-
-void releaseWidget () {
- 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.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the menu events are generated for the control.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Sets the default menu item to the argument or removes
- * the default emphasis when the argument is <code>null</code>.
- *
- * @param item the default menu item or null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the menu item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 menu is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEnabled (boolean enabled) {
- checkWidget ();
- 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 location of the receiver, which must be a popup,
- * to the point specified by the arguments which are relative
- * to the display.
- * <p>
- * Note that this is different from most widgets where the
- * location of the widget is relative to the parent.
- * </p><p>
- * Note that the platform window manager ultimately has control
- * over the location of popup menus.
- * </p>
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLocation (int x, int y) {
- checkWidget();
- this.x = x;
- this.y = y;
- hasLocation = true;
-}
-
-/**
- * Sets the location of the receiver, which must be a popup,
- * to the point specified by the argument which is relative
- * to the display.
- * <p>
- * Note that this is different from most widgets where the
- * location of the widget is relative to the parent.
- * </p><p>
- * Note that the platform window manager ultimately has control
- * over the location of popup menus.
- * </p>
- *
- * @param location the new location for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-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.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setVisible (boolean visible) {
- checkWidget();
- if ((style & SWT.POP_UP) == 0) return;
- if (visible == OS.PtWidgetIsRealized (handle)) return;
- if (visible) {
- display.runDeferredEvents ();
- 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
deleted file mode 100755
index e2f942200c..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
+++ /dev/null
@@ -1,921 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Arm, Help, Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a menu control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#CHECK
- * @see SWT#CASCADE
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public MenuItem (Menu parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Menu</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a menu control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the zero-relative index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#CHECK
- * @see SWT#CASCADE
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @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));
- 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
- * it one of the messages defined in the <code>ArmListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ArmListener
- * @see #removeArmListener
- */
-public void addArmListener (ArmListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Arm, typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the help events are generated for the control, by sending
- * it one of the messages defined in the <code>HelpListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see HelpListener
- * @see #removeHelpListener
- */
-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 menu item is selected by the user, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified when the menu item is selected by the user
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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 ());
- }
-}
-
-/**
- * Returns the widget accelerator. An accelerator is the bit-wise
- * OR of zero or more modifier masks and a key. Examples:
- * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
- * The default value is zero, indicating that the menu item does
- * not have an accelerator.
- *
- * @return the accelerator or 0
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getAccelerator () {
- checkWidget();
- return accelerator;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> otherwise. A disabled menu item 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 #isEnabled
- */
-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
- * a pull down menu. The sequence of key strokes, button presses
- * and/or button releases that are used to request a pull down
- * menu is platform specific.
- *
- * @return the receiver's menu
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Menu getMenu () {
- checkWidget();
- return menu;
-}
-
-String getNameText () {
- if ((style & SWT.SEPARATOR) != 0) return "|";
- return super.getNameText ();
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Menu</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Menu getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns <code>true</code> if the receiver is selected,
- * and false otherwise.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked.
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 = display.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 menu item 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);
- setInputState (event, SWT.Selection, ke.key_mods, ke.button_state);
- 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);
- setInputState (event, SWT.Selection, pe.key_mods, pe.button_state);
- 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) {
- sendEvent (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 (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- return OS.Pt_CONTINUE;
-}
-
-void releaseChildren (boolean destroy) {
- if (menu != null && !menu.isDisposed ()) {
- menu.release (false);
- menu = null;
- }
- super.releaseChildren (destroy);
-}
-
-void releaseParent () {
- super.releaseParent ();
- if (menu != null) menu.dispose ();
- menu = null;
-}
-
-void releaseWidget () {
- 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.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the help events are generated for the control.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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));
- 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 by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (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:
- * <code>SWT.MOD1 | SWT.MOD2 | 'T', SWT.MOD3 | SWT.F2</code>.
- * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
- * The default value is zero, indicating that the menu item does
- * not have an accelerator.
- *
- * @param accelerator an integer that is the bit-wise OR of masks and a key
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setAccelerator (int accelerator) {
- checkWidget();
- if (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 menu item is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEnabled (boolean enabled) {
- checkWidget ();
- if (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>
- * Note: This operation is a hint and is not supported on
- * platforms that do not have this concept (for example, Windows NT).
- * Furthermore, some platforms (such as GTK), cannot display both
- * a check box and an image at the same time. Instead, they hide
- * the image and display the check box.
- * </p>
- *
- * @param image the image 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 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.
- */
- 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
- * pull down menu. The sequence of key strokes, button presses
- * and/or button releases that are used to request a pull down
- * menu is platform specific.
- * <p>
- * Note: Disposing of a menu item that has a pull down menu
- * will dispose of the menu. To avoid this behavior, set the
- * menu to null before the menu item is disposed.
- * </p>
- *
- * @param menu the new pull down menu
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_MENU_NOT_DROP_DOWN - if the menu is not a drop down menu</li>
- * <li>ERROR_MENUITEM_NOT_CASCADE - if the menu item is not a <code>CASCADE</code></li>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMenu (Menu menu) {
- checkWidget();
- if ((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>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (boolean selected) {
- checkWidget();
- if ((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 text. The string may include
- * the mnemonic character and accelerator text.
- * <p>
- * Mnemonics are indicated by an '&amp;' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&amp;' can be
- * escaped by doubling it in the string, causing a single
- * '&amp;' to be displayed.
- * </p>
- * <p>
- * Accelerator text is indicated by the '\t' character.
- * On platforms that support accelerator text, the text
- * that follows the '\t' character is displayed to the user,
- * typically indicating the key stroke that will cause
- * the item to become selected. On most platforms, the
- * accelerator text appears right aligned in the menu.
- * Setting the accelerator text does not install the
- * accelerator key sequence. The accelerator key sequence
- * is installed using #setAccelerator.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setAccelerator
- */
-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++]) == '&') {
- if (i == text.length) {continue;}
- if (text [i] == '&') {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
deleted file mode 100755
index 3f5de9a94c..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class are used to inform or warn the user.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING</dd>
- * <dd>OK, OK | CANCEL</dd>
- * <dd>YES | NO, YES | NO | CANCEL</dd>
- * <dd>RETRY | CANCEL</dd>
- * <dd>ABORT | RETRY | IGNORE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
- * ICON_WARNING and ICON_WORKING may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class MessageBox extends Dialog {
- String message = "";
-/**
- * Constructs a new instance of this class given only its parent.
- *
- * @param parent a shell which will be the parent of the new instance
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public MessageBox (Shell parent) {
- this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
-}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of dialog to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#ICON_ERROR
- * @see SWT#ICON_INFORMATION
- * @see SWT#ICON_QUESTION
- * @see SWT#ICON_WARNING
- * @see SWT#ICON_WORKING
- * @see SWT#OK
- * @see SWT#CANCEL
- * @see SWT#YES
- * @see SWT#NO
- * @see SWT#ABORT
- * @see SWT#RETRY
- * @see SWT#IGNORE
- */
-public MessageBox (Shell parent, int style) {
- super (parent, checkStyle (parent, checkStyle (style)));
- checkSubclass ();
-}
-static int checkStyle (int style) {
- 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, or an empty string if it does not have one.
- * The message is a description of the purpose for which the dialog was opened.
- * This message will be visible in the dialog while it is open.
- *
- * @return the message
- */
-public String getMessage () {
- return message;
-}
-/**
- * Makes the dialog visible and brings it to the front
- * of the display.
- *
- * @return the ID of the button that was selected to dismiss the
- * message box (e.g. SWT.OK, SWT.CANCEL, etc.)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
- * </ul>
- */
-public int open () {
- 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;
- 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
- * visible on the dialog while it is open.
- *
- * @param string the message
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- */
-public void setMessage (String string) {
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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
deleted file mode 100755
index 575bc28393..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of the receiver represent an unselectable
- * user interface object that is used to display progress,
- * typically in the form of a bar.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SMOOTH, HORIZONTAL, VERTICAL, INDETERMINATE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#progressbar">ProgressBar snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class ProgressBar extends Control {
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SMOOTH
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see SWT#INDETERMINATE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ProgressBar (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style |= SWT.NO_FOCUS;
- 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;
- 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 () {
- return display.GAUGE_FONT;
-}
-
-/**
- * Returns the maximum value which the receiver will allow.
- *
- * @return the maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMaximum () {
- checkWidget();
- 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.
- *
- * @return the minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns the single 'selection' that is the receiver's position.
- *
- * @return the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns the state of the receiver. The value will be one of:
- * <ul>
- * <li>{@link SWT#NORMAL}</li>
- * <li>{@link SWT#ERROR}</li>
- * <li>{@link SWT#PAUSED}</li>
- * </ul>
- *
- * @return the 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>
- *
- * @since 3.4
- */
-public int getState () {
- checkWidget ();
- return SWT.NORMAL;
-}
-
-/**
- * Sets the maximum value that the receiver will allow. This new
- * value will be ignored if it is not greater than the receiver's current
- * minimum value. If the new maximum is applied then the receiver's
- * selection value will be adjusted if necessary to fall within its new range.
- *
- * @param value the new maximum, which must be greater than the current minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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 that the receiver will allow. This new
- * value will be ignored if it is negative or is not less than the receiver's
- * current maximum value. If the new minimum is applied then the receiver's
- * selection value will be adjusted if necessary to fall within its new range.
- *
- * @param value the new minimum, which must be nonnegative and less than the current maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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 'selection' that is the receiver's
- * position to the argument which must be greater than or equal
- * to zero.
- *
- * @param value the new selection (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
-/**
- * Sets the state of the receiver. The state must be one of these values:
- * <ul>
- * <li>{@link SWT#NORMAL}</li>
- * <li>{@link SWT#ERROR}</li>
- * <li>{@link SWT#PAUSED}</li>
- * </ul>
- *
- * @param state the new 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>
- *
- * @since 3.4
- */
-public void setState (int state) {
- checkWidget ();
- //NOT IMPLEMENTED
-}
-
-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
deleted file mode 100755
index f6af35eff8..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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
- * the parent control.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL, SMOOTH</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#sash">Sash snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see SWT#SMOOTH
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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 the user, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid.
- * If the receiver is being dragged, the event object detail field contains the value <code>SWT.DRAG</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified when the control is selected by the user
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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;
- 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 () {
- 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);
- int disjoint = OS.PtFindDisjoint( handle );
- if( disjoint != 0 )
- OS.PgSetRegion( OS.PtWidgetRid( disjoint ) );
- PhPoint_t pt = new PhPoint_t ();
-// PhRect_t tran_rect = new PhRect_t();
- if (parentHandle <= 0) return;
- OS.PtWidgetOffset(parentHandle, pt);
- OS.PgSetTranslation(pt,0);
- OS.PgSetDrawMode (OS.Pg_DrawModeDSx);
- 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 (true);
- 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 by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (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
deleted file mode 100755
index a53bcc02f4..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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
- * numeric values.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#scale">Scale snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Scale extends Control {
-
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Scale (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the user changes the receiver's value, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the user changes the receiver's value.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- */
-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;
- 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 () {
- return display.GAUGE_FONT;
-}
-
-/**
- * Returns the amount that the receiver's value will be
- * modified by when the up/down (or right/left) arrows
- * are pressed.
- *
- * @return the increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getIncrement () {
- checkWidget();
- 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.
- *
- * @return the maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMaximum () {
- checkWidget();
- 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.
- *
- * @return the minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMinimum () {
- checkWidget();
- 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
- * are selected.
- *
- * @return the page increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getPageIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns the 'selection', which is the receiver's position.
- *
- * @return the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelection () {
- checkWidget();
- 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 = display.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 user changes the receiver's value.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Sets the amount that the receiver's value will be
- * modified by when the up/down (or right/left) arrows
- * are pressed to the argument, which must be at least
- * one.
- *
- * @param increment the new increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
-/**
- * Sets the maximum value that the receiver will allow. This new
- * value will be ignored if it is not greater than the receiver's current
- * minimum value. If the new maximum is applied then the receiver's
- * selection value will be adjusted if necessary to fall within its new range.
- *
- * @param value the new maximum, which must be greater than the current minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMaximum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value, 0);
-}
-
-/**
- * Sets the minimum value that the receiver will allow. This new
- * value will be ignored if it is negative or is not less than the receiver's
- * current maximum value. If the new minimum is applied then the receiver's
- * selection value will be adjusted if necessary to fall within its new range.
- *
- * @param value the new minimum, which must be nonnegative and less than the current maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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
- * are selected to the argument, which must be at least
- * one.
- *
- * @param pageIncrement the page increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
-/**
- * Sets the 'selection', which is the receiver's value,
- * to the argument which must be greater than or equal to zero.
- *
- * @param value the new selection (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int value) {
- checkWidget();
- 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
deleted file mode 100755
index e92f951cd6..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
+++ /dev/null
@@ -1,725 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <p>
- * At any given moment, a given scroll bar will have a
- * single 'selection' that is considered to be its
- * value, which is constrained to be within the range of
- * values the scroll bar represents (that is, between its
- * <em>minimum</em> and <em>maximum</em> values).
- * </p><p>
- * Typically, scroll bars will be made up of five areas:
- * <ol>
- * <li>an arrow button for decrementing the value</li>
- * <li>a page decrement area for decrementing the value by a larger amount</li>
- * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
- * <li>a page increment area for incrementing the value by a larger amount</li>
- * <li>an arrow button for incrementing the value</li>
- * </ol>
- * Based on their style, scroll bars are either <code>HORIZONTAL</code>
- * (which have a left facing button for decrementing the value and a
- * right facing button for incrementing it) or <code>VERTICAL</code>
- * (which have an upward facing button for decrementing the value
- * and a downward facing buttons for incrementing it).
- * </p><p>
- * On some platforms, the size of the scroll bar's thumb can be
- * varied relative to the magnitude of the range of values it
- * represents (that is, relative to the difference between its
- * maximum and minimum values). Typically, this is used to
- * indicate some proportional value such as the ratio of the
- * visible area of a document to the total amount of space that
- * it would take to display it. SWT supports setting the thumb
- * size even if the underlying platform does not, but in this
- * case the appearance of the scroll bar will not change.
- * </p><p>
- * Scroll bars are created by specifying either <code>H_SCROLL</code>,
- * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.
- * They are accessed from the <code>Scrollable</code> using
- * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.
- * </p><p>
- * Note: Scroll bars are not Controls. On some platforms, scroll bars
- * that appear as part of some standard controls such as a text or list
- * have no operating system resources and are not children of the control.
- * For this reason, scroll bars are treated specially. To create a control
- * that looks like a scroll bar but has operating system resources, use
- * <code>Slider</code>.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see Slider
- * @see Scrollable
- * @see Scrollable#getHorizontalBar
- * @see Scrollable#getVerticalBar
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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 user changes the receiver's value, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
- * <code>SWT.NONE</code> - for the end of a drag.
- * <code>SWT.DRAG</code>.
- * <code>SWT.HOME</code>.
- * <code>SWT.END</code>.
- * <code>SWT.ARROW_DOWN</code>.
- * <code>SWT.ARROW_UP</code>.
- * <code>SWT.PAGE_DOWN</code>.
- * <code>SWT.PAGE_UP</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified when the user changes the receiver's value
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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;
- 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, 99, 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);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> otherwise. A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #isEnabled
- */
-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
- * are pressed.
- *
- * @return the increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getIncrement () {
- checkWidget();
- 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.
- *
- * @return the minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMinimum () {
- checkWidget();
- 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.
- *
- * @return the maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1] + 1;
-}
-
-/**
- * Returns the amount that the receiver's value will be
- * modified by when the page increment/decrement areas
- * are selected.
- *
- * @return the page increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 a Scrollable.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Scrollable getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns the single 'selection' that is the receiver's value.
- *
- * @return the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelection () {
- checkWidget();
- 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]);
-}
-
-/**
- * Returns the size of the receiver's thumb relative to the
- * difference between its maximum and minimum values.
- *
- * @return the thumb value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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];
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible, and
- * <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getVisible () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
-}
-
-void hookEvents () {
- int windowProc = display.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 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 user changes the receiver's value.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-void releaseParent () {
- super.releaseParent ();
- if (parent.horizontalBar == this) parent.horizontalBar = null;
- if (parent.verticalBar == this) parent.verticalBar = null;
-}
-
-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
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEnabled (boolean enabled) {
- checkWidget ();
- 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
- * are pressed to the argument, which must be at least
- * one.
- *
- * @param value the new increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
-/**
- * Sets the maximum. If this value is negative or less than or
- * equal to the minimum, the value is ignored. If necessary, first
- * the thumb and then the selection are adjusted to fit within the
- * new range.
- *
- * @param value the new maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMaximum (int value) {
- checkWidget();
- int [] args = {
- OS.Pt_ARG_MAXIMUM, 0, 0,
- OS.Pt_ARG_MINIMUM, 0, 0,
- OS.Pt_ARG_SLIDER_SIZE, 0, 0,
- OS.Pt_ARG_GAUGE_VALUE, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int minimum = args [4];
- if (value <= minimum) return;
- int thumb = args [7];
- thumb = Math.min (thumb, value - minimum);
- int selection = args [10];
- selection = Math.min (selection, value - thumb);
- args [1] = value - 1;
- args [7] = thumb;
- args [10] = selection;
- OS.PtSetResources (handle, args.length / 3, args);
-}
-
-/**
- * Sets the minimum value. If this value is negative or greater
- * than or equal to the maximum, the value is ignored. If necessary,
- * first the thumb and then the selection are adjusted to fit within
- * the new range.
- *
- * @param value the new minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMinimum (int value) {
- checkWidget();
- if (value < 0) return;
- int [] args = {
- OS.Pt_ARG_MAXIMUM, 0, 0,
- OS.Pt_ARG_MINIMUM, 0, 0,
- OS.Pt_ARG_SLIDER_SIZE, 0, 0,
- OS.Pt_ARG_GAUGE_VALUE, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int maximum = args [1] + 1;
- if (value >= maximum) return;
- int thumb = args [7];
- thumb = Math.min (thumb, maximum - value);
- int selection = args [10];
- selection = Math.max (selection, value);
- args [4] = value;
- args [7] = thumb;
- args [10] = selection;
- OS.PtSetResources (handle, args.length / 3, args);
-}
-
-/**
- * Sets the amount that the receiver's value will be
- * modified by when the page increment/decrement areas
- * are selected to the argument, which must be at least
- * one.
- *
- * @param value the page increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setPageIncrement (int value) {
- checkWidget();
- 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
- * to zero.
- *
- * @param selection the new selection (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int value) {
- checkWidget();
- 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. This new
- * value will be ignored if it is less than one, and will be
- * clamped if it exceeds the receiver's current range.
- *
- * @param value the new thumb value, which must be at least one and not
- * larger than the size of the current range
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setThumb (int value) {
- checkWidget();
- if (value < 1) return;
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0, OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int minimum = args [1];
- int maximum = args [4] + 1;
- value = Math.min (value, maximum - minimum);
- 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.
- * <p>
- * Note: This is similar to setting the values individually
- * using the appropriate methods, but may be implemented in a
- * more efficient fashion on some platforms.
- * </p>
- *
- * @param selection the new selection value
- * @param minimum the new minimum value
- * @param maximum the new maximum value
- * @param thumb the new thumb value
- * @param increment the new increment value
- * @param pageIncrement the new pageIncrement value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
- checkWidget();
- if (minimum < 0) return;
- if (maximum < 0) return;
- if (thumb < 1) return;
- if (increment < 1) return;
- if (pageIncrement < 1) return;
- thumb = Math.min (thumb, maximum - minimum);
- int [] args = {
- OS.Pt_ARG_MAXIMUM, maximum - 1, 0,
- OS.Pt_ARG_MINIMUM, minimum, 0,
- OS.Pt_ARG_SLIDER_SIZE, thumb, 0,
- OS.Pt_ARG_GAUGE_VALUE, selection, 0,
- OS.Pt_ARG_INCREMENT, increment, 0,
- OS.Pt_ARG_PAGE_INCREMENT, pageIncrement, 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.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setVisible (boolean visible) {
- checkWidget ();
- int topHandle = topHandle ();
- int oldFlags = OS.PtWidgetFlags (topHandle);
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if ((oldFlags & OS.Pt_DELAY_REALIZE) == flags) return;
- parent.resizeClientArea ();
- if (visible) {
- sendEvent (SWT.Show);
- OS.PtRealizeWidget (topHandle);
- } else {
- OS.PtUnrealizeWidget (topHandle);
- sendEvent(SWT.Hide);
- }
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
deleted file mode 100755
index 22cc818e63..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>H_SCROLL, V_SCROLL</dd>
- * <dt><b>Events:</b>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#H_SCROLL
- * @see SWT#V_SCROLL
- * @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);
-}
-
-/**
- * Given a desired <em>client area</em> for the receiver
- * (as described by the arguments), returns the bounding
- * rectangle which would be required to produce that client
- * area.
- * <p>
- * In other words, it returns a rectangle such that, if the
- * receiver's bounds were set to that rectangle, the area
- * of the receiver which is capable of displaying data
- * (that is, not covered by the "trimmings") would be the
- * rectangle described by the arguments (relative to the
- * receiver's parent).
- * </p>
- *
- * @param x the desired x coordinate of the client area
- * @param y the desired y coordinate of the client area
- * @param width the desired width of the client area
- * @param height the desired height of the client area
- * @return the required bounds to produce the given client area
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getClientArea
- */
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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,
- * not covered by the "trimmings").
- *
- * @return the client area
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #computeTrim
- */
-public Rectangle getClientArea () {
- checkWidget();
- 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.
- *
- * @return the horizontal scroll bar (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public ScrollBar getHorizontalBar () {
- checkWidget();
- return horizontalBar;
-}
-
-/**
- * Returns the receiver's vertical scroll bar if it has
- * one, and null if it does not.
- *
- * @return the vertical scroll bar (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 releaseChildren (boolean destroy) {
- if (horizontalBar != null) {
- horizontalBar.release (false);
- horizontalBar = null;
- }
- if (verticalBar != null) {
- verticalBar.release (false);
- verticalBar = null;
- }
- super.releaseChildren (destroy);
-}
-
-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
deleted file mode 100755
index e66164f526..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
+++ /dev/null
@@ -1,1426 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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>
- * The <em>modality</em> of an instance may be specified using
- * style bits. The modality style bits are used to determine
- * whether input is blocked for other shells on the display.
- * The <code>PRIMARY_MODAL</code> style allows an instance to block
- * input to its parent. The <code>APPLICATION_MODAL</code> style
- * allows an instance to block input to every other shell in the
- * display. The <code>SYSTEM_MODAL</code> style allows an instance
- * to block input to all shells, including shells belonging to
- * different applications.
- * </p><p>
- * Note: The styles supported by this class are 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>.
- * A modality style may also be "downgraded" to a less
- * restrictive style. For example, most operating systems
- * no longer support <code>SYSTEM_MODAL</code> because
- * it can freeze up the desktop, so this is typically
- * downgraded to <code>APPLICATION_MODAL</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL, SHEET</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
- * @see <a href="http://www.eclipse.org/swt/snippets/#shell">Shell snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public class Shell extends Decorations {
- int shellHandle;
- Menu activeMenu;
- int blockedList;
- Control lastActive;
- boolean modified;
-
-/**
- * Constructs a new instance of this class. This is equivalent
- * to calling <code>Shell((Display) null)</code>.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public Shell () {
- this ((Display) null);
-}
-
-/**
- * Constructs a new instance of this class given only the style
- * value describing its behavior and appearance. This is equivalent
- * to calling <code>Shell((Display) null, style)</code>.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#TOOL
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#ON_TOP
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- * @see SWT#SHEET
- */
-public Shell (int style) {
- this ((Display) null, style);
-}
-
-/**
- * Constructs a new instance of this class given only the display
- * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
- * <p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the shell on
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-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
- * and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the shell on
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#TOOL
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#ON_TOP
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- * @see SWT#SHEET
- */
-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);
- }
- if (parent != null && parent.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- 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>.
- * <p>
- * Note: Currently, null can be passed in for the parent.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the parent is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-public Shell (Shell parent) {
- this (parent, SWT.DIALOG_TRIM);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the parent.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the parent is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#ON_TOP
- * @see SWT#TOOL
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- * @see SWT#SHEET
- */
-public Shell (Shell parent, int style) {
- this (parent != null ? parent.display : 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,
- * by sending the listener one of the messages defined in the
- * <code>ShellListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ShellListener
- * @see #removeShellListener
- */
-public void addShellListener (ShellListener listener) {
- checkWidget();
- if (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 (boolean force) {
- if (!force) {
- if (display.getActiveShell () == null) return;
- }
- OS.PtWindowToFront (shellHandle);
-}
-
-static int checkStyle (int style) {
- style = Decorations.checkStyle (style);
- style &= ~SWT.TRANSPARENT;
- 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
- * the "close box" or performs some other platform specific
- * key or mouse combination that indicates the window
- * should be removed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT#Close
- * @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 ();
- Monitor monitor = getMonitor ();
- Rectangle rect = monitor.getClientArea ();
- int width = rect.width * 5 / 8;
- int height = rect.height * 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);
- OS.memset(titlePtr, 0, 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 trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX;
- if ((style & SWT.NO_TRIM) != 0 || (style & trim) == 0) {
- OS.PtSetResource (shellHandle, OS.Pt_ARG_MIN_WIDTH, 0, 0);
- }
- OS.PtSetResource (shellHandle, OS.Pt_ARG_MIN_HEIGHT, 0, 0);
- int [] args = new int [] {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);
-}
-
-Composite findDeferredControl () {
- return layoutCount > 0 ? this : null;
-}
-
-/**
- * If the receiver is visible, moves it 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(Button)
- * @see Shell#open
- * @see Shell#setActive
- */
-public void forceActive () {
- checkWidget ();
- bringToTop (true);
-}
-
-/**
- * Returns the receiver's alpha value. The alpha value
- * is between 0 (transparent) and 255 (opaque).
- *
- * @return the alpha value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public int getAlpha () {
- checkWidget ();
- return 255;
-}
-
-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);
-}
-
-/**
- * Returns <code>true</code> if the receiver is currently
- * in fullscreen state, and false otherwise.
- * <p>
- *
- * @return the fullscreen 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>
- *
- * @since 3.4
- */
-public boolean getFullScreen () {
- checkWidget();
- return false;
-}
-
-/**
- * Returns the receiver's input method editor mode. This
- * will be the result of bitwise OR'ing together one or
- * more of the following constants defined in class
- * <code>SWT</code>:
- * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,
- * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
- *
- * @return the IME mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- */
-public int getImeInputMode () {
- checkWidget();
- 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;
-}
-
-/**
- * Returns a point describing the minimum receiver's size. The
- * x coordinate of the result is the minimum width of the receiver.
- * The y coordinate of the result is the minimum 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>
- *
- * @since 3.1
- */
-public Point getMinimumSize () {
- 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);
- args = new int [] {
- OS.Pt_ARG_MIN_WIDTH, 0, 0,
- OS.Pt_ARG_MIN_HEIGHT, 0, 0,
- };
- OS.PtGetResources (shellHandle, args.length / 3, args);
- return new Point (args [1] + left [0] + right [0], args [4] + top [0] + bottom [0]);
-}
-
-/**
- * Gets the receiver's modified state.
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.5
- */
-public boolean getModified () {
- checkWidget ();
- return modified;
-}
-
-/**
- * Returns the region that defines the shape of the shell,
- * or null if the shell has the default shape.
- *
- * @return the region that defines the shape of the shell (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- *
- */
-public Region getRegion () {
- /* This method is needed for the @since 3.0 Javadoc */
- checkWidget ();
- return region;
-}
-
-public Shell getShell () {
- checkWidget();
- return this;
-}
-
-/**
- * Returns an array containing all shells which are
- * descendants of the receiver.
- * <p>
- * @return the dialog shells
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Shell [] getShells () {
- checkWidget();
- 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 = display.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,
- * sets the focus 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(Button)
- * @see Shell#setActive
- * @see Shell#forceActive
- */
-public void open () {
- checkWidget();
- setVisible (true);
- if (isDisposed ()) return;
- traverseGroup (true);
-}
-
-public boolean print (GC gc) {
- checkWidget ();
- if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- return false;
-}
-
-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) {
- markLayout (false, false);
- updateLayout (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 releaseParent () {
- /* Do nothing */
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- shellHandle = 0;
-}
-
-void releaseChildren (boolean destroy) {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (shell != null && !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.release (false);
- }
- }
- }
- super.releaseChildren (destroy);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (blockedList != 0) OS.PtUnblockWindows (blockedList);
- blockedList = 0;
- lastActive = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when operations are performed on the receiver.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ShellListener
- * @see #addShellListener
- */
-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);
-}
-
-/**
- * If the receiver is visible, moves it 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(Button)
- * @see Shell#open
- * @see Shell#setActive
- */
-public void setActive () {
- checkWidget ();
- bringToTop (false);
-}
-
-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);
- }
- }
-}
-
-/**
- * Sets the receiver's alpha value which must be
- * between 0 (transparent) and 255 (opaque).
- * <p>
- * This operation requires the operating system's advanced
- * widgets subsystem which may not be available on some
- * platforms.
- * </p>
- * @param alpha the alpha value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public void setAlpha (int alpha) {
- checkWidget ();
- /*Not implemented */
-}
-
-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) {
- markLayout (false, false);
- updateLayout (false);
- }
- }
- }
-
- if (isFocus) caret.setFocus ();
-
- /* Always return 0 */
- return 0;
-}
-
-/**
- * Sets the full screen state of the receiver.
- * If the argument is <code>true</code> causes the receiver
- * to switch to the full screen state, and if the argument is
- * <code>false</code> and the receiver was previously switched
- * into full screen state, causes the receiver to switch back
- * to either the maximized or normal states.
- * <p>
- * Note: The result of intermixing calls to <code>setFullScreen(true)</code>,
- * <code>setMaximized(true)</code> and <code>setMinimized(true)</code> will
- * vary by platform. Typically, the behavior will match the platform user's
- * expectations, but not always. This should be avoided if possible.
- * </p>
- *
- * @param fullScreen the new fullscreen 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>
- *
- * @since 3.4
- */
-public void setFullScreen (boolean fullScreen) {
- checkWidget();
-}
-
-/**
- * Sets the input method editor mode to the argument which
- * should be the result of bitwise OR'ing together one or more
- * of the following constants defined in class <code>SWT</code>:
- * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,
- * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
- *
- * @param mode the new IME mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- */
-public void setImeInputMode (int mode) {
- checkWidget();
-}
-
-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);
- }
-}
-
-/**
- * Sets the receiver's modified state as specified by the argument.
- *
- * @param modified the new modified state for the receiver
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.5
- */
-public void setModified (boolean modified) {
- checkWidget ();
- this.modified = modified;
-}
-
-/**
- * Sets the shape of the shell to the region specified
- * by the argument. When the argument is null, the
- * default shape of the shell is restored. The shell
- * must be created with the style SWT.NO_TRIM in order
- * to specify a region.
- *
- * @param region the region that defines the shape of the shell (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.0
- *
- */
-public void setRegion (Region region) {
- checkWidget ();
- if ((style & SWT.NO_TRIM) == 0) return;
- super.setRegion (region);
-}
-
-/**
- * Sets the receiver's minimum size to the size specified by the arguments.
- * If the new minimum size is larger than the current size of the receiver,
- * the receiver is resized to the new minimum size.
- *
- * @param width the new minimum width for the receiver
- * @param height the new minimum height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.1
- */
-public void setMinimumSize (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);
- width = Math.max (width - left [0] - right [0], 0);
- height = Math.max (height - top [0] - bottom [0], 0);
- args = new int [] {
- OS.Pt_ARG_MIN_WIDTH, width, 0,
- OS.Pt_ARG_MIN_HEIGHT, height, 0,
- };
- OS.PtSetResources (shellHandle, args.length / 3, args);
-}
-
-/**
- * Sets the receiver's minimum size to the size specified by the argument.
- * If the new minimum size is larger than the current size of the receiver,
- * the receiver is resized to the new minimum size.
- *
- * @param size the new minimum size for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.1
- */
-public void setMinimumSize (Point size) {
- checkWidget();
- if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setMinimumSize (size.x, size.y);
-}
-
-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);
- if (isDisposed ()) return;
- OS.PtRealizeWidget (shellHandle);
- } else {
- OS.PtUnrealizeWidget (shellHandle);
- sendEvent(SWT.Hide);
- if (isDisposed ()) return;
- }
-
- /*
- * 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
deleted file mode 100755
index 8de4424e49..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <p>
- * At any given moment, a given slider will have a
- * single 'selection' that is considered to be its
- * value, which is constrained to be within the range of
- * values the slider represents (that is, between its
- * <em>minimum</em> and <em>maximum</em> values).
- * </p><p>
- * Typically, sliders will be made up of five areas:
- * <ol>
- * <li>an arrow button for decrementing the value</li>
- * <li>a page decrement area for decrementing the value by a larger amount</li>
- * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
- * <li>a page increment area for incrementing the value by a larger amount</li>
- * <li>an arrow button for incrementing the value</li>
- * </ol>
- * Based on their style, sliders are either <code>HORIZONTAL</code>
- * (which have a left facing button for decrementing the value and a
- * right facing button for incrementing it) or <code>VERTICAL</code>
- * (which have an upward facing button for decrementing the value
- * and a downward facing buttons for incrementing it).
- * </p><p>
- * On some platforms, the size of the slider's thumb can be
- * varied relative to the magnitude of the range of values it
- * represents (that is, relative to the difference between its
- * maximum and minimum values). Typically, this is used to
- * indicate some proportional value such as the ratio of the
- * visible area of a document to the total amount of space that
- * it would take to display it. SWT supports setting the thumb
- * size even if the underlying platform does not, but in this
- * case the appearance of the slider will not change.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see ScrollBar
- * @see <a href="http://www.eclipse.org/swt/snippets/#slider">Slider snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Slider extends Control {
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#HORIZONTAL
- * @see SWT#VERTICAL
- * @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);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the user changes the receiver's value, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
- * <code>SWT.NONE</code> - for the end of a drag.
- * <code>SWT.DRAG</code>.
- * <code>SWT.HOME</code>.
- * <code>SWT.END</code>.
- * <code>SWT.ARROW_DOWN</code>.
- * <code>SWT.ARROW_UP</code>.
- * <code>SWT.PAGE_DOWN</code>.
- * <code>SWT.PAGE_UP</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified when the user changes the receiver's value
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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();
- 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;
- int clazz = display.PtScrollbar;
- int parentHandle = parent.parentingHandle ();
- int [] args = {
- OS.Pt_ARG_MAXIMUM, 99, 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 () {
- return display.GAUGE_FONT;
-}
-
-/**
- * Returns the amount that the receiver's value will be
- * modified by when the up/down (or right/left) arrows
- * are pressed.
- *
- * @return the increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getIncrement () {
- checkWidget();
- 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.
- *
- * @return the minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMinimum () {
- checkWidget();
- 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.
- *
- * @return the maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1] + 1;
-}
-
-/**
- * Returns the amount that the receiver's value will be
- * modified by when the page increment/decrement areas
- * are selected.
- *
- * @return the page increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 'selection', which is the receiver's value.
- *
- * @return the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelection () {
- checkWidget();
- 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.
- *
- * @return the thumb value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getThumb () {
- checkWidget();
- 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 = display.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 user changes the receiver's value.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Sets the amount that the receiver's value will be
- * modified by when the up/down (or right/left) arrows
- * are pressed to the argument, which must be at least
- * one.
- *
- * @param value the new increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
-/**
- * Sets the maximum. If this value is negative or less than or
- * equal to the minimum, the value is ignored. If necessary, first
- * the thumb and then the selection are adjusted to fit within the
- * new range.
- *
- * @param value the new maximum, which must be greater than the current minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMaximum (int value) {
- checkWidget();
- int [] args = {
- OS.Pt_ARG_MAXIMUM, 0, 0,
- OS.Pt_ARG_MINIMUM, 0, 0,
- OS.Pt_ARG_SLIDER_SIZE, 0, 0,
- OS.Pt_ARG_GAUGE_VALUE, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int minimum = args [4];
- if (value <= minimum) return;
- int thumb = args [7];
- thumb = Math.min (thumb, value - minimum);
- int selection = args [10];
- selection = Math.min (selection, value - thumb);
- args [1] = value - 1;
- args [7] = thumb;
- args [10] = selection;
- OS.PtSetResources (handle, args.length / 3, args);
-}
-
-/**
- * Sets the minimum value. If this value is negative or greater
- * than or equal to the maximum, the value is ignored. If necessary,
- * first the thumb and then the selection are adjusted to fit within
- * the new range.
- *
- * @param value the new minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMinimum (int value) {
- checkWidget();
- if (value < 0) return;
- int [] args = {
- OS.Pt_ARG_MAXIMUM, 0, 0,
- OS.Pt_ARG_MINIMUM, 0, 0,
- OS.Pt_ARG_SLIDER_SIZE, 0, 0,
- OS.Pt_ARG_GAUGE_VALUE, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int maximum = args [1] + 1;
- if (value >= maximum) return;
- int thumb = args [7];
- thumb = Math.min (thumb, maximum - value);
- int selection = args [10];
- selection = Math.max (selection, value);
- args [4] = value;
- args [7] = thumb;
- args [10] = selection;
- OS.PtSetResources (handle, args.length / 3, args);
-}
-
-/**
- * Sets the amount that the receiver's value will be
- * modified by when the page increment/decrement areas
- * are selected to the argument, which must be at least
- * one.
- *
- * @param value the page increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
-/**
- * Sets the 'selection', which is the receiver's
- * value, to the argument which must be greater than or equal
- * to zero.
- *
- * @param value the new selection (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int value) {
- checkWidget();
- 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. This new
- * value will be ignored if it is less than one, and will be
- * clamped if it exceeds the receiver's current range.
- *
- * @param value the new thumb value, which must be at least one and not
- * larger than the size of the current range
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setThumb (int value) {
- checkWidget();
- if (value < 1) return;
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0, OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int minimum = args [1];
- int maximum = args [4] + 1;
- value = Math.min (value, maximum - minimum);
- 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.
- * <p>
- * Note: This is similar to setting the values individually
- * using the appropriate methods, but may be implemented in a
- * more efficient fashion on some platforms.
- * </p>
- *
- * @param selection the new selection value
- * @param minimum the new minimum value
- * @param maximum the new maximum value
- * @param thumb the new thumb value
- * @param increment the new increment value
- * @param pageIncrement the new pageIncrement value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
- checkWidget();
- if (minimum < 0) return;
- if (maximum < 0) return;
- if (thumb < 1) return;
- if (increment < 1) return;
- if (pageIncrement < 1) return;
- thumb = Math.min (thumb, maximum - minimum);
- int [] args = {
- OS.Pt_ARG_MAXIMUM, maximum - 1, 0,
- OS.Pt_ARG_MINIMUM, minimum, 0,
- OS.Pt_ARG_SLIDER_SIZE, thumb, 0,
- OS.Pt_ARG_GAUGE_VALUE, selection, 0,
- OS.Pt_ARG_INCREMENT, increment, 0,
- OS.Pt_ARG_PAGE_INCREMENT, pageIncrement, 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/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Spinner.java
deleted file mode 100644
index e8e5d1ad1a..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Spinner.java
+++ /dev/null
@@ -1,824 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.*;
-
-/**
- * Instances of this class are selectable user interface
- * objects that allow the user to enter and modify numeric
- * values.
- * <p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add children to it, or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>READ_ONLY, WRAP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, Modify, Verify</dd>
- * </dl>
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#spinner">Spinner snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
- * @since 3.1
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Spinner extends Composite {
- /**
- * the operating system limit for the number of characters
- * that the text field in an instance of this class can hold
- *
- * @since 3.4
- */
- 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 = 0x7FFF;
- }
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#READ_ONLY
- * @see SWT#WRAP
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Spinner (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- /*
- * Even though it is legal to create this widget
- * with scroll bars, they serve no useful purpose
- * because they do not automatically scroll the
- * widget's client area. The fix is to clear
- * the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- int parentHandle = parent.parentingHandle ();
- boolean hasBorder = (style & SWT.BORDER) != 0;
- int textFlags = (style & SWT.READ_ONLY) != 0 ? 0 : OS.Pt_EDITABLE;
- boolean wrap = (style & SWT.WRAP) != 0;
- int [] args = new int [] {
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- OS.Pt_ARG_NUMERIC_INCREMENT, 1, 0,
- OS.Pt_ARG_NUMERIC_MIN, 0, 0,
- OS.Pt_ARG_NUMERIC_MAX, 100, 0,
- OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
- OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_NUMERIC_FLAGS, wrap ? OS.Pt_NUMERIC_WRAP : 0, OS.Pt_NUMERIC_WRAP,
- };
- handle = OS.PtCreateWidget (display.PtNumericInteger, parentHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
- */
-public void addModifyListener (ModifyListener listener) {
- checkWidget ();
- if (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 the user, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is not called for texts.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text.
- * </p>
- *
- * @param listener the listener which should be notified when the control is selected by the user
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- 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
- * it one of the messages defined in the <code>VerifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VerifyListener
- * @see #removeVerifyListener
- */
-void addVerifyListener (VerifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Verify, typedListener);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget ();
- int [] args = new int [] {
- OS.Pt_ARG_TEXT_FONT, 0, 0,
- OS.Pt_ARG_NUMERIC_MAX, 0, 0,
- OS.Pt_ARG_NUMERIC_UPDOWN_WIDTH, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int width = wHint;
- int height = hHint;
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- int ptr = args [1];
- int length = OS.strlen (ptr);
- byte [] font = new byte [length + 1];
- OS.memmove (font, ptr, length);
- String string = String.valueOf (args [4]);
- PhRect_t rect = new PhRect_t ();
- int size = string.length ();
- char [] buffer = new char [size];
- string.getChars (0, size, buffer, 0);
- OS.PfExtentWideText (rect, null, font, buffer, size * 2);
- if (wHint == SWT.DEFAULT) width = rect.lr_x - rect.ul_x + 1;
- if (hHint == SWT.DEFAULT) height = rect.lr_y - rect.ul_y + 1;
- }
- Rectangle trim = computeTrim (0, 0, width, height);
- if (hHint == SWT.DEFAULT) {
- trim.height = Math.max (trim.height, args [7] * 2);
- }
- return new Point (trim.width, trim.height);
-}
-
-public Rectangle computeTrim(int x, int y, int width, int height) {
- int border = getBorderWidth ();
- x -= border;
- y -= border;
- width += 2 * border;
- height += 2 * border;
- int [] args = new int [] {
- OS.Pt_ARG_NUMERIC_SPACING, 0, 0, // 1
- OS.Pt_ARG_NUMERIC_UPDOWN_WIDTH, 0, 0, // 4
-// OS.Pt_ARG_NUMERIC_TEXT_BORDER, 0, 0, // 7
- };
- OS.PtGetResources (handle, args.length / 3, args);
-
- /*
- * Note: Pt_ARG_NUMERIC_TEXT_BORDER is defined in the
- * documentation (default value 2) but is not defined
- * in the include files on QNX 6.2.1.
- */
- int textBorder = 2;
- width += args [1] + args [4] + 2 * textBorder;
- height += 2 * textBorder;
- int textHandle = OS.PtWidgetChildBack (handle);
- args = 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.Pt_ARG_TEXT_CURSOR_WIDTH, 0, 0, // 10
- };
- OS.PtGetResources (textHandle, args.length / 3, args);
- width += args [1] + args [4] + args [7] + args [10];
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Copies the selected text.
- * <p>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void copy () {
- checkWidget ();
- int textHandle = OS.PtWidgetChildBack (handle);
- if (textHandle != 0) {
- int [] start = new int [1], end = new int [1];
- int length = OS.PtTextGetSelection (textHandle, start, end);
- if (length <= 0) return;
- int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
- OS.PtGetResources (textHandle, 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 SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void cut () {
- checkWidget ();
- if ((style & SWT.READ_ONLY) != 0) return;
- int textHandle = OS.PtWidgetChildBack (handle);
- if (textHandle != 0) {
- int [] start = new int [1], end = new int [1];
- int length = OS.PtTextGetSelection (textHandle, start, end);
- if (length <= 0) return;
- int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
- OS.PtGetResources (textHandle, 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 (textHandle, start [0], end [0], start [0], buffer, buffer.length);
- }
-}
-
-void deregister () {
- super.deregister ();
- int textHandle = OS.PtWidgetChildBack (handle);
- WidgetTable.remove (textHandle);
-}
-
-int defaultBackground () {
- return display.TEXT_BACKGROUND;
-}
-
-int defaultForeground () {
- return display.TEXT_FOREGROUND;
-}
-
-/**
- * Returns the number of decimal places used by the receiver.
- *
- * @return the digits
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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 getDigits () {
- checkWidget ();
- return 0;
-}
-
-/**
- * Returns the amount that the receiver's value will be
- * modified by when the up/down arrows are pressed.
- *
- * @return the increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getIncrement () {
- checkWidget ();
- int [] args = {OS.Pt_ARG_NUMERIC_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns the maximum value which the receiver will allow.
- *
- * @return the maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMaximum () {
- checkWidget ();
- int [] args = {OS.Pt_ARG_NUMERIC_MAX, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns the minimum value which the receiver will allow.
- *
- * @return the minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getMinimum () {
- checkWidget ();
- int [] args = {OS.Pt_ARG_NUMERIC_MIN, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns the amount that the receiver's position will be
- * modified by when the page up/down keys are pressed.
- *
- * @return the page increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getPageIncrement () {
- checkWidget ();
- return 0;
-}
-
-/**
- * Returns the <em>selection</em>, which is the receiver's position.
- *
- * @return the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelection () {
- checkWidget ();
- int [] args = {OS.Pt_ARG_NUMERIC_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns a string containing a copy of the contents of the
- * receiver's text field, or an empty string if there are no
- * contents.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public String getText () {
- checkWidget ();
- return "";
-}
-
-/**
- * Returns the maximum number of characters that the receiver's
- * text field is capable of holding. If this has not been changed
- * by <code>setTextLimit()</code>, it will be the constant
- * <code>Spinner.LIMIT</code>.
- *
- * @return the text limit
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #LIMIT
- *
- * @since 3.4
- */
-public int getTextLimit () {
- checkWidget ();
- return LIMIT;
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) != 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = display.windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_NUMERIC_CHANGED, windowProc, OS.Pt_CB_NUMERIC_CHANGED);
-}
-
-/**
- * Pastes text from clipboard.
- * <p>
- * The selected text is deleted from the widget
- * and new text inserted from the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void paste () {
- checkWidget ();
- if ((style & SWT.READ_ONLY) != 0) return;
- int textHandle = OS.PtWidgetChildBack (handle);
- if (textHandle != 0) {
- 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 (textHandle, start, end);
- if (start [0] == -1) {
- int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
- OS.PtGetResources (textHandle, args.length / 3, args);
- start [0] = end [0] = args [1];
- }
- OS.PtTextModifyText (textHandle, start [0], end [0], end [0], ptr, length);
- OS.free(ptr);
- }
-}
-
-int Pt_CB_NUMERIC_CHANGED (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;
- switch (cbinfo.reason_subtype) {
- case OS.Pt_NUMERIC_CHANGED:
- sendEvent (SWT.Modify);
- break;
- case OS.Pt_NUMERIC_UPDOWN_ACTIVATE:
- case OS.Pt_NUMERIC_UPDOWN_REPEAT:
- sendEvent (SWT.Selection);
- break;
- }
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
- int textHandle = OS.PtWidgetChildBack (handle);
- WidgetTable.put (textHandle, this);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's text is modified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #addModifyListener
- */
-public void removeModifyListener (ModifyListener listener) {
- checkWidget ();
- if (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 by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is verified.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VerifyListener
- * @see #addVerifyListener
- */
-void removeVerifyListener (VerifyListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Verify, listener);
-}
-
-/**
- * Sets the number of decimal places used by the receiver.
- * <p>
- * The digit setting is used to allow for floating point values in the receiver.
- * For example, to set the selection to a floating point value of 1.37 call setDigits() with
- * a value of 2 and setSelection() with a value of 137. Similarly, if getDigits() has a value
- * of 2 and getSelection() returns 137 this should be interpreted as 1.37. This applies to all
- * numeric APIs.
- * </p>
- *
- * @param value the new digits (must be greater than or equal to zero)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the value is less than zero</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDigits (int value) {
- checkWidget ();
-}
-
-/**
- * Sets the amount that the receiver's value will be
- * modified by when the up/down arrows are pressed to
- * the argument, which must be at least one.
- *
- * @param value the new increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setIncrement (int value) {
- checkWidget ();
- if (value < 1) return;
- OS.PtSetResource (handle, OS.Pt_ARG_NUMERIC_INCREMENT, value, 0);
-}
-
-/**
- * Sets the maximum value that the receiver will allow. This new
- * value will be ignored if it is not greater than the receiver's current
- * minimum value. If the new maximum is applied then the receiver's
- * selection value will be adjusted if necessary to fall within its new range.
- *
- * @param value the new maximum, which must be greater than the current minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMaximum (int value) {
- checkWidget ();
- if (value < 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_NUMERIC_MAX, value, 0);
-}
-
-/**
- * Sets the minimum value that the receiver will allow. This new
- * value will be ignored if it is not less than the receiver's
- * current maximum value. If the new minimum is applied then the receiver's
- * selection value will be adjusted if necessary to fall within its new range.
- *
- * @param value the new minimum, which must be less than the current maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMinimum (int value) {
- checkWidget ();
- if (value < 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_NUMERIC_MIN, value, 0);
-}
-
-/**
- * Sets the amount that the receiver's position will be
- * modified by when the page up/down keys are pressed
- * to the argument, which must be at least one.
- *
- * @param value the page increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setPageIncrement (int value) {
- checkWidget ();
- if (value < 1) return;
-}
-
-/**
- * Sets the <em>selection</em>, which is the receiver's
- * position, to the argument. If the argument is not within
- * the range specified by minimum and maximum, it will be
- * adjusted to fall within this range.
- *
- * @param value the new selection (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int value) {
- checkWidget ();
- OS.PtSetResource (handle, OS.Pt_ARG_NUMERIC_VALUE, value, 0);
-}
-
-/**
- * Sets the maximum number of characters that the receiver's
- * text field is capable of holding to be the argument.
- * <p>
- * To reset this value to the default, use <code>setTextLimit(Spinner.LIMIT)</code>.
- * Specifying a limit value larger than <code>Spinner.LIMIT</code> sets the
- * receiver's limit to <code>Spinner.LIMIT</code>.
- * </p>
- * @param limit new text limit
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #LIMIT
- *
- * @since 3.4
- */
-public void setTextLimit (int limit) {
- checkWidget ();
- if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
-}
-
-/**
- * Sets the receiver's selection, minimum value, maximum
- * value, digits, increment and page increment all at once.
- * <p>
- * Note: This is similar to setting the values individually
- * using the appropriate methods, but may be implemented in a
- * more efficient fashion on some platforms.
- * </p>
- *
- * @param selection the new selection value
- * @param minimum the new minimum value
- * @param maximum the new maximum value
- * @param digits the new digits value
- * @param increment the new increment value
- * @param pageIncrement the new pageIncrement value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.2
- */
-public void setValues (int selection, int minimum, int maximum, int digits, int increment, int pageIncrement) {
- checkWidget ();
- if (minimum < 0) return;
- if (maximum <= minimum) return;
- if (digits < 0) return;
- if (increment < 1) return;
- if (pageIncrement < 1) return;
- selection = Math.min (Math.max (minimum, selection), maximum);
- int [] args = new int [] {
- OS.Pt_ARG_NUMERIC_INCREMENT, increment, 0,
- OS.Pt_ARG_NUMERIC_MIN, minimum, 0,
- OS.Pt_ARG_NUMERIC_MAX, maximum, 0,
- OS.Pt_ARG_NUMERIC_VALUE, selection, 0
- };
- OS.PtSetResources (handle, args.length / 3, args);
-}
-
-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.PtNumericInteger ();
-}
-
-}
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
deleted file mode 100755
index 35c64ff915..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
+++ /dev/null
@@ -1,756 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.widgets.TabItem;
-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
- * set of pages.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TabItem</code>.
- * <code>Control</code> children are created and then set into a
- * tab item using <code>TabItem#setControl</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>TOP, BOTTOM</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles TOP and BOTTOM may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#tabfolder">TabFolder, TabItem snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see SWT#TOP
- * @see SWT#BOTTOM
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TabFolder (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style = checkBits (style, SWT.TOP, SWT.BOTTOM, 0, 0, 0, 0);
- /*
- * 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 user changes the receiver's selection, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified when the user changes the receiver's selection
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- 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) {
- changed |= (state & LAYOUT_CHANGED) != 0;
- size = layout.computeSize (this, wHint, hHint, changed);
- state &= ~LAYOUT_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;
- if ((style & SWT.BOTTOM) != 0) {
- trimY = y - args [4];
- } else {
- 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;
- 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,
- OS.Pt_ARG_PG_FLAGS, (style & SWT.BOTTOM) != 0 ? OS.Pt_PG_SELECTOR_ON_BOTTOM : 0, OS.Pt_PG_SELECTOR_ON_BOTTOM,
- };
- 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);
- OS.memset(str [0], 0, 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);
-
- int args[] = {
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0,
- OS.Pt_ARG_MARGIN_BOTTOM, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
-
- PhArea_t parentArea = new PhArea_t();
- OS.PtWidgetArea(handle, parentArea);
- int deltaX = area.pos_x - parentArea.pos_x;
- int deltaY = area.pos_y - parentArea.pos_y;
- area.size_w = (short) (parentArea.size_w - ( deltaX + args[1]));
- area.size_h = (short) (parentArea.size_h - ( deltaY + args [4]));
-
- 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.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TabItem getItem (int index) {
- checkWidget();
- if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
- return items [index];
-}
-
-/**
- * Returns the tab item at the given point in the receiver
- * or null if no such item exists. The point is in the
- * coordinate system of the receiver.
- *
- * @param point the point used to locate the item
- * @return the tab item at the given point, or null if the point is not in a tab item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public TabItem getItem (Point point) {
- checkWidget();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int index = 0; index < itemCount; index++) {
- TabItem item = items[index];
- Rectangle bounds = item.getBounds();
- if (bounds.contains(point)) return item;
- }
- return null;
-}
-
-/**
- * Returns an array of <code>TabItem</code>s which are the items
- * in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TabItem [] getItems () {
- 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.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget();
- return itemCount;
-}
-
-/**
- * Returns an array of <code>TabItem</code>s that are currently
- * selected in the receiver. An empty array indicates that no
- * items are selected.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its selection, so modifying the array will
- * not affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TabItem [] getSelection () {
- 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.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionIndex () {
- checkWidget();
- 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 = display.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
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param item the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (TabItem item) {
- 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 releaseChildren (boolean destroy) {
- if (items != null) {
- for (int i=0; i<itemCount; i++) {
- TabItem item = items [i];
- if (item != null && !item.isDisposed ()) {
- item.release (false);
- }
- }
- itemCount = 0;
- items = null;
- }
- super.releaseChildren (destroy);
-}
-
-void removeControl (Control control) {
- super.removeControl (control);
- for (int i=0; i<itemCount; i++) {
- TabItem item = items [i];
- if (item.control == control) item.setControl (null);
- }
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the user changes the receiver's selection.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (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.
- * The current selection is first cleared, then the new items are
- * selected. Indices that are out of range are ignored.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int index) {
- checkWidget();
- if (!(0 <= index && index < itemCount)) return;
- 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 the given item.
- * The current selected is first cleared, then the new item is
- * selected.
- *
- * @param item the item to select
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.2
- */
-public void setSelection (TabItem item) {
- checkWidget ();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSelection (new TabItem [] {item});
-}
-
-/**
- * Sets the receiver's selection to be the given array of items.
- * The current selected is first cleared, then the new items are
- * selected.
- *
- * @param items the array of items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (TabItem [] items) {
- checkWidget();
- if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (items.length == 0) {
- setSelection (-1, false);
- } else {
- for (int i=items.length-1; i>=0; --i) {
- int index = indexOf (items [i]);
- if (index != -1) setSelection (index, false);
- }
- }
-}
-
-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
deleted file mode 100755
index dc914c6ac4..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#tabfolder">TabFolder, TabItem snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TabItem (TabFolder parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>TabFolder</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the zero-relative index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TabItem (TabFolder parent, int style, int index) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, index);
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-void destroyWidget () {
- parent.destroyItem (this);
- releaseHandle ();
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 3.4
- */
-public Rectangle getBounds() {
- //TODO: Need to provide implementation for photon.
- checkWidget();
- return new Rectangle (0, 0, 0, 0);
-}
-
-/**
- * Returns the control that is used to fill the client area of
- * the tab folder when the user selects the tab item. If no
- * control has been set, return <code>null</code>.
- * <p>
- * @return the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Control getControl () {
- checkWidget();
- return control;
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>TabFolder</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TabFolder getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns the receiver's tool tip text, or null if it has
- * not been set.
- *
- * @return the receiver's tool tip text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- parent = null;
-}
-
-void releaseParent () {
- super.releaseParent ();
- int index = parent.indexOf (this);
- if (index == parent.getSelectionIndex ()) {
- if (control != null) control.setVisible (false);
- }
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- control = 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.
- * <p>
- * @param control the new control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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), selectionIndex = parent.getSelectionIndex();
- if (index != selectionIndex) {
- if (newControl != null) {
- if (selectionIndex != -1) {
- Control selectedControl = parent.getItem(selectionIndex).getControl();
- if (selectedControl == newControl) return;
- }
- 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
-}
-
-/**
- * Sets the receiver's text. The string may include
- * the mnemonic character.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp;' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&amp;' can be
- * escaped by doubling it in the string, causing a single
- * '&amp;' to be displayed.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
- fixMnemonic (text);
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- 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];
- 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 the default tool tip for the
- * control will be shown. For a control that has a default
- * tool tip, such as the Tree control on Windows, setting
- * the tool tip text to an empty string replaces the default,
- * causing no tool tip text to be shown.
- * <p>
- * The mnemonic indicator (character '&amp;') is not displayed in a tool tip.
- * To display a single '&amp;' in the tool tip, the character '&amp;' can be
- * escaped by doubling it in the string.
- * </p>
- *
- * @param string the new tool tip text (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setToolTipText (String string) {
- checkWidget();
- 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
deleted file mode 100755
index 4fdf962a41..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
+++ /dev/null
@@ -1,1615 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * Text controls can be either single or multi-line.
- * When a text control is created with a border, the
- * operating system includes a platform specific inset
- * around the contents of the control. When created
- * without a border, an effort is made to remove the
- * inset such that the preferred size of the control
- * is the same size as the contents.
- * <p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>CENTER, ICON_CANCEL, ICON_SEARCH, LEFT, MULTI, PASSWORD, SEARCH, SINGLE, RIGHT, READ_ONLY, WRAP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>DefaultSelection, Modify, Verify</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles MULTI and SINGLE may be specified,
- * and only one of the styles LEFT, CENTER, and RIGHT may be specified.
- * </p>
- * <p>
- * Note: The styles ICON_CANCEL and ICON_SEARCH are hints used in combination with SEARCH.
- * When the platform supports the hint, the text control shows these icons. When an icon
- * is selected, a default selection event is sent with the detail field set to one of
- * ICON_CANCEL or ICON_SEARCH. Normally, application code does not need to check the
- * detail. In the case of ICON_CANCEL, the text is cleared before the default selection
- * event is sent causing the application to search for an empty string.
- * </p>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#text">Text snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Text extends Scrollable {
- char echoCharacter;
- boolean ignoreChange;
- String hiddenText, message;
- int tabs, lastModifiedText;
- PtTextCallback_t textVerify;
-
- /**
- * The maximum number of characters that can be entered
- * into a text widget.
- * <p>
- * Note that this value is platform dependent, based upon
- * the native widget implementation.
- * </p>
- */
- public static final int LIMIT;
- /**
- * The delimiter used by multi-line text widgets. When text
- * is queried and from the widget, it will be delimited using
- * this delimiter.
- */
- public static final String DELIMITER;
- static final char PASSWORD = '*';
- /*
- * 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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#SINGLE
- * @see SWT#MULTI
- * @see SWT#READ_ONLY
- * @see SWT#WRAP
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see SWT#PASSWORD
- * @see SWT#SEARCH
- * @see SWT#ICON_SEARCH
- * @see SWT#ICON_CANCEL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Text (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- if ((style & SWT.SEARCH) != 0) {
- style |= SWT.SINGLE | SWT.BORDER;
- style &= ~SWT.PASSWORD;
- }
- style &= ~SWT.SEARCH;
- if ((style & SWT.SINGLE) != 0 && (style & SWT.MULTI) != 0) {
- style &= ~SWT.MULTI;
- }
- 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;
- style &= ~SWT.H_SCROLL;
- }
- if ((style & SWT.MULTI) != 0) style &= ~SWT.PASSWORD;
- 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.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void clearSelection () {
- checkWidget();
- 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;
- 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);
- hiddenText = message = "";
- if ((style & SWT.PASSWORD) != 0) setEchoChar (PASSWORD);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's text is modified, by sending
- * it one of the messages defined in the <code>ModifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #removeModifyListener
- */
-public void addModifyListener (ModifyListener listener) {
- checkWidget();
- if (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 the user, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is not called for texts.
- * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text,
- * or when ENTER is pressed in a search text. If the receiver has the <code>SWT.SEARCH | SWT.CANCEL</code> style
- * and the user cancels the search, the event object detail field contains the value <code>SWT.CANCEL</code>.
- * </p>
- *
- * @param listener the listener which should be notified when the control is selected by the user
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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
- * it one of the messages defined in the <code>VerifyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see VerifyListener
- * @see #removeVerifyListener
- */
-public void addVerifyListener (VerifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Verify, typedListener);
-}
-
-/**
- * Appends a string.
- * <p>
- * The new text is appended to the text at
- * the end of the widget.
- * </p>
- *
- * @param string the string to be appended
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void copy () {
- checkWidget();
- 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 SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void cut () {
- checkWidget();
- 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 () {
- return display.TEXT_BACKGROUND;
-}
-
-int defaultForeground () {
- return display.TEXT_FOREGROUND;
-}
-
-/**
- * Returns the line number of the caret.
- * <p>
- * The line number of the caret is returned.
- * </p>
- *
- * @return the line number
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getCaretLineNumber () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
-/**
- * Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null).
- * <p>
- * The location of the caret is returned.
- * </p>
- *
- * @return a point, the location of the caret
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getCaretLocation () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return null;
-}
-
-/**
- * Returns the character position of the caret.
- * <p>
- * Indexing is zero based.
- * </p>
- *
- * @return the position of the caret
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getCaretPosition () {
- checkWidget();
- int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns the number of characters.
- *
- * @return number of characters in the widget
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getCharCount () {
- checkWidget();
- 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]);
-}
-
-/**
- * Returns the double click enabled flag.
- * <p>
- * The double click flag enables or disables the
- * default action of the text widget when the user
- * double clicks.
- * </p>
- *
- * @return whether or not double click is enabled
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getDoubleClickEnabled () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return false;
-}
-
-/**
- * Returns the echo character.
- * <p>
- * The echo character is the character that is
- * displayed when the user enters text or the
- * text is changed by the programmer.
- * </p>
- *
- * @return the echo character
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setEchoChar
- */
-public char getEchoChar () {
- checkWidget();
- return echoCharacter;
-}
-
-/**
- * Returns the editable state.
- *
- * @return whether or not the receiver is editable
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getEditable () {
- checkWidget();
- int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};
- OS.PtGetResources(handle, args.length / 3, args);
- return (args [1] & OS.Pt_EDITABLE) != 0;
-}
-
-/**
- * Returns the number of lines.
- *
- * @return the number of lines in the widget
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getLineCount () {
- checkWidget();
- if ((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];
-}
-
-/**
- * Returns the line delimiter.
- *
- * @return a string that is the line delimiter
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #DELIMITER
- */
-public String getLineDelimiter () {
- checkWidget();
- return "\n";
-}
-
-/**
- * Returns the height of a line.
- *
- * @return the height of a row of text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getLineHeight () {
- checkWidget();
- if ((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];
-}
-
-/**
- * Returns the widget message. The message text is displayed
- * as a hint for the user, indicating the purpose of the field.
- * <p>
- * Typically this is used in conjunction with <code>SWT.SEARCH</code>.
- * </p>
- *
- * @return the widget message
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.3
- */
-public String getMessage () {
- checkWidget ();
- return message;
-}
-
-String getNameText () {
- if ((style & SWT.SINGLE) != 0) return getText ();
- return getText (0, Math.min(getCharCount () - 1, 10));
-}
-
-/**
- * Returns the orientation of the receiver, which will be one of the
- * constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
- *
- * @return the orientation style
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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.2
- */
-public int getOrientation () {
- checkWidget();
- return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
-}
-
-/**
- * Returns a <code>Point</code> whose x coordinate is the
- * character position representing the start of the selected
- * text, and whose y coordinate is the character position
- * representing the end of the selection. An "empty" selection
- * is indicated by the x and y coordinates having the same value.
- * <p>
- * Indexing is zero based. The range of a selection is from
- * 0..N where N is the number of characters in the widget.
- * </p>
- *
- * @return a point representing the selection start and end
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Point getSelection () {
- checkWidget();
- if (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 number of selected characters.
- *
- * @return the number of selected characters.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionCount () {
- checkWidget();
- Point selection = getSelection ();
- return selection.y - selection.x;
-}
-
-/**
- * Gets the selected text, or an empty string if there is no current selection.
- *
- * @return the selected text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getSelectionText () {
- checkWidget();
- /*
- * NOTE: The current implementation uses substring ()
- * which can reference a potentially large character
- * array.
- */
- Point selection = getSelection ();
- return getText ().substring (selection.x, selection.y);
-}
-
-/**
- * Returns the number of tabs.
- * <p>
- * Tab stop spacing is specified in terms of the
- * space (' ') character. The width of a single
- * tab stop is the pixel width of the spaces.
- * </p>
- *
- * @return the number of tab characters
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTabs () {
- checkWidget();
- 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;
-}
-
-/**
- * Returns a range of text. Returns an empty string if the
- * start of the range is greater than the end.
- * <p>
- * Indexing is zero based. The range of
- * a selection is from 0..N-1 where N is
- * the number of characters in the widget.
- * </p>
- *
- * @param start the start of the range
- * @param end the end of the range
- * @return the range of text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText (int start, int end) {
- checkWidget ();
- if (!(start <= end && 0 <= end)) return "";
- String text = getText ();
- int length = text.length ();
- end = Math.min (end, length - 1);
- if (start > end) return "";
- start = Math.max (0, start);
- /*
- * NOTE: The current implementation uses substring ()
- * which can reference a potentially large character
- * array.
- */
- //NOT DONE - use OS in SINGLE text
- return text.substring (start, end + 1);
-}
-
-/**
- * Returns the widget text.
- * <p>
- * The text for a text widget is the characters in the widget, or
- * an empty string if this has never been set.
- * </p>
- *
- * @return the widget text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getText () {
- checkWidget();
- if (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>
- * If this has not been changed by <code>setTextLimit()</code>,
- * it will be the constant <code>Text.LIMIT</code>.
- * </p>
- *
- * @return the text limit
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #LIMIT
- */
-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.
- * <p>
- * This index can change when lines are scrolled or new lines are added or removed.
- * </p>
- *
- * @return the index of the top line
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTopIndex () {
- checkWidget();
- if ((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;
-}
-
-/**
- * Returns the top pixel.
- * <p>
- * The top pixel is the pixel position of the line
- * that is currently at the top of the widget. On
- * some platforms, a text widget can be scrolled by
- * pixels instead of lines so that a partial line
- * is displayed at the top of the widget.
- * </p><p>
- * The top pixel changes when the widget is scrolled.
- * The top pixel does not include the widget trimming.
- * </p>
- *
- * @return the pixel position of the top line
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getTopPixel () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = display.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>
- * The old selection is replaced with the new text.
- * </p>
- *
- * @param string the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is <code>null</code></li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void insert (String string) {
- checkWidget();
- if (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>
- * The selected text is deleted from the widget
- * and new text inserted from the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void paste () {
- checkWidget();
- 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 Ph_EV_BOUNDARY (int widget, int info) {
- /*
- * Bug in Photon. PtMultiText reports boundary events for
- * the internal (hidden) child widget. This makes it appear as
- * though the pointer leaves as soon as it enters the widget
- * area. The fix is to filter out these theser events.
- */
- if ((style & SWT.MULTI) != 0) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_END;
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- switch ((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);
-}
-
-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, SWT.Verify, 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, 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 = message = null;
- textVerify = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's text is modified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ModifyListener
- * @see #addModifyListener
- */
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (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 by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is verified.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-/**
- * Selects all the text in the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void selectAll () {
- checkWidget();
- OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0x7FFFFFFF});
-}
-
-/**
- * Sets the echo character.
- * <p>
- * The echo character is the character that is
- * displayed when the user enters text or the
- * text is changed by the programmer. Setting
- * the echo character to '\0' clears the echo
- * character and redraws the original text.
- * If for any reason the echo character is invalid,
- * or if the platform does not allow modification
- * of the echo character, the default echo character
- * for the platform is used.
- * </p>
- *
- * @param echo the new echo character
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEchoChar (char echo) {
- checkWidget();
- if ((style & SWT.MULTI) != 0) return;
- if (echoCharacter == echo) return;
- String newText;
- if (echo == 0) {
- newText = hiddenText;
- hiddenText = "";
- } 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>
- * The double click flag enables or disables the
- * default action of the text widget when the user
- * double clicks.
- * </p><p>
- * Note: This operation is a hint and is not supported on
- * platforms that do not have this concept.
- * </p>
- *
- * @param doubleClick the new double click flag
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setDoubleClickEnabled (boolean doubleClick) {
- checkWidget();
- //NOT DONE - NOT NEEDED
-}
-
-/**
- * Sets the editable state.
- *
- * @param editable the new editable state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEditable (boolean editable) {
- checkWidget();
- 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 widget message. The message text is displayed
- * as a hint for the user, indicating the purpose of the field.
- * <p>
- * Typically this is used in conjunction with <code>SWT.SEARCH</code>.
- * </p>
- *
- * @param message the new message
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the message is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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 3.3
- */
-public void setMessage (String message) {
- checkWidget ();
- if (message == null) error (SWT.ERROR_NULL_ARGUMENT);
- this.message = message;
-}
-
-/**
- * Sets the orientation of the receiver, which must be one
- * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
- * <p>
- * Note: This operation is a hint and is not supported on
- * platforms that do not have this concept.
- * </p>
- *
- * @param orientation new orientation style
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - 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.2
- */
-public void setOrientation (int orientation) {
- checkWidget();
-}
-
-/**
- * Sets the selection.
- * <p>
- * Indexing is zero based. The range of
- * a selection is from 0..N where N is
- * the number of characters in the widget.
- * </p><p>
- * Text selections are specified in terms of
- * caret positions. In a text widget that
- * contains N characters, there are N+1 caret
- * positions, ranging from 0..N. This differs
- * from other functions that address character
- * position such as getText () that use the
- * regular array indexing rules.
- * </p>
- *
- * @param start new caret position
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int 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 to the range specified
- * by the given point, where the x coordinate
- * represents the start index and the y coordinate
- * represents the end index.
- * <p>
- * Indexing is zero based. The range of
- * a selection is from 0..N where N is
- * the number of characters in the widget.
- * </p><p>
- * Text selections are specified in terms of
- * caret positions. In a text widget that
- * contains N characters, there are N+1 caret
- * positions, ranging from 0..N. This differs
- * from other functions that address character
- * position such as getText () that use the
- * usual array indexing rules.
- * </p>
- *
- * @param selection the point
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (Point selection) {
- checkWidget();
- if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSelection (selection.x, selection.y);
-}
-
-/**
- * Sets the selection to the range specified
- * by the given start and end indices.
- * <p>
- * Indexing is zero based. The range of
- * a selection is from 0..N where N is
- * the number of characters in the widget.
- * </p><p>
- * Text selections are specified in terms of
- * caret positions. In a text widget that
- * contains N characters, there are N+1 caret
- * positions, ranging from 0..N. This differs
- * from other functions that address character
- * position such as getText () that use the
- * usual array indexing rules.
- * </p>
- *
- * @param start the start of the range
- * @param end the end of the range
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (int start, int end) {
- checkWidget();
- 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>
- * Tab stop spacing is specified in terms of the
- * space (' ') character. The width of a single
- * tab stop is the pixel width of the spaces.
- * </p>
- *
- * @param tabs the number of tabs
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTabs (int tabs) {
- checkWidget();
- if (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
- * operation is undefined and may vary from platform to platform.
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (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.
- * <p>
- * Instead of trying to set the text limit to zero, consider
- * creating a read-only text widget.
- * </p><p>
- * To reset this value to the default, use <code>setTextLimit(Text.LIMIT)</code>.
- * Specifying a limit value larger than <code>Text.LIMIT</code> sets the
- * receiver's limit to <code>Text.LIMIT</code>.
- * </p>
- *
- * @param limit new text limit
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #LIMIT
- */
-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
- * are scrolled or new lines are added and removed.
- *
- * @param index the index of the top item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setTopIndex (int index) {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0);
-}
-
-/**
- * Shows the selection.
- * <p>
- * If the selection is already showing
- * in the receiver, this method simply returns. Otherwise,
- * lines are scrolled until the selection is visible.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void showSelection () {
- checkWidget();
- //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
deleted file mode 100755
index 823bff5614..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>ToolItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>FLAT, WRAP, RIGHT, HORIZONTAL, VERTICAL, SHADOW_OUT</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#toolbar">ToolBar, ToolItem snippets</a>
- * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#FLAT
- * @see SWT#WRAP
- * @see SWT#RIGHT
- * @see SWT#HORIZONTAL
- * @see SWT#SHADOW_OUT
- * @see SWT#VERTICAL
- * @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);
-}
-
-Control [] _getChildren () {
- Control [] children = super._getChildren ();
- int count = 0;
- for (int i=0; i<itemCount; i++) {
- if (items [i].control != null) count++;
- }
- if (count == 0) return children;
- Control [] newChildren = new Control [children.length + count];
- System.arraycopy (children, 0, newChildren, 0, children.length);
- int index = children.length;
- for (int i=0; i<itemCount; i++) {
- ToolItem item = items [i];
- if (item.control != null) newChildren [index++] = item.control;
- }
- return newChildren;
-}
-
-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;
- 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.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget();
- return itemCount;
-}
-
-/**
- * Returns an array of <code>ToolItem</code>s which are the items
- * in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public ToolItem [] getItems () {
- checkWidget();
- 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.
- *
- * @param index the index of the item to return
- * @return the item at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public ToolItem getItem (int index) {
- checkWidget();
- if (!(0 <= index && index < itemCount)) 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
- * coordinate system of the receiver.
- *
- * @param point the point used to locate the item
- * @return the item at the given point
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public ToolItem getItem (Point pt) {
- checkWidget();
- if (pt == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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
- * number of rows can be greater than one. Otherwise,
- * the number of rows is always one.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getRowCount () {
- checkWidget();
- 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
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param item the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the tool item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (ToolItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- for (int i=0; i<itemCount; 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 releaseChildren (boolean destroy) {
- if (items != null) {
- for (int i=0; i<itemCount; i++) {
- ToolItem item = items [i];
- if (item != null && !item.isDisposed ()) {
- item.release (false);
- }
- }
- items = null;
- itemCount = 0;
- }
- super.releaseChildren (destroy);
-}
-
-void removeControl (Control control) {
- super.removeControl (control);
- for (int i=0; i<itemCount; i++) {
- ToolItem item = items [i];
- if (item.control == control) item.setControl (null);
- }
-}
-
-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 ();
-}
-
-}
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
deleted file mode 100755
index ee265148db..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
+++ /dev/null
@@ -1,967 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN
- * may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#toolbar">ToolBar, ToolItem snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-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
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#PUSH
- * @see SWT#CHECK
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @see SWT#DROP_DOWN
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public ToolItem (ToolBar parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>ToolBar</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the zero-relative index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#PUSH
- * @see SWT#CHECK
- * @see SWT#RADIO
- * @see SWT#SEPARATOR
- * @see SWT#DROP_DOWN
- * @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);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is selected by the user, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called when the mouse is over the arrow portion of a drop-down tool,
- * the event object detail field contains the value <code>SWT.ARROW</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified when the control is selected by the user,
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- 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);
-}
-
-void click () {
- click (handle);
-}
-
-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);
- }
-}
-
-void destroyWidget () {
- parent.destroyItem (this);
- super.destroyWidget ();
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle getBounds () {
- checkWidget();
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- int x = area.pos_x, y = area.pos_y;
- int width = area.size_w, height = area.size_h;
- /* Check if the item is scrolled */
- int child = OS.PtWidgetChildBack (parent.handle);
- if (child != 0) {
- OS.PtWidgetArea (child, area);
- x += area.pos_x;
- y += area.pos_y;
- }
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Returns the control that is used to fill the bounds of
- * the item when the item is a <code>SEPARATOR</code>.
- *
- * @return the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Control getControl () {
- checkWidget();
- return control;
-}
-
-/**
- * Returns the receiver's disabled image if it has one, or null
- * if it does not.
- * <p>
- * The disabled image is displayed when the receiver is disabled.
- * </p>
- *
- * @return the receiver's disabled image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getDisabledImage () {
- checkWidget();
- return disabledImage;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> otherwise. A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #isEnabled
- */
-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.
- * <p>
- * The hot image is displayed when the mouse enters the receiver.
- * </p>
- *
- * @return the receiver's hot image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getHotImage () {
- checkWidget();
- return hotImage;
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>ToolBar</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public ToolBar getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns <code>true</code> if the receiver is selected,
- * and false otherwise.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked (which some platforms draw as a
- * pushed in button). If the receiver is of any other type, this method
- * returns false.
- * </p>
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getSelection () {
- checkWidget();
- if ((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.
- *
- * @return the receiver's tool tip text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
-/**
- * Gets the width of the receiver.
- *
- * @return the width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 = display.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);
-}
-
-int hotkeyProc (int widget, int data, int info) {
- if (setFocus ()) click ();
- 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 () {
- 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 releaseHandle () {
- super.releaseHandle ();
- arrow = button = 0;
- parent = null;
-}
-
-void releaseWidget () {
- // reparent the control back to the toolbar
- if (control != null) setControl (null);
- super.releaseWidget ();
- if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
- if (parent.lastFocus == this) parent.lastFocus = null;
- toolTipHandle = 0;
- 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 by the user.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (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 item is a <code>SEPARATOR</code>.
- *
- * @param control the new control
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void 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 () {
- 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.
- * <p>
- * The disabled image is displayed when the receiver is disabled.
- * </p>
- *
- * @param image the disabled image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- * <p>
- * A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- * </p>
- *
- * @param enabled the new enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setEnabled (boolean enabled) {
- checkWidget ();
- 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.
- * <p>
- * The hot image is displayed when the mouse enters the receiver.
- * </p>
- *
- * @param image the hot image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked (which some platforms draw as a
- * pushed in button).
- * </p>
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setSelection (boolean selected) {
- checkWidget();
- if ((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 text. The string may include
- * the mnemonic character.
- * </p>
- * <p>
- * Mnemonics are indicated by an '&amp;' that causes the next
- * character to be the mnemonic. When the user presses a
- * key sequence that matches the mnemonic, a selection
- * event occurs. On most platforms, the mnemonic appears
- * underlined but may be emphasised in a platform specific
- * manner. The mnemonic indicator character '&amp;' can be
- * escaped by doubling it in the string, causing a single
- * '&amp;' to be displayed.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setText (string);
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
- char mnemonic = fixMnemonic (text);
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- int ptr1 = OS.malloc (buffer.length);
- OS.memmove (ptr1, 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 type = OS.Pt_Z_STRING;
- if (image != null) type = OS.Pt_TEXT_IMAGE;
- int [] args = {
- OS.Pt_ARG_TEXT_STRING, ptr1, 0,
- OS.Pt_ARG_LABEL_TYPE, type, 0,
- OS.Pt_ARG_ACCEL_KEY, ptr2, 0,
- };
- OS.PtSetResources (button, args.length / 3, args);
- OS.free (ptr1);
- OS.free (ptr2);
-
- /*
- * 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 the default tool tip for the
- * control will be shown. For a control that has a default
- * tool tip, such as the Tree control on Windows, setting
- * the tool tip text to an empty string replaces the default,
- * causing no tool tip text to be shown.
- * <p>
- * The mnemonic indicator (character '&amp;') is not displayed in a tool tip.
- * To display a single '&amp;' in the tool tip, the character '&amp;' can be
- * escaped by doubling it in the string.
- * </p>
- *
- * @param string the new tool tip text (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setToolTipText (String string) {
- checkWidget();
- toolTipText = string;
-}
-
-/**
- * Sets the width of the receiver, for <code>SEPARATOR</code> ToolItems.
- *
- * @param width the new width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setWidth (int width) {
- checkWidget();
- if ((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
deleted file mode 100755
index 0ea5d78fdc..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
+++ /dev/null
@@ -1,1057 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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>
- *
- * @see <a href="http://www.eclipse.org/swt/snippets/#tracker">Tracker snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Tracker extends Widget {
- Composite parent;
- boolean tracking, stippled;
- Rectangle [] rectangles = new Rectangle [0], proportions = rectangles;
- Rectangle bounds;
- int resizeCursor;
- Cursor clientCursor;
- 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
- * and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the tracker on the currently active
- * display if there is one. If there is no current display, the
- * tracker is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the tracker on
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#UP
- * @see SWT#DOWN
- * @see SWT#RESIZE
- */
-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.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#UP
- * @see SWT#DOWN
- * @see SWT#RESIZE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Tracker (Composite parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is moved or resized, by sending
- * it one of the messages defined in the <code>ControlListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #removeControlListener
- */
-public void addControlListener(ControlListener listener) {
- checkWidget();
- if (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 keys are pressed and released on the system keyboard, by sending
- * it one of the messages defined in the <code>KeyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #removeKeyListener
- */
-public void addKeyListener (KeyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.KeyUp,typedListener);
- addListener (SWT.KeyDown,typedListener);
-}
-
-Point adjustMoveCursor () {
- if (bounds == null) return null;
- 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 () {
- if (bounds == null) return null;
- int newX, newY;
-
- 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 == null) {
- 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 () {
- if (rectangles.length == 0) return null;
- 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];
- bounds = computeBounds ();
- if (bounds != null) {
- for (int i = 0; i < rects.length; i++) {
- int x = 0, y = 0, width = 0, height = 0;
- if (bounds.width != 0) {
- x = (rects [i].x - bounds.x) * 100 / bounds.width;
- width = rects [i].width * 100 / bounds.width;
- } else {
- width = 100;
- }
- if (bounds.height != 0) {
- y = (rects [i].y - bounds.y) * 100 / bounds.height;
- height = rects [i].height * 100 / bounds.height;
- } else {
- height = 100;
- }
- result [i] = new Rectangle (x, y, width, height);
- }
- }
- return result;
-}
-
-void drawRectangles (Rectangle [] rects, boolean stippled) {
- 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_DrawModeDSx);
- 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);
-}
-
-/**
- * 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();
- Rectangle [] result = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle current = rectangles [i];
- result [i] = new Rectangle (current.x, current.y, current.width, current.height);
- }
- return result;
-}
-
-/**
- * Returns <code>true</code> if the rectangles are drawn with a stippled line, <code>false</code> otherwise.
- *
- * @return the stippled effect of the rectangles
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getStippled () {
- checkWidget();
- return stippled;
-}
-
-void moveRectangles (int xChange, int yChange) {
- if (bounds == null) return;
- if (xChange < 0 && ((style & SWT.LEFT) == 0)) xChange = 0;
- if (xChange > 0 && ((style & SWT.RIGHT) == 0)) xChange = 0;
- if (yChange < 0 && ((style & SWT.UP) == 0)) yChange = 0;
- if (yChange > 0 && ((style & SWT.DOWN) == 0)) yChange = 0;
- if (xChange == 0 && yChange == 0) return;
- 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();
-
- 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 = info.pos_x, oldY = info.pos_y;
- int size = PhEvent_t.sizeof + 1024;
- int buffer = OS.malloc (size);
- PhEvent_t phEvent = new PhEvent_t ();
- Event event = new Event ();
-
- // if exactly one of UP/DOWN is specified as a style then set the cursor
- // orientation accordingly (the same is done for LEFT/RIGHT styles below)
- int vStyle = style & (SWT.UP | SWT.DOWN);
- if (vStyle == SWT.UP || vStyle == SWT.DOWN) {
- cursorOrientation |= vStyle;
- }
- int hStyle = style & (SWT.LEFT | SWT.RIGHT);
- if (hStyle == SWT.LEFT || hStyle == SWT.RIGHT) {
- cursorOrientation |= hStyle;
- }
-
- update ();
- drawRectangles (rectangles, stippled);
- Point cursorPos = null;
- if ((style & SWT.MENU) == 0) {
- oldX = info.pos_x;
- oldY = info.pos_y;
- } else {
- if ((style & SWT.RESIZE) != 0) {
- cursorPos = adjustResizeCursor ();
- } else {
- cursorPos = adjustMoveCursor ();
- }
- if (cursorPos != null) {
- 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) {
- Rectangle [] oldRectangles = rectangles;
- boolean oldStippled = stippled;
- Rectangle [] rectsToErase = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle current = rectangles [i];
- rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
- }
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (newX - oldX, newY - oldY);
- sendEvent (SWT.Resize, 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 ()) {
- cancelled = true;
- break;
- }
- boolean draw = false;
- /*
- * It is possible that application code could have
- * changed the rectangles in the resize event. If this
- * happens then only redraw the tracker if the rectangle
- * values have changed.
- */
- if (rectangles != oldRectangles) {
- int length = rectangles.length;
- if (length != rectsToErase.length) {
- draw = true;
- } else {
- for (int i = 0; i < length; i++) {
- if (!rectangles [i].equals (rectsToErase [i])) {
- draw = true;
- break;
- }
- }
- }
- } else {
- draw = true;
- }
- if (draw) {
- drawRectangles (rectsToErase, oldStippled);
- update ();
- drawRectangles (rectangles, stippled);
- }
- cursorPos = adjustResizeCursor ();
- if (cursorPos != null) {
- newX = cursorPos.x;
- newY = cursorPos.y;
- }
- } 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 ()) {
- cancelled = true;
- break;
- }
- boolean draw = false;
- /*
- * It is possible that application code could have
- * changed the rectangles in the move event. If this
- * happens then only redraw the tracker if the rectangle
- * values have changed.
- */
- if (rectangles != oldRectangles) {
- int length = rectangles.length;
- if (length != rectsToErase.length) {
- draw = true;
- } else {
- for (int i = 0; i < length; i++) {
- if (!rectangles [i].equals (rectsToErase [i])) {
- draw = true;
- break;
- }
- }
- }
- } else {
- draw = true;
- }
- if (draw) {
- drawRectangles (rectsToErase, oldStippled);
- update ();
- drawRectangles (rectangles, stippled);
- }
- }
- 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) {
- Rectangle [] oldRectangles = rectangles;
- boolean oldStippled = stippled;
- Rectangle [] rectsToErase = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle current = rectangles [i];
- rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
- }
- int newX = oldX + xChange;
- int newY = oldY + yChange;
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (xChange, yChange);
- sendEvent (SWT.Resize, 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 ()) {
- cancelled = true;
- break;
- }
- boolean draw = false;
- /*
- * It is possible that application code could have
- * changed the rectangles in the resize event. If this
- * happens then only redraw the tracker if the rectangle
- * values have changed.
- */
- if (rectangles != oldRectangles) {
- int length = rectangles.length;
- if (length != rectsToErase.length) {
- draw = true;
- } else {
- for (int i = 0; i < length; i++) {
- if (!rectangles [i].equals (rectsToErase [i])) {
- draw = true;
- break;
- }
- }
- }
- } else {
- draw = true;
- }
- if (draw) {
- drawRectangles (rectsToErase, oldStippled);
- update ();
- drawRectangles (rectangles, stippled);
- }
- cursorPos = adjustResizeCursor ();
- } else {
- moveRectangles (xChange, yChange);
- 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 ()) {
- cancelled = true;
- break;
- }
- boolean draw = false;
- /*
- * It is possible that application code could have
- * changed the rectangles in the move event. If this
- * happens then only redraw the tracker if the rectangle
- * values have changed.
- */
- if (rectangles != oldRectangles) {
- int length = rectangles.length;
- if (length != rectsToErase.length) {
- draw = true;
- } else {
- for (int i = 0; i < length; i++) {
- if (!rectangles [i].equals (rectsToErase [i])) {
- draw = true;
- break;
- }
- }
- }
- } else {
- draw = true;
- }
- if (draw) {
- drawRectangles (rectsToErase, oldStippled);
- update ();
- drawRectangles (rectangles, stippled);
- }
- cursorPos = adjustMoveCursor ();
- }
- if (cursorPos != null) {
- 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);
- }
- OS.free (buffer);
- if (!isDisposed ()) {
- update ();
- drawRectangles (rectangles, stippled);
- }
- tracking = false;
- if (region != 0) OS.PtDestroyWidget (region);
- return !cancelled;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
- rectangles = proportions = null;
- bounds = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is moved or resized.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #addControlListener
- */
-public void removeControlListener (ControlListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Resize, listener);
- eventTable.unhook (SWT.Move, listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when keys are pressed and released on the system keyboard.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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);
-}
-
-void resizeRectangles (int xChange, int yChange) {
- if (bounds == null) return;
- /*
- * 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;
- }
- if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
- cursorOrientation |= SWT.RIGHT;
- }
- if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
- cursorOrientation |= SWT.UP;
- }
- if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
- cursorOrientation |= SWT.DOWN;
- }
-
- /*
- * If the bounds will flip about the x or y axis then apply the adjustment
- * up to the axis (ie.- where bounds width/height becomes 0), change the
- * cursor's orientation accordingly, and flip each Rectangle's origin (only
- * necessary for > 1 Rectangles)
- */
- if ((cursorOrientation & SWT.LEFT) != 0) {
- if (xChange > bounds.width) {
- if ((style & SWT.RIGHT) == 0) return;
- cursorOrientation |= SWT.RIGHT;
- cursorOrientation &= ~SWT.LEFT;
- bounds.x += bounds.width;
- xChange -= bounds.width;
- bounds.width = 0;
- if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
- proportion.x = 100 - proportion.x - proportion.width;
- }
- }
- }
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- if (bounds.width < -xChange) {
- if ((style & SWT.LEFT) == 0) return;
- cursorOrientation |= SWT.LEFT;
- cursorOrientation &= ~SWT.RIGHT;
- xChange += bounds.width;
- bounds.width = 0;
- if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
- proportion.x = 100 - proportion.x - proportion.width;
- }
- }
- }
- }
- if ((cursorOrientation & SWT.UP) != 0) {
- if (yChange > bounds.height) {
- if ((style & SWT.DOWN) == 0) return;
- cursorOrientation |= SWT.DOWN;
- cursorOrientation &= ~SWT.UP;
- bounds.y += bounds.height;
- yChange -= bounds.height;
- bounds.height = 0;
- if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
- proportion.y = 100 - proportion.y - proportion.height;
- }
- }
- }
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- if (bounds.height < -yChange) {
- if ((style & SWT.UP) == 0) return;
- cursorOrientation |= SWT.UP;
- cursorOrientation &= ~SWT.DOWN;
- yChange += bounds.height;
- bounds.height = 0;
- if (proportions.length > 1) {
- for (int i = 0; i < proportions.length; i++) {
- Rectangle proportion = proportions [i];
- proportion.y = 100 - proportion.y - proportion.height;
- }
- }
- }
- }
-
- // apply the bounds adjustment
- 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;
- }
-
- 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();
- if (cursor != null && cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- clientCursor = cursor;
-}
-
-void setCursor (int cursorHandle) {
- if (cursorHandle == 0) return;
- int type = 0;
- int bitmap = 0;
- if (clientCursor != null) {
- type = clientCursor.type;
- bitmap = clientCursor.bitmap;
- } 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.
- *
- * @param rectangles the bounds of the rectangles to be drawn
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the set of rectangles is null or contains a null rectangle</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setRectangles (Rectangle [] rectangles) {
- checkWidget();
- if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
- this.rectangles = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle current = rectangles [i];
- if (current == null) error (SWT.ERROR_NULL_ARGUMENT);
- this.rectangles [i] = new Rectangle (current.x, current.y, current.width, current.height);
- }
- proportions = computeProportions (rectangles);
-}
-
-/**
- * Changes the appearance of the line used to draw the rectangles.
- *
- * @param stippled <code>true</code> if rectangle should appear stippled
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setStippled (boolean stippled) {
- checkWidget();
- this.stippled = stippled;
-}
-
-void update () {
- if (parent != null) {
- if (parent.isDisposed ()) return;
- parent.getShell ().update ();
- } else {
- display.update ();
- }
-}
-}
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
deleted file mode 100755
index 19b0c5f24a..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
+++ /dev/null
@@ -1,1274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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
- * when events occur which affect them.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation. However, it has not been marked
- * final to allow those outside of the SWT development team to implement
- * patched versions of the class in order to get around specific
- * limitations in advance of when those limitations can be addressed
- * by the team. Any class built using subclassing to access the internals
- * of this class will likely fail to compile or run between releases and
- * may be strongly platform specific. Subclassing should not be attempted
- * without an intimate and detailed understanding of the workings of the
- * hierarchy. No support is provided for user-written classes which are
- * implemented as subclasses of this class.
- * </p>
- *
- * @see #checkSubclass
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- */
-public abstract class Widget {
- /**
- * the handle to the resource
- * (Warning: This field is platform dependent)
- * <p>
- * <b>IMPORTANT:</b> This field 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 is not available on all
- * platforms and should never be accessed from application code.
- * </p>
- */
- public int handle;
- int style, state;
- Display display;
- EventTable eventTable;
- Object data;
-
- /* Global state flags */
- static final int DISPOSED = 1 << 0;
- static final int CANVAS = 1 << 1;
- static final int KEYED_DATA = 1 << 2;
- static final int HANDLE = 1 << 3;
- static final int DISABLED = 1 << 4;
- static final int MOVED = 1 << 5;
- static final int RESIZED = 1 << 6;
- static final int GRAB = 1 << 7;
-
- /* A layout was requested on this widget */
- static final int LAYOUT_NEEDED = 1 << 8;
-
- /* The preferred size of a child has changed */
- static final int LAYOUT_CHANGED = 1 << 9;
-
- /* A layout was requested in this widget hierachy */
- static final int LAYOUT_CHILD = 1 << 10;
-
- /* More global state flags */
- static final int RELEASED = 1<<11;
- static final int DISPOSE_SENT = 1<<12;
-
- /* Default size for widgets */
- static final int DEFAULT_WIDTH = 64;
- static final int DEFAULT_HEIGHT = 64;
-
-Widget () {
- /* Do nothing */
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a widget which will be the parent of the new instance (cannot be null)
- * @param style the style of widget to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see #checkSubclass
- * @see #getStyle
- */
-public Widget (Widget parent, int style) {
- checkSubclass ();
- checkParent (parent);
- this.style = style;
- display = parent.display;
-}
-
-static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
- int mask = int0 | int1 | int2 | int3 | int4 | int5;
- if ((style & mask) == 0) style |= int0;
- if ((style & int0) != 0) style = (style & ~mask) | int0;
- if ((style & int1) != 0) style = (style & ~mask) | int1;
- if ((style & int2) != 0) style = (style & ~mask) | int2;
- if ((style & int3) != 0) style = (style & ~mask) | int3;
- if ((style & int4) != 0) style = (style & ~mask) | int4;
- if ((style & int5) != 0) style = (style & ~mask) | int5;
- return style;
-}
-
-void 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.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- parent.checkWidget ();
-}
-
-/**
- * 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 () {
- Display display = this.display;
- if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if ((state & DISPOSED) != 0) 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 notified when an event of the given type occurs. When the
- * event does occur in the widget, the listener is notified by
- * sending it the <code>handleEvent()</code> message. The event
- * type is one of the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #getListeners(int)
- * @see #removeListener(int, Listener)
- * @see #notifyListeners
- */
-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 notified when the widget is disposed. When the widget is
- * disposed, the listener is notified by sending it the
- * <code>widgetDisposed()</code> message.
- *
- * @param listener the listener which should be notified when the receiver is disposed
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DisposeListener
- * @see #removeDisposeListener
- */
-public void addDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Dispose, typedListener);
-}
-
-void click (int widget) {
- int rid = OS.PtWidgetRid (widget);
- if (rid == 0) return;
- PhEvent_t event = new PhEvent_t ();
- event.emitter_rid = rid;
- event.emitter_handle = widget;
- event.collector_rid = rid;
- event.collector_handle = widget;
- event.flags = (short) OS.Ph_EVENT_DIRECT;
- event.processing_flags = (short) 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 = (short) 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 (widget, ptr);
- OS.PtFlush ();
- event.type = OS.Ph_EV_BUT_RELEASE;
- event.subtype = (short) 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 (widget, ptr);
- OS.free (ptr);
-}
-
-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);
- 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 descendants. After this method has
- * been invoked, the receiver and all descendants will answer
- * <code>true</code> when sent the message <code>isDisposed()</code>.
- * Any internal connections between the widgets in the tree will
- * have been removed to facilitate garbage collection.
- * <p>
- * NOTE: This method is not called recursively on the descendants
- * of the receiver. This means that, widget implementers can not
- * detect when a widget is being disposed of by re-implementing
- * this method, but should instead listen for the <code>Dispose</code>
- * event.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #addDisposeListener
- * @see #removeDisposeListener
- * @see #checkWidget
- */
-public void dispose () {
- /*
- * Note: It is valid to attempt to dispose a widget
- * more than once. If this happens, fail silently.
- */
- if (isDisposed ()) return;
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- release (true);
-}
-
-int drawProc (int widget, int damage) {
- return OS.Pt_CONTINUE;
-}
-
-static void error (int code) {
- SWT.error(code);
-}
-
-boolean filters (int eventType) {
- return display.filters (eventType);
-}
-
-char fixMnemonic (char [] buffer) {
- int i=0, j=0;
- char mnemonic=0;
- while (i < buffer.length) {
- if ((buffer [j++] = buffer [i++]) == '&') {
- if (i == buffer.length) {continue;}
- if (buffer [i] == '&') {i++; continue;}
- if (mnemonic == 0) mnemonic = buffer [i];
- j--;
- }
- }
- while (j < buffer.length) buffer [j++] = 0;
- return mnemonic;
-}
-
-/**
- * Returns the application defined widget data associated
- * with the receiver, or null if it has not been set. The
- * <em>widget data</em> is a single, unnamed field that is
- * stored with every widget.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the widget data needs to be notified
- * when the widget is disposed of, it is the application's
- * responsibility to hook the Dispose event on the widget and
- * do so.
- * </p>
- *
- * @return the widget data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- *
- * @see #setData(Object)
- */
-public Object getData () {
- checkWidget();
- return (state & KEYED_DATA) != 0 ? ((Object []) data) [0] : data;
-}
-
-/**
- * Returns the application defined property of the receiver
- * with the specified name, or null if it has not been set.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the widget is disposed
- * of, it is the application's responsibility to hook the
- * Dispose event on the widget and do so.
- * </p>
- *
- * @param key the name of the property
- * @return the value of the property or null if it has not been set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setData(String, Object)
- */
-public Object getData (String key) {
- checkWidget();
- if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((state & KEYED_DATA) != 0) {
- Object [] table = (Object []) data;
- for (int i=1; i<table.length; i+=2) {
- if (key.equals (table [i])) return table [i+1];
- }
- }
- return null;
-}
-
-/**
- * Returns the <code>Display</code> that is associated with
- * the receiver.
- * <p>
- * A widget's display is either provided when it is created
- * (for example, top level <code>Shell</code>s) or is the
- * same as its parent's display.
- * </p>
- *
- * @return the receiver's display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- */
-public Display getDisplay () {
- Display display = this.display;
- if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return display;
-}
-
-/**
- * Returns an array of listeners who will be notified when an event
- * of the given type occurs. The event type is one of the event constants
- * defined in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @return an array of listeners that will be notified when the event occurs
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if 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 SWT
- * @see #addListener(int, Listener)
- * @see #removeListener(int, Listener)
- * @see #notifyListeners
- *
- * @since 3.4
- */
-public Listener[] getListeners (int eventType) {
- checkWidget();
- if (eventTable == null) return new Listener[0];
- return eventTable.getListeners(eventType);
-}
-
-String getName () {
- String string = getClass ().getName ();
- int index = string.length ();
- while (--index > 0 && string.charAt (index) != '.') {/* empty */}
- return string.substring (index + 1, string.length ());
-}
-
-String getNameText () {
- return "";
-}
-
-/**
- * Returns the receiver's style information.
- * <p>
- * Note that the value which is returned by this method <em>may
- * not match</em> the value which was provided to the constructor
- * when the receiver was created. This can occur when the underlying
- * operating system does not support a particular combination of
- * requested styles. For example, if the platform widget used to
- * implement a particular SWT widget always has scroll bars, the
- * result of calling this method would always have the
- * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set.
- * </p>
- *
- * @return the style bits
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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.
- * <p>
- * This method gets the dispose state for the widget.
- * When a widget has been disposed, it is an error to
- * invoke any other method using the widget.
- * </p>
- *
- * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
- */
-public boolean isDisposed () {
- if (handle != 0) return false;
- if ((state & HANDLE) != 0) return true;
- return (state & DISPOSED) != 0;
-}
-
-boolean isValidSubclass () {
- return Display.isValidClass (getClass ());
-}
-
-/**
- * Returns <code>true</code> if there are any listeners
- * for the specified event type associated with the receiver,
- * and <code>false</code> otherwise. The event type is one of
- * the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event
- * @return true if the event is hooked
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- */
-public 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
- * invoking their <code>handleEvent()</code> method. The
- * event type is one of the event constants defined in class
- * <code>SWT</code>.
- *
- * @param eventType the type of event which has occurred
- * @param event the event data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- * @see #addListener
- * @see #getListeners(int)
- * @see #removeListener(int, Listener)
- */
-public void notifyListeners (int eventType, Event event) {
- checkWidget();
- if (event == null) event = new Event ();
- 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_NUMERIC_CHANGED (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 register () {
- if (handle == 0) return;
- WidgetTable.put (handle, this);
-}
-
-void release (boolean destroy) {
- if ((state & DISPOSE_SENT) == 0) {
- state |= DISPOSE_SENT;
- sendEvent (SWT.Dispose);
- }
- if ((state & DISPOSED) == 0) {
- releaseChildren (destroy);
- }
- if ((state & RELEASED) == 0) {
- state |= RELEASED;
- if (destroy) {
- releaseParent ();
- releaseWidget ();
- destroyWidget ();
- } else {
- releaseWidget ();
- releaseHandle ();
- }
- }
-}
-
-void releaseChildren (boolean destroy) {
-}
-
-void releaseHandle () {
- handle = 0;
- state |= DISPOSED;
- display = null;
-}
-
-void releaseParent () {
- /* Do nothing */
-}
-
-void releaseWidget () {
- deregister ();
- eventTable = null;
- data = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when an event of the given type occurs. The event
- * type is one of the event constants defined in class <code>SWT</code>.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see SWT
- * @see #addListener
- * @see #getListeners(int)
- * @see #notifyListeners
- */
-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 notified 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
- *
- * @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 notified when the widget is disposed.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see 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) {
- 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, handle, display.hotkeyProc);
- }
- 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) {
- 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
- * data</em> is a single, unnamed field that is stored
- * with every widget.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the widget data needs to be notified
- * when the widget is disposed of, it is the application's
- * responsibility to hook the Dispose event on the widget and
- * do so.
- * </p>
- *
- * @param data the widget data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- *
- * @see #getData()
- */
-public void setData (Object data) {
- checkWidget();
- if ((state & KEYED_DATA) != 0) {
- ((Object []) this.data) [0] = data;
- } else {
- this.data = data;
- }
-}
-
-/**
- * Sets the application defined property of the receiver
- * with the specified name to the given value.
- * <p>
- * Applications may associate arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the widget is disposed
- * of, it is the application's responsibility to hook the
- * Dispose event on the widget and do so.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getData(String)
- */
-public void setData (String key, Object value) {
- checkWidget();
- if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
- int index = 1;
- Object [] table = null;
- if ((state & KEYED_DATA) != 0) {
- table = (Object []) data;
- while (index < table.length) {
- if (key.equals (table [index])) break;
- index += 2;
- }
- }
- if (value != null) {
- if ((state & KEYED_DATA) != 0) {
- if (index == table.length) {
- Object [] newTable = new Object [table.length + 2];
- System.arraycopy (table, 0, newTable, 0, table.length);
- data = table = newTable;
- }
- } else {
- table = new Object [3];
- table [0] = data;
- data = table;
- state |= KEYED_DATA;
- }
- table [index] = key;
- table [index + 1] = value;
- } else {
- if ((state & KEYED_DATA) != 0) {
- if (index != table.length) {
- int length = table.length - 2;
- if (length == 1) {
- data = table [0];
- state &= ~KEYED_DATA;
- } else {
- Object [] newTable = new Object [length];
- System.arraycopy (table, 0, newTable, 0, index);
- System.arraycopy (table, index + 2, newTable, index, length - index);
- data = newTable;
- }
- }
- }
- }
-}
-
-boolean setInputState (Event event, int type, 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;
- switch (type) {
- case SWT.MouseDown:
- case SWT.MouseDoubleClick:
- if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
- if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
- if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
- break;
- case SWT.MouseUp:
- if (event.button == 1) event.stateMask |= SWT.BUTTON1;
- if (event.button == 2) event.stateMask |= SWT.BUTTON2;
- if (event.button == 3) event.stateMask |= SWT.BUTTON3;
- break;
- 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;
- }
- return true;
-}
-
-boolean setKeyState (Event event, int type, PhKeyEvent_t ke) {
- int key = 0;
- boolean isNull = false;
- if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
- key = ke.key_cap;
- if ((ke.key_mods & OS.Pk_KM_Num_Lock) == 0) {
- switch (key) {
- case OS.Pk_KP_0: key = OS.Pk_Insert; break;
- case OS.Pk_KP_1: key = OS.Pk_End; break;
- case OS.Pk_KP_2: key = OS.Pk_Down; break;
- case OS.Pk_KP_3: key = OS.Pk_Pg_Down; break;
- case OS.Pk_KP_4: key = OS.Pk_Left; break;
- case OS.Pk_KP_5: break;
- case OS.Pk_KP_6: key = OS.Pk_Right; break;
- case OS.Pk_KP_7: key = OS.Pk_Home; break;
- case OS.Pk_KP_8: key = OS.Pk_Up; break;
- case OS.Pk_KP_9: key = OS.Pk_Pg_Up; break;
- case OS.Pk_KP_Decimal: key = OS.Pk_Delete; break;
- }
-
- }
- 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_KP_Enter:
- case OS.Pk_Return: event.character = '\r'; break;
- case OS.Pk_Delete: event.character = 0x7F; break;
- case OS.Pk_Escape: event.character = 0x1B; break;
- case OS.Pk_KP_Tab:
- case OS.Pk_Tab: event.character = '\t'; break;
- /* These keys have no mapping in SWT yet */
- case OS.Pk_Clear:
- case OS.Pk_Menu:
- case OS.Pk_Hyper_L:
- case OS.Pk_Hyper_R:
- break;
- default: {
- if (event.keyCode == 0) {
- if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
- event.keyCode = ke.key_cap;
- }
- }
- /*
- * 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.
- */
- if ((ke.key_mods & (OS.Pk_KM_Alt | OS.Pk_KM_Ctrl)) != 0) {
- if (0 <= key && key <= 0x7F) {
- if ((ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
- isNull = key == '@';
- if ('a' <= key && key <= 'z') key -= 'a' - 'A';
- if (64 <= key && key <= 95) key -= 64;
- event.character = (char) key;
- isNull &= key == 0;
- } else {
- if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
- event.character = (char) ke.key_sym;
- }
- }
- }
- } else {
- byte [] buffer = new byte [6];
- int length = OS.PhKeyToMb (buffer, ke);
- if (length > 0) {
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- if (unicode.length > 0) event.character = unicode [0];
- }
- }
- }
- }
- if (event.keyCode == 0 && event.character == 0) {
- if (!isNull) return false;
- }
- return setInputState (event, type, ke.key_mods, ke.button_state);
-}
-
-boolean setMouseState(Event event, int type, 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;
- }
- }
- return setInputState(event, type, pe.key_mods, pe.button_state);
-}
-
-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_NUMERIC_CHANGED: return Pt_CB_NUMERIC_CHANGED (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
deleted file mode 100755
index 8898734d6f..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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;
-}
-}