diff options
102 files changed, 21511 insertions, 27592 deletions
diff --git a/bundles/org.eclipse.swt/.classpath_carbon b/bundles/org.eclipse.swt/.classpath_carbon index c49cc82528..6c34dede24 100644 --- a/bundles/org.eclipse.swt/.classpath_carbon +++ b/bundles/org.eclipse.swt/.classpath_carbon @@ -1,22 +1,22 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="var" path="JRE_LIB"/> - <classpathentry kind="src" path="Eclipse SWT/carbon"/> - <classpathentry kind="src" path="Eclipse SWT/emulated/bidi"/> - <classpathentry kind="src" path="Eclipse SWT/emulated/coolbar"/> - <classpathentry kind="src" path="Eclipse SWT/emulated/treetable"/> + <classpathentry kind="src" path="Eclipse SWT/carbon" excluding="Tree*.*|Table*.*"/> <classpathentry kind="src" path="Eclipse SWT/common"/> <classpathentry kind="src" path="Eclipse SWT/common_j2se"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/bidi"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/coolbar"/> <classpathentry kind="src" path="Eclipse SWT PI/carbon"/> <classpathentry kind="src" path="Eclipse SWT PI/common_j2se"/> - <classpathentry kind="src" path="Eclipse SWT Accessibility/emulated"/> <classpathentry kind="src" path="Eclipse SWT Accessibility/common"/> - <classpathentry kind="src" path="Eclipse SWT Drag and Drop/carbon"/> + <classpathentry kind="src" path="Eclipse SWT Accessibility/emulated"/> + <classpathentry kind="src" path="Eclipse SWT Custom Widgets/common"/> <classpathentry kind="src" path="Eclipse SWT Drag and Drop/common"/> - <classpathentry kind="src" path="Eclipse SWT Printing/carbon"/> + <classpathentry kind="src" path="Eclipse SWT Drag and Drop/carbon"/> <classpathentry kind="src" path="Eclipse SWT Printing/common"/> - <classpathentry kind="src" path="Eclipse SWT Program/carbon"/> + <classpathentry kind="src" path="Eclipse SWT Printing/carbon"/> <classpathentry kind="src" path="Eclipse SWT Program/common"/> - <classpathentry kind="src" path="Eclipse SWT Custom Widgets/common"/> + <classpathentry kind="src" path="Eclipse SWT Program/carbon"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/treetable"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java index 4debaf4679..a87f6ce595 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java @@ -7,109 +7,6 @@ package org.eclipse.swt.dnd; * http://www.eclipse.org/legal/cpl-v10.html */ -/** - * The class <code>ByteArrayTransfer</code> provides a platform specific - * mechanism for converting a java <code>byte[]</code> to a platform - * specific representation of the byte array and vice versa. See - * <code>Transfer</code> for additional information. - * - * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed - * by transfer agents that convert between data in a java format such as a - * <code>String</code> and a platform specific byte array. - * - * <p>If the data you are converting <b>does not</b> map to a - * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly - * and do your own mapping to a platform data type.</p> - * - * <p>The following snippet shows a sublcass of ByteArrayTransfer that transfers - * data defined by the class <code>MyType</code>.</p> - * - * <pre><code> - * public class MyType { - * public String fileName; - * public long fileLength; - * public long lastModified; - * } - * </code></pre> - * - * <code><pre> - * public class MyTypeTransfer extends ByteArrayTransfer { - * - * private static final String MYTYPENAME = "my_type_name"; - * private static final int MYTYPEID = registerType(MYTYPENAME); - * private static MyTypeTransfer _instance = new MyTypeTransfer(); - * - * private MyTypeTransfer() {} - * - * public static MyTypeTransfer getInstance () { - * return _instance; - * } - * public void javaToNative (Object object, TransferData transferData) { - * if (object == null || !(object instanceof MyType[])) return; - * - * if (isSupportedType(transferData)) { - * MyType[] myTypes = (MyType[]) object; - * try { - * // write data to a byte array and then ask super to convert to pMedium - * ByteArrayOutputStream out = new ByteArrayOutputStream(); - * DataOutputStream writeOut = new DataOutputStream(out); - * for (int i = 0, length = myTypes.length; i < length; i++){ - * byte[] buffer = myTypes[i].fileName.getBytes(); - * writeOut.writeInt(buffer.length); - * writeOut.write(buffer); - * writeOut.writeLong(myTypes[i].fileLength); - * writeOut.writeLong(myTypes[i].lastModified); - * } - * byte[] buffer = out.toByteArray(); - * writeOut.close(); - * - * super.javaToNative(buffer, transferData); - * - * } catch (IOException e) { - * } - * } - * } - * public Object nativeToJava(TransferData transferData){ - * - * if (isSupportedType(transferData)) { - * - * byte[] buffer = (byte[])super.nativeToJava(transferData); - * if (buffer == null) return null; - * - * MyType[] myData = new MyType[0]; - * try { - * ByteArrayInputStream in = new ByteArrayInputStream(buffer); - * DataInputStream readIn = new DataInputStream(in); - * while(readIn.available() > 20) { - * MyType datum = new MyType(); - * int size = readIn.readInt(); - * byte[] name = new byte[size]; - * readIn.read(name); - * datum.fileName = new String(name); - * datum.fileLength = readIn.readLong(); - * datum.lastModified = readIn.readLong(); - * MyType[] newMyData = new MyType[myData.length + 1]; - * System.arraycopy(myData, 0, newMyData, 0, myData.length); - * newMyData[myData.length] = datum; - * myData = newMyData; - * } - * readIn.close(); - * } catch (IOException ex) { - * return null; - * } - * return myData; - * } - * - * return null; - * } - * protected String[] getTypeNames(){ - * return new String[]{MYTYPENAME}; - * } - * protected int[] getTypeIds(){ - * return new int[] {MYTYPEID}; - * } - * } - */ public abstract class ByteArrayTransfer extends Transfer { public TransferData[] getSupportedTypes() { @@ -123,61 +20,30 @@ public TransferData[] getSupportedTypes() { } public boolean isSupportedType(TransferData transferData){ - if (transferData != null) { - int[] types= getTypeIds(); - for (int i= 0; i < types.length; i++) { - if (transferData.type == types[i]) - return true; - } + if (transferData == null) return false; + int[] types= getTypeIds(); + for (int i= 0; i < types.length; i++) { + if (transferData.type == types[i]) + return true; } return false; } -/** - * This implementation of <code>javaToNative</code> converts a java - * <code>byte[]</code> to a platform specific representation. For additional - * information see <code>Transfer#javaToNative</code>. - * - * @see Transfer#javaToNative - * - * @param object a java <code>byte[]</code> containing the data to be converted - * @param transferData an empty <code>TransferData</code> object; this - * object will be filled in on return with the platform specific format of the data - */ protected void javaToNative (Object object, TransferData transferData) { if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) { - transferData.result = 0; + transferData.result = -1; return; } - byte[] buffer= (byte[])object; - /* - transferData.pValue = OS.g_malloc(buffer.length); - OS.memmove(transferData.pValue, buffer, buffer.length); - */ - transferData.data= buffer; - transferData.length = buffer.length; - //transferData.format = 8; - transferData.result = 1; + byte[] orig = (byte[])object; + byte[] buffer= new byte[orig.length]; + System.arraycopy(orig, 0, buffer, 0, orig.length); + transferData.data = buffer; + transferData.result = 0; } -/** - * This implementation of <code>nativeToJava</code> converts a platform specific - * representation of a byte array to a java <code>byte[]</code>. - * For additional information see <code>Transfer#nativeToJava</code>. - * - * @see Transfer#nativeToJava - * - * @param transferData the platform specific representation of the data to be - * been converted - * @return a java <code>byte[]</code> containing the converted data if the - * conversion was successful; otherwise null - */ protected Object nativeToJava(TransferData transferData) { - if ( !isSupportedType(transferData) || transferData.data == null ) return null; - int n= transferData.length; - byte[] buffer= new byte[n]; - System.arraycopy(transferData.data, 0, buffer, 0, n); - return buffer; + if (!isSupportedType(transferData)) return null; + return transferData.data; } -} +}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Clipboard.java index 71dec955ba..8b554d54ae 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Clipboard.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Clipboard.java @@ -9,35 +9,13 @@ package org.eclipse.swt.dnd; import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; -import org.eclipse.swt.internal.carbon.MacUtil; import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.CFRange; - -/** - * The <code>Clipboard</code> provides a mechanism for transferring data from one - * application to another or within an application. - * - * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p> - */ public class Clipboard { private Display display; -/** - * Constructs a new instance of this class. Creating an instance of a Clipboard - * may cause system resources to be allocated depending on the platform. It is therefore - * mandatory that the Clipboard instance be disposed when no longer required. - * - * @param display the display on which to allocate the clipboard - * - * @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 Clipboard#dispose - * @see Clipboard#checkSubclass - */ public Clipboard(Display display) { checkSubclass (); if (display == null) { @@ -52,33 +30,6 @@ public Clipboard(Display display) { this.display = display; } -/** - * Checks that this class can be subclassed. - * <p> - * The SWT class library is intended to be subclassed - * only at specific, controlled points. 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 () { String name = getClass().getName (); String validName = Clipboard.class.getName(); @@ -86,194 +37,87 @@ protected void checkSubclass () { DND.error (SWT.ERROR_INVALID_SUBCLASS); } } -/** - * Disposes of the operating system resources associated with the clipboard. - * The data will still be available on the system clipboard after the dispose - * method is called. - * - * <p>NOTE: On some platforms the data will not be available once the application - * has exited or the display has been disposed.</p> - */ + public void dispose () { display = null; } -/** - * Retrieve the data of the specified type currently available on the system clipboard. Refer to the - * specific subclass of <code>Tramsfer</code> to determine the type of object returned. - * - * <p>The following snippet shows text and RTF text being retrieved from the clipboard:</p> - * - * <code><pre> - * Clipboard clipboard = new Clipboard(display); - * TextTransfer textTransfer = TextTransfer.getInstance(); - * String textData = (String)clipboard.getContents(textTransfer); - * if (textData != null) System.out.println("Text is "+textData); - * RTFTransfer rtfTransfer = RTFTransfer.getInstance(); - * String rtfData = (String)clipboard.getContents(rtfTransfer); - * if (rtfData != null) System.out.println("RTF Text is "+rtfData); - * clipboard.dispose(); - * </code></pre> - * - * @see Transfer - * - * @param transfer the transfer agent for the type of data being requested - * - * @return the data obtained from the clipboard or null if no data of this type is available - */ + public Object getContents(Transfer transfer) { - - if (display.isDisposed()) - return null; - - if (transfer == null) - return null; + if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED); + if (transfer == null) DND.error(SWT.ERROR_NULL_ARGUMENT); - int[] scrapHandle= new int[1]; + int[] scrapHandle = new int[1]; OS.GetCurrentScrap(scrapHandle); int scrap= scrapHandle[0]; // Does Clipboard have data in required format? - int[] typeIds= transfer.getTypeIds(); + int[] typeIds = transfer.getTypeIds(); for (int i= 0; i < typeIds.length; i++) { - int flavorType= typeIds[i]; - int[] size= new int[1]; - if (OS.GetScrapFlavorSize(scrap, flavorType, size) == OS.kNoErr) { + int type = typeIds[i]; + int[] size = new int[1]; + if (OS.GetScrapFlavorSize(scrap, type, size) == OS.noErr) { if (size[0] > 0) { - - TransferData tdata= new TransferData(); - - tdata.type= flavorType; - tdata.data= new byte[size[0]]; - OS.GetScrapFlavorData(scrap, flavorType, size, tdata.data); - tdata.length= size[0]; - - Object result= transfer.nativeToJava(tdata); - if (result != null) - return result; + TransferData tdata = new TransferData(); + tdata.type = type; + tdata.data = new byte[size[0]]; + OS.GetScrapFlavorData(scrap, type, size, tdata.data); + return transfer.nativeToJava(tdata); } } } - return null; // No data available for this transfer } -/** - * Place data of the specified type on the system clipboard. More than one type of - * data can be placed on the system clipboard at the same time. Setting the data - * clears any previous data of the same type from the system clipboard and also - * clears data of any other type currently on the system clipboard. - * - * <p>NOTE: On some platforms, the data is immediately copied to the system - * clipboard but on other platforms it is provided upon request. As a result, if the - * application modifes the data object it has set on the clipboard, that modification - * may or may not be available when the data is subsequently requested.</p> - * - * <p>The following snippet shows text and RTF text being set on the clipboard:</p> - * - * <code><pre> - * Clipboard clipboard = new Clipboard(display); - * String textData = "Hello World"; - * String rtfData = "{\\rtf1\\b\\i Hello World}"; - * TextTransfer textTransfer = TextTransfer.getInstance(); - * RTFTransfer rtfTransfer = RTFTransfer.getInstance(); - * clipboard.setContents(new Object[]{textData, rtfData}, new Transfer[]{textTransfer, rtfTransfer}); - * clipboard.dispose(); - * </code></pre> - * - * @param data the data to be set in the clipboard - * @param dataTypes the transfer agents that will convert the data to its platform - * specific format; each entry in the data array must have a corresponding dataType - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if data is null or datatypes is null - * or the length of data is not the same as the length of dataTypes</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or - * otherwise unavailable</li> - * </ul> - */ + public void setContents(Object[] data, Transfer[] dataTypes) { - - if (data == null) { - DND.error(SWT.ERROR_INVALID_ARGUMENT); - } - if (dataTypes == null || data.length != dataTypes.length) { + if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED); + if (data == null || dataTypes == null || data.length != dataTypes.length) { DND.error(SWT.ERROR_INVALID_ARGUMENT); } - if (display.isDisposed()) - DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD); - OS.ClearCurrentScrap(); - int[] scrapHandle= new int[1]; + int[] scrapHandle = new int[1]; OS.GetCurrentScrap(scrapHandle); - int scrap= scrapHandle[0]; - - int status= 1; - + int scrap = scrapHandle[0]; // copy data directly over to System clipboard (not deferred) for (int i= 0; i < dataTypes.length; i++) { - int[] ids= dataTypes[i].getTypeIds(); + int[] ids = dataTypes[i].getTypeIds(); for (int j= 0; j < ids.length; j++) { - TransferData transferData= new TransferData(); - /* Use the character encoding for the default locale */ - transferData.type= ids[j]; + TransferData transferData = new TransferData(); + transferData.type = ids[j]; dataTypes[i].javaToNative(data[i], transferData); - if (transferData.result == 1) { - /* - if (transferData.format == 8) { - byte[] buffer = new byte[transferData.length]; - OS.memmove(buffer, transferData.pValue, transferData.length); - byte[] bName = Converter.wcsToMbcs(null, names[j], true); - status = OS.XmClipboardCopy(xDisplay, xWindow, item_id[0], bName, buffer, transferData.length, 0, null); - } - */ - status= OS.PutScrapFlavor(scrap, transferData.type, 0, transferData.data); + if (transferData.result != OS.noErr) + DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD); + if (OS.PutScrapFlavor(scrap, transferData.type, 0, transferData.data.length, transferData.data) != OS.noErr){ + DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD); } } } - - if (status != OS.kNoErr) - DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD); } -/** - * Returns a platform specific list of the data types currently available on the - * system clipboard. - * - * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer - * sub-class. It should NOT be used within an application because it provides - * platform specific information.</p> - * - * @returns a platform specific list of the data types currently available on the - * system clipboard - */ -public String[] getAvailableTypeNames() { - if (display.isDisposed()) - return null; +public String[] getAvailableTypeNames() { + if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED); - int[] scrapHandle= new int[1]; + int[] scrapHandle = new int[1]; OS.GetCurrentScrap(scrapHandle); - int scrap= scrapHandle[0]; - - int[] flavorCount= new int[1]; - OS.GetScrapFlavorCount(scrap, flavorCount); - - //System.out.println("Clipboard.getAvailableTypeNames:"); - if (flavorCount[0] > 0) { - int[] info= new int[flavorCount[0] * 2]; - OS.GetScrapFlavorInfoList(scrap, flavorCount, info); - int n= flavorCount[0]; - String[] result= new String[n]; - for (int i= 0; i < n; i++) { - int flavorType= info[i*2]; - String type= MacUtil.toString(flavorType); - //System.out.println(" " + i + ": " + type); - result[i]= type; - } - return result; + int scrap = scrapHandle[0]; + int[] count = new int[1]; + OS.GetScrapFlavorCount(scrap, count); + if (count [0] == 0) return new String [0]; + int[] info = new int[count[0] * 2]; + OS.GetScrapFlavorInfoList(scrap, count, info); + String[] result = new String[count[0]]; + for (int i= 0; i < count [0]; i++) { + int type = info[i*2]; + StringBuffer sb = new StringBuffer(); + sb.append((char)((type & 0xff000000) >> 24)); + sb.append((char)((type & 0x00ff0000) >> 16)); + sb.append((char)((type & 0x0000ff00) >> 8)); + sb.append((char)((type & 0x000000ff) >> 0)); + result[i] = sb.toString(); } - - return null; + return result; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java index 2527ccf0f1..d84579c58e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DragSource.java @@ -88,6 +88,13 @@ import org.eclipse.swt.internal.*; * </dl> */ public final class DragSource extends Widget { + + // info for registering as a drag source + private Control control; + private Listener controlListener; + private Transfer[] transferAgents = new Transfer[0]; + + private static final String DRAGSOURCEID = "DragSource"; /** * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>. @@ -112,6 +119,24 @@ public final class DragSource extends Widget { */ public DragSource(Control control, int style) { super (control, style); + this.control = control; + if (control.getData(DRAGSOURCEID) != null) + DND.error(DND.ERROR_CANNOT_INIT_DRAG); + + controlListener = new Listener () { + public void handleEvent (Event event) { + if (event.type == SWT.Dispose){ + DragSource.this.dispose(); + } + } + }; + control.addListener (SWT.Dispose, controlListener); + + this.addListener(SWT.Dispose, new Listener() { + public void handleEvent(Event e) { + onDispose(); + } + }); } /** @@ -144,9 +169,21 @@ public DragSource(Control control, int style) { * @see DragSourceEvent */ public void addDragListener(DragSourceListener listener) { - + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + DNDListener typedListener = new DNDListener (listener); + addListener (DND.DragStart, typedListener); + addListener (DND.DragEnd, typedListener); + addListener (DND.DragSetData, typedListener); } +protected void checkSubclass () { + String name = getClass().getName (); + String validName = DragSource.class.getName(); + if (!validName.equals(name)) { + DND.error (SWT.ERROR_INVALID_SUBCLASS); + } +} + /** * Returns the Control which is registered for this DragSource. This is the control that the * user clicks in to initiate dragging. @@ -154,11 +191,12 @@ public void addDragListener(DragSourceListener listener) { * @return the Control which is registered for this DragSource */ public Control getControl () { - return null; + return control; } public Display getDisplay () { - return null; + if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + return control.getDisplay (); } /** * Returns the list of data types that can be transferred by this DragSource. @@ -166,7 +204,19 @@ public Display getDisplay () { * @return the list of data types that can be transferred by this DragSource */ public Transfer[] getTransfer(){ - return null; + return transferAgents; +} + +private void onDispose () { + if (control != null && controlListener != null){ + control.removeListener(SWT.Dispose, controlListener); + control.removeListener(SWT.DragDetect, controlListener); + } + controlListener = null; + control.setData(DRAGSOURCEID, null); + control = null; + + transferAgents = null; } /** @@ -187,6 +237,10 @@ public Transfer[] getTransfer(){ * @see #addDragListener */ public void removeDragListener(DragSourceListener listener) { + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + removeListener (DND.DragStart, listener); + removeListener (DND.DragEnd, listener); + removeListener (DND.DragSetData, listener); } /** @@ -198,6 +252,7 @@ public void removeDragListener(DragSourceListener listener) { * dragged from this source */ public void setTransfer(Transfer[] transferAgents){ + this.transferAgents = transferAgents; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DropTarget.java index 49dbe7b852..d4d1f066e8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/DropTarget.java @@ -65,6 +65,13 @@ import org.eclipse.swt.internal.*; */ public final class DropTarget extends Widget { + // info for registering as a droptarget + private Control control; + private Listener controlListener; + private Transfer[] transferAgents = new Transfer[0]; + + private static final String DROPTARGETID = "DropTarget"; + /** * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified * <code>Control</code>. @@ -85,6 +92,24 @@ public final class DropTarget extends Widget { */ public DropTarget(Control control, int style) { super(control, style); + this.control = control; + if (control.getData(DROPTARGETID) != null) + DND.error(DND.ERROR_CANNOT_INIT_DROP); + control.setData(DROPTARGETID, this); + + controlListener = new Listener () { + public void handleEvent (Event event) { + DropTarget.this.dispose(); + } + }; + + control.addListener (SWT.Dispose, controlListener); + + this.addListener (SWT.Dispose, new Listener () { + public void handleEvent (Event event) { + onDispose(); + } + }); } /** @@ -120,8 +145,24 @@ public DropTarget(Control control, int style) { * @see DropTargetEvent */ public void addDropListener(DropTargetListener listener) { + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + DNDListener typedListener = new DNDListener (listener); + addListener (DND.DragEnter, typedListener); + addListener (DND.DragLeave, typedListener); + addListener (DND.DragOver, typedListener); + addListener (DND.DragOperationChanged, typedListener); + addListener (DND.Drop, typedListener); + addListener (DND.DropAccept, typedListener); } +protected void checkSubclass () { + String name = getClass().getName (); + String validName = DropTarget.class.getName(); + if (!validName.equals(name)) { + DND.error (SWT.ERROR_INVALID_SUBCLASS); + } +} + /** * Returns the Control which is registered for this DropTarget. This is the control over which the * user positions the cursor to drop the data. @@ -129,19 +170,33 @@ public void addDropListener(DropTargetListener listener) { * @return the Control which is registered for this DropTarget */ public Control getControl () { - return null; + return control; } + public Display getDisplay () { - return null; + if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED); + return control.getDisplay (); } + /** * Returns a list of the data types that can be transferred to this DropTarget. * * @return a list of the data types that can be transferred to this DropTarget */ -public Transfer[] getTransfer() { return null; } +public Transfer[] getTransfer(){ + return transferAgents; +} -public void notifyListener (int eventType, Event event) {} +private void onDispose () { + if (control == null) return; + + if (controlListener != null) + control.removeListener(SWT.Dispose, controlListener); + controlListener = null; + control.setData(DROPTARGETID, null); + transferAgents = null; + control = null; +} /** * Removes the listener from the collection of listeners who will @@ -160,7 +215,15 @@ public void notifyListener (int eventType, Event event) {} * @see DropTargetListener * @see #addDropListener */ -public void removeDropListener(DropTargetListener listener) {} +public void removeDropListener(DropTargetListener listener) { + if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT); + removeListener (DND.DragEnter, listener); + removeListener (DND.DragLeave, listener); + removeListener (DND.DragOver, listener); + removeListener (DND.DragOperationChanged, listener); + removeListener (DND.Drop, listener); + removeListener (DND.DropAccept, listener); +} /** * Specifies the data types that can be transferred to this DropTarget. If data is @@ -176,6 +239,7 @@ public void removeDropListener(DropTargetListener listener) {} */ public void setTransfer(Transfer[] transferAgents){ if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT); + this.transferAgents = transferAgents; } -} +}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TextTransfer.java index 22afcdcf6b..2249eb2df9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TextTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TextTransfer.java @@ -6,8 +6,9 @@ package org.eclipse.swt.dnd; * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html */ - - import org.eclipse.swt.internal.Converter; + +import org.eclipse.swt.internal.Converter; +import org.eclipse.swt.internal.carbon.OS; /** * The class <code>TextTransfer</code> provides a platform specific mechanism @@ -26,7 +27,7 @@ public class TextTransfer extends ByteArrayTransfer { private static TextTransfer _instance = new TextTransfer(); private static final String TYPENAME1 = "TEXT"; - private static final int TYPEID1 = ('T'<<24) + ('E'<<16) + ('X'<<8) + 'T'; + private static final int TYPEID1 = OS.kScrapFlavorTypeText; private TextTransfer() { } @@ -38,6 +39,7 @@ private TextTransfer() { public static TextTransfer getInstance () { return _instance; } + /** * This implementation of <code>javaToNative</code> converts plain text * represented by a java <code>String</code> to a platform specific representation. @@ -48,10 +50,14 @@ public static TextTransfer getInstance () { * object will be filled in on return with the platform specific format of the data */ public void javaToNative (Object object, TransferData transferData){ - if (object == null || !(object instanceof String)) return; + if (object == null || !(object instanceof String)) { + transferData.result = -1; + return; + } byte [] buffer = Converter.wcsToMbcs (null, (String)object, true); super.javaToNative(buffer, transferData); } + /** * This implementation of <code>nativeToJava</code> converts a platform specific * representation of plain text to a java <code>String</code>. @@ -72,9 +78,11 @@ public Object nativeToJava(TransferData transferData){ int end = string.indexOf('\0'); return (end == -1) ? string : string.substring(0, end); } + protected String[] getTypeNames() { return new String[] { TYPENAME1 }; } + protected int[] getTypeIds() { return new int[] { TYPEID1 }; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TransferData.java index de58e88908..d3ed77977d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TransferData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/TransferData.java @@ -29,24 +29,18 @@ public class TransferData { public int type; /** - * The byte count for the data. - * (Warning: This field is platform dependent) - */ - public int length; - - /** * The data being transferred. * (Warning: This field is platform dependent) */ public byte[] data; - + /** * The result field contains the result of converting a java data type * into a platform specific value. * (Warning: This field is platform dependent) * - * <p>The value of result is 1 if the conversion was successfully. The value of - * result is 0 if the conversion failed.</p> + * <p>The value of result is if the conversion was successfully. The value of + * result is an error code if the conversion failed.</p> */ public int result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/.cvsignore b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/.cvsignore deleted file mode 100644 index ca9481cd77..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -org_eclipse_swt_internal_carbon_OS.h diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/build.csh b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/build.csh new file mode 100644 index 0000000000..4572a603e9 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/build.csh @@ -0,0 +1,10 @@ +#!/bin/csh + +#********************************************************************** +# Copyright (c) 2000, 2002 IBM Corp. All rights reserved. +# This file is made available under the terms of the Common Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/cpl-v10.html +#********************************************************************** + +make -f make_carbon.mak $1 $2 $3 $4 $5 $6 $7 $8 $9 diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/make_carbon.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/make_carbon.mak new file mode 100644 index 0000000000..da6a3f6335 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/make_carbon.mak @@ -0,0 +1,32 @@ +#********************************************************************** +# Copyright (c) 2000, 2002 IBM Corp. All rights reserved. +# This file is made available under the terms of the Common Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/cpl-v10.html +#********************************************************************** +# +# Makefile for SWT libraries on Carbon/Mac + +include make_common.mak + +SWT_PREFIX=swt +WS_PREFIX=carbon +SWT_VERSION=$(maj_ver)$(min_ver) +SWT_LIB=lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).jnilib + +DEBUG = +CFLAGS = -c -DSWT_VERSION=$(SWT_VERSION) $(DEBUG) -DCARBON -I /System/Library/Frameworks/JavaVM.framework/Headers +LFLAGS = -bundle -framework JavaVM -framework Carbon + +SWT_OBJS = swt.o structs.o callback.o + +all: $(SWT_LIB) + +.c.o: + cc $(CFLAGS) $*.c + +$(SWT_LIB): $(SWT_OBJS) + cc -o $(SWT_LIB) $(LFLAGS) $(SWT_OBJS) + +clean: + rm -f *.jnilib *.o
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/make_carbon.xml b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/make_carbon.xml index e8f23f9f16..ec3a790d33 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/make_carbon.xml +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/make_carbon.xml @@ -3,57 +3,33 @@ <!-- This file is made available under the terms of the Common Public License v1.0 --> <!-- which accompanies this distribution, and is available at --> <!-- http://www.eclipse.org/legal/cpl-v10.html --> -<!-- --> -<!-- Andre Weinand, OTI - Initial version --> <!-- ============================================================================= --> -<project default="build_dll" basedir="."> +<project default="build_lib" basedir="."> <target name="init"> <tstamp/> <property name="fragment_dir" value="../../../../org.eclipse.swt.carbon" /> <property name="jar_destdir" value="${fragment_dir}/ws/carbon" /> - <property name="dll_destdir" value="${fragment_dir}/os/macosx/ppc" /> + <property name="lib_destdir" value="${fragment_dir}/os/macosx/ppc" /> <property name="plugin" value="org.eclipse.swt" /> <property name="bin_dir" value="../../../bin" /> - <property name="common_library" value="../../../Eclipse SWT/common/library" /> <mkdir dir="${jar_destdir}" /> - <mkdir dir="${dll_destdir}" /> + <mkdir dir="${lib_destdir}" /> </target> <target name="build" depends="init"> <eclipse.incrementalBuild project="${plugin}" kind="incr" /> </target> - <target name="build_header" depends="build"> - <javah - destdir="." - force="yes" - classpath="${bin_dir}" - class= "org.eclipse.swt.internal.carbon.OS" - /> - </target> - - <target name="build_dll" depends="build_header"> + <target name="build_lib" depends="build"> - <property file="${common_library}/make_common.mak" /> - <property name="SWT_VERSION" value="${maj_ver}${min_ver}" /> - <property name="SWT_PREFIX" value="swt" /> - <property name="WS_PREFIX" value="carbon" /> - <property name="SWT_DLL" value="lib${SWT_PREFIX}-${WS_PREFIX}-${SWT_VERSION}.jnilib" /> - - <exec executable="cc"> - <arg line="-bundle" /> - <arg value='-DPLATFORM="carbon"' /> - <arg value="-DREDUCED_CALLBACKS=1" /> - <arg line="-I /System/Library/Frameworks/JavaVM.framework/Headers" /> - <arg line="-o ${dll_destdir}/${SWT_DLL}" /> - <arg line="-framework JavaVM" /> - <arg line="-framework Carbon" /> - <arg line="swt.c" /> - <arg value="${common_library}/callback.c" /> + <exec dir="${bin_dir}/library/" executable="csh"> + <arg line='build.csh' /> </exec> - + <copy todir="${lib_destdir}"> + <fileset dir="${bin_dir}/library" includes="**/*.jnilib"/> + </copy> </target> <target name="build_jar" depends="build"> @@ -62,8 +38,16 @@ basedir="${bin_dir}" /> </target> + + <target name="clean" depends="init"> + + <exec dir="${bin_dir}/library/" executable="csh"> + <arg line='build.csh' /> + <arg line='clean' /> + </exec> + </target> - <target name="export" depends="build_jar,build_dll"> + <target name="export" depends="build_jar,build_lib"> </target> </project> diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.c new file mode 100644 index 0000000000..3dfd6ad6cc --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.c @@ -0,0 +1,1716 @@ +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +/** + * JNI SWT object field getters and setters declarations for Mac/Carbon structs. + */ + +#include "swt.h" +#include "structs.h" + +#ifndef NO_AEDesc +typedef struct AEDesc_FID_CACHE { + int cached; + jclass clazz; + jfieldID descriptorType, dataHandle; +} AEDesc_FID_CACHE; + +AEDesc_FID_CACHE AEDescFc; + +void cacheAEDescFids(JNIEnv *env, jobject lpObject) +{ + if (AEDescFc.cached) return; + AEDescFc.clazz = (*env)->GetObjectClass(env, lpObject); + AEDescFc.descriptorType = (*env)->GetFieldID(env, AEDescFc.clazz, "descriptorType", "I"); + AEDescFc.dataHandle = (*env)->GetFieldID(env, AEDescFc.clazz, "dataHandle", "I"); + AEDescFc.cached = 1; +} + +AEDesc *getAEDescFields(JNIEnv *env, jobject lpObject, AEDesc *lpStruct) +{ + if (!AEDescFc.cached) cacheAEDescFids(env, lpObject); + lpStruct->descriptorType = (DescType)(*env)->GetIntField(env, lpObject, AEDescFc.descriptorType); + lpStruct->dataHandle = (AEDataStorage)(*env)->GetIntField(env, lpObject, AEDescFc.dataHandle); + return lpStruct; +} + +void setAEDescFields(JNIEnv *env, jobject lpObject, AEDesc *lpStruct) +{ + if (!AEDescFc.cached) cacheAEDescFids(env, lpObject); + (*env)->SetIntField(env, lpObject, AEDescFc.descriptorType, (jint)lpStruct->descriptorType); + (*env)->SetIntField(env, lpObject, AEDescFc.dataHandle, (jint)lpStruct->dataHandle); +} +#endif /* NO_AEDesc */ + +#ifndef NO_ATSTrapezoid +typedef struct ATSTrapezoid_FID_CACHE { + int cached; + jclass clazz; + jfieldID upperLeft_x, upperLeft_y, upperRight_x, upperRight_y, lowerRight_x, lowerRight_y, lowerLeft_x, lowerLeft_y; +} ATSTrapezoid_FID_CACHE; + +ATSTrapezoid_FID_CACHE ATSTrapezoidFc; + +void cacheATSTrapezoidFids(JNIEnv *env, jobject lpObject) +{ + if (ATSTrapezoidFc.cached) return; + ATSTrapezoidFc.clazz = (*env)->GetObjectClass(env, lpObject); + ATSTrapezoidFc.upperLeft_x = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "upperLeft_x", "I"); + ATSTrapezoidFc.upperLeft_y = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "upperLeft_y", "I"); + ATSTrapezoidFc.upperRight_x = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "upperRight_x", "I"); + ATSTrapezoidFc.upperRight_y = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "upperRight_y", "I"); + ATSTrapezoidFc.lowerRight_x = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "lowerRight_x", "I"); + ATSTrapezoidFc.lowerRight_y = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "lowerRight_y", "I"); + ATSTrapezoidFc.lowerLeft_x = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "lowerLeft_x", "I"); + ATSTrapezoidFc.lowerLeft_y = (*env)->GetFieldID(env, ATSTrapezoidFc.clazz, "lowerLeft_y", "I"); + ATSTrapezoidFc.cached = 1; +} + +ATSTrapezoid *getATSTrapezoidFields(JNIEnv *env, jobject lpObject, ATSTrapezoid *lpStruct) +{ + if (!ATSTrapezoidFc.cached) cacheATSTrapezoidFids(env, lpObject); + lpStruct->upperLeft.x = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.upperLeft_x); + lpStruct->upperLeft.y = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.upperLeft_y); + lpStruct->upperRight.x = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.upperRight_x); + lpStruct->upperRight.y = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.upperRight_y); + lpStruct->lowerRight.x = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.lowerRight_x); + lpStruct->lowerRight.y = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.lowerRight_y); + lpStruct->lowerLeft.x = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.lowerLeft_x); + lpStruct->lowerLeft.y = (*env)->GetIntField(env, lpObject, ATSTrapezoidFc.lowerLeft_y); + return lpStruct; +} + +void setATSTrapezoidFields(JNIEnv *env, jobject lpObject, ATSTrapezoid *lpStruct) +{ + if (!ATSTrapezoidFc.cached) cacheATSTrapezoidFids(env, lpObject); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.upperLeft_x, (jint)lpStruct->upperLeft.x); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.upperLeft_y, (jint)lpStruct->upperLeft.y); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.upperRight_x, (jint)lpStruct->upperRight.x); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.upperRight_y, (jint)lpStruct->upperRight.y); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.lowerRight_x, (jint)lpStruct->lowerRight.x); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.lowerRight_y, (jint)lpStruct->lowerRight.y); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.lowerLeft_x, (jint)lpStruct->lowerLeft.x); + (*env)->SetIntField(env, lpObject, ATSTrapezoidFc.lowerLeft_y, (jint)lpStruct->lowerLeft.y); +} +#endif /* NO_ATSTrapezoid */ + +#ifndef NO_AlertStdCFStringAlertParamRec +typedef struct AlertStdCFStringAlertParamRec_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, movable, helpButton, defaultText, cancelText, otherText, defaultButton, cancelButton, position, flags; +} AlertStdCFStringAlertParamRec_FID_CACHE; + +AlertStdCFStringAlertParamRec_FID_CACHE AlertStdCFStringAlertParamRecFc; + +void cacheAlertStdCFStringAlertParamRecFids(JNIEnv *env, jobject lpObject) +{ + if (AlertStdCFStringAlertParamRecFc.cached) return; + AlertStdCFStringAlertParamRecFc.clazz = (*env)->GetObjectClass(env, lpObject); + AlertStdCFStringAlertParamRecFc.version = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "version", "I"); + AlertStdCFStringAlertParamRecFc.movable = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "movable", "Z"); + AlertStdCFStringAlertParamRecFc.helpButton = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "helpButton", "Z"); + AlertStdCFStringAlertParamRecFc.defaultText = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "defaultText", "I"); + AlertStdCFStringAlertParamRecFc.cancelText = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "cancelText", "I"); + AlertStdCFStringAlertParamRecFc.otherText = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "otherText", "I"); + AlertStdCFStringAlertParamRecFc.defaultButton = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "defaultButton", "S"); + AlertStdCFStringAlertParamRecFc.cancelButton = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "cancelButton", "S"); + AlertStdCFStringAlertParamRecFc.position = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "position", "S"); + AlertStdCFStringAlertParamRecFc.flags = (*env)->GetFieldID(env, AlertStdCFStringAlertParamRecFc.clazz, "flags", "I"); + AlertStdCFStringAlertParamRecFc.cached = 1; +} + +AlertStdCFStringAlertParamRec *getAlertStdCFStringAlertParamRecFields(JNIEnv *env, jobject lpObject, AlertStdCFStringAlertParamRec *lpStruct) +{ + if (!AlertStdCFStringAlertParamRecFc.cached) cacheAlertStdCFStringAlertParamRecFids(env, lpObject); + lpStruct->version = (UInt32)(*env)->GetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.version); + lpStruct->movable = (Boolean)(*env)->GetBooleanField(env, lpObject, AlertStdCFStringAlertParamRecFc.movable); + lpStruct->helpButton = (Boolean)(*env)->GetBooleanField(env, lpObject, AlertStdCFStringAlertParamRecFc.helpButton); + lpStruct->defaultText = (CFStringRef)(*env)->GetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.defaultText); + lpStruct->cancelText = (CFStringRef)(*env)->GetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.cancelText); + lpStruct->otherText = (CFStringRef)(*env)->GetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.otherText); + lpStruct->defaultButton = (SInt16)(*env)->GetShortField(env, lpObject, AlertStdCFStringAlertParamRecFc.defaultButton); + lpStruct->cancelButton = (SInt16)(*env)->GetShortField(env, lpObject, AlertStdCFStringAlertParamRecFc.cancelButton); + lpStruct->position = (UInt16)(*env)->GetShortField(env, lpObject, AlertStdCFStringAlertParamRecFc.position); + lpStruct->flags = (OptionBits)(*env)->GetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.flags); + return lpStruct; +} + +void setAlertStdCFStringAlertParamRecFields(JNIEnv *env, jobject lpObject, AlertStdCFStringAlertParamRec *lpStruct) +{ + if (!AlertStdCFStringAlertParamRecFc.cached) cacheAlertStdCFStringAlertParamRecFids(env, lpObject); + (*env)->SetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.version, (jint)lpStruct->version); + (*env)->SetBooleanField(env, lpObject, AlertStdCFStringAlertParamRecFc.movable, (jboolean)lpStruct->movable); + (*env)->SetBooleanField(env, lpObject, AlertStdCFStringAlertParamRecFc.helpButton, (jboolean)lpStruct->helpButton); + (*env)->SetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.defaultText, (jint)lpStruct->defaultText); + (*env)->SetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.cancelText, (jint)lpStruct->cancelText); + (*env)->SetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.otherText, (jint)lpStruct->otherText); + (*env)->SetShortField(env, lpObject, AlertStdCFStringAlertParamRecFc.defaultButton, (jshort)lpStruct->defaultButton); + (*env)->SetShortField(env, lpObject, AlertStdCFStringAlertParamRecFc.cancelButton, (jshort)lpStruct->cancelButton); + (*env)->SetShortField(env, lpObject, AlertStdCFStringAlertParamRecFc.position, (jshort)lpStruct->position); + (*env)->SetIntField(env, lpObject, AlertStdCFStringAlertParamRecFc.flags, (jint)lpStruct->flags); +} +#endif /* NO_AlertStdCFStringAlertParamRec */ + +#ifndef NO_BitMap +typedef struct BitMap_FID_CACHE { + int cached; + jclass clazz; + jfieldID baseAddr, rowBytes, top, left, bottom, right; +} BitMap_FID_CACHE; + +BitMap_FID_CACHE BitMapFc; + +void cacheBitMapFids(JNIEnv *env, jobject lpObject) +{ + if (BitMapFc.cached) return; + BitMapFc.clazz = (*env)->GetObjectClass(env, lpObject); + BitMapFc.baseAddr = (*env)->GetFieldID(env, BitMapFc.clazz, "baseAddr", "I"); + BitMapFc.rowBytes = (*env)->GetFieldID(env, BitMapFc.clazz, "rowBytes", "S"); + BitMapFc.top = (*env)->GetFieldID(env, BitMapFc.clazz, "top", "S"); + BitMapFc.left = (*env)->GetFieldID(env, BitMapFc.clazz, "left", "S"); + BitMapFc.bottom = (*env)->GetFieldID(env, BitMapFc.clazz, "bottom", "S"); + BitMapFc.right = (*env)->GetFieldID(env, BitMapFc.clazz, "right", "S"); + BitMapFc.cached = 1; +} + +BitMap *getBitMapFields(JNIEnv *env, jobject lpObject, BitMap *lpStruct) +{ + if (!BitMapFc.cached) cacheBitMapFids(env, lpObject); + lpStruct->baseAddr = (void *)(*env)->GetIntField(env, lpObject, BitMapFc.baseAddr); + lpStruct->rowBytes = (*env)->GetShortField(env, lpObject, BitMapFc.rowBytes); + lpStruct->bounds.top = (*env)->GetShortField(env, lpObject, BitMapFc.top); + lpStruct->bounds.left = (*env)->GetShortField(env, lpObject, BitMapFc.left); + lpStruct->bounds.bottom = (*env)->GetShortField(env, lpObject, BitMapFc.bottom); + lpStruct->bounds.right = (*env)->GetShortField(env, lpObject, BitMapFc.right); + return lpStruct; +} + +void setBitMapFields(JNIEnv *env, jobject lpObject, BitMap *lpStruct) +{ + if (!BitMapFc.cached) cacheBitMapFids(env, lpObject); + (*env)->SetIntField(env, lpObject, BitMapFc.baseAddr, (jint)lpStruct->baseAddr); + (*env)->SetShortField(env, lpObject, BitMapFc.rowBytes, (jshort)lpStruct->rowBytes); + (*env)->SetShortField(env, lpObject, BitMapFc.top, (jshort)lpStruct->bounds.top); + (*env)->SetShortField(env, lpObject, BitMapFc.left, (jshort)lpStruct->bounds.left); + (*env)->SetShortField(env, lpObject, BitMapFc.bottom, (jshort)lpStruct->bounds.bottom); + (*env)->SetShortField(env, lpObject, BitMapFc.right, (jshort)lpStruct->bounds.right); +} +#endif /* NO_BitMap */ + +#ifndef NO_CFRange +typedef struct CFRange_FID_CACHE { + int cached; + jclass clazz; + jfieldID location, length; +} CFRange_FID_CACHE; + +CFRange_FID_CACHE CFRangeFc; + +void cacheCFRangeFids(JNIEnv *env, jobject lpObject) +{ + if (CFRangeFc.cached) return; + CFRangeFc.clazz = (*env)->GetObjectClass(env, lpObject); + CFRangeFc.location = (*env)->GetFieldID(env, CFRangeFc.clazz, "location", "I"); + CFRangeFc.length = (*env)->GetFieldID(env, CFRangeFc.clazz, "length", "I"); + CFRangeFc.cached = 1; +} + +CFRange *getCFRangeFields(JNIEnv *env, jobject lpObject, CFRange *lpStruct) +{ + if (!CFRangeFc.cached) cacheCFRangeFids(env, lpObject); + lpStruct->location = (CFIndex)(*env)->GetIntField(env, lpObject, CFRangeFc.location); + lpStruct->length = (CFIndex)(*env)->GetIntField(env, lpObject, CFRangeFc.length); + return lpStruct; +} + +void setCFRangeFields(JNIEnv *env, jobject lpObject, CFRange *lpStruct) +{ + if (!CFRangeFc.cached) cacheCFRangeFids(env, lpObject); + (*env)->SetIntField(env, lpObject, CFRangeFc.location, (jint)lpStruct->location); + (*env)->SetIntField(env, lpObject, CFRangeFc.length, (jint)lpStruct->length); +} +#endif /* NO_CFRange */ + +#ifndef NO_CGPoint +typedef struct CGPoint_FID_CACHE { + int cached; + jclass clazz; + jfieldID x, y; +} CGPoint_FID_CACHE; + +CGPoint_FID_CACHE CGPointFc; + +void cacheCGPointFids(JNIEnv *env, jobject lpObject) +{ + if (CGPointFc.cached) return; + CGPointFc.clazz = (*env)->GetObjectClass(env, lpObject); + CGPointFc.x = (*env)->GetFieldID(env, CGPointFc.clazz, "x", "F"); + CGPointFc.y = (*env)->GetFieldID(env, CGPointFc.clazz, "y", "F"); + CGPointFc.cached = 1; +} + +CGPoint *getCGPointFields(JNIEnv *env, jobject lpObject, CGPoint *lpStruct) +{ + if (!CGPointFc.cached) cacheCGPointFids(env, lpObject); + lpStruct->x = (float)(*env)->GetFloatField(env, lpObject, CGPointFc.x); + lpStruct->y = (float)(*env)->GetFloatField(env, lpObject, CGPointFc.y); + return lpStruct; +} + +void setCGPointFields(JNIEnv *env, jobject lpObject, CGPoint *lpStruct) +{ + if (!CGPointFc.cached) cacheCGPointFids(env, lpObject); + (*env)->SetFloatField(env, lpObject, CGPointFc.x, (jfloat)lpStruct->x); + (*env)->SetFloatField(env, lpObject, CGPointFc.y, (jfloat)lpStruct->y); +} +#endif /* NO_CGPoint */ + +#ifndef NO_CGRect +typedef struct CGRect_FID_CACHE { + int cached; + jclass clazz; + jfieldID x, y, width, height; +} CGRect_FID_CACHE; + +CGRect_FID_CACHE CGRectFc; + +void cacheCGRectFids(JNIEnv *env, jobject lpObject) +{ + if (CGRectFc.cached) return; + CGRectFc.clazz = (*env)->GetObjectClass(env, lpObject); + CGRectFc.x = (*env)->GetFieldID(env, CGRectFc.clazz, "x", "F"); + CGRectFc.y = (*env)->GetFieldID(env, CGRectFc.clazz, "y", "F"); + CGRectFc.width = (*env)->GetFieldID(env, CGRectFc.clazz, "width", "F"); + CGRectFc.height = (*env)->GetFieldID(env, CGRectFc.clazz, "height", "F"); + CGRectFc.cached = 1; +} + +CGRect *getCGRectFields(JNIEnv *env, jobject lpObject, CGRect *lpStruct) +{ + if (!CGRectFc.cached) cacheCGRectFids(env, lpObject); + lpStruct->origin.x = (float)(*env)->GetFloatField(env, lpObject, CGRectFc.x); + lpStruct->origin.y = (float)(*env)->GetFloatField(env, lpObject, CGRectFc.y); + lpStruct->size.width = (float)(*env)->GetFloatField(env, lpObject, CGRectFc.width); + lpStruct->size.height = (float)(*env)->GetFloatField(env, lpObject, CGRectFc.height); + return lpStruct; +} + +void setCGRectFields(JNIEnv *env, jobject lpObject, CGRect *lpStruct) +{ + if (!CGRectFc.cached) cacheCGRectFids(env, lpObject); + (*env)->SetFloatField(env, lpObject, CGRectFc.x, (jfloat)lpStruct->origin.x); + (*env)->SetFloatField(env, lpObject, CGRectFc.y, (jfloat)lpStruct->origin.y); + (*env)->SetFloatField(env, lpObject, CGRectFc.width, (jfloat)lpStruct->size.width); + (*env)->SetFloatField(env, lpObject, CGRectFc.height, (jfloat)lpStruct->size.height); +} +#endif /* NO_CGRect */ + +#ifndef NO_ColorPickerInfo +typedef struct ColorPickerInfo_FID_CACHE { + int cached; + jclass clazz; + jfieldID profile, red, green, blue, dstProfile, flags, placeWhere, h, v, pickerType, eventProc, colorProc, colorProcData, prompt, editMenuID, cutItem, copyItem, pasteItem, clearItem, undoItem, newColorChosen; +} ColorPickerInfo_FID_CACHE; + +ColorPickerInfo_FID_CACHE ColorPickerInfoFc; + +void cacheColorPickerInfoFids(JNIEnv *env, jobject lpObject) +{ + if (ColorPickerInfoFc.cached) return; + ColorPickerInfoFc.clazz = (*env)->GetObjectClass(env, lpObject); + ColorPickerInfoFc.profile = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "profile", "I"); + ColorPickerInfoFc.red = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "red", "S"); + ColorPickerInfoFc.green = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "green", "S"); + ColorPickerInfoFc.blue = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "blue", "S"); + ColorPickerInfoFc.dstProfile = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "dstProfile", "I"); + ColorPickerInfoFc.flags = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "flags", "I"); + ColorPickerInfoFc.placeWhere = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "placeWhere", "S"); + ColorPickerInfoFc.h = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "h", "S"); + ColorPickerInfoFc.v = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "v", "S"); + ColorPickerInfoFc.pickerType = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "pickerType", "I"); + ColorPickerInfoFc.eventProc = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "eventProc", "I"); + ColorPickerInfoFc.colorProc = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "colorProc", "I"); + ColorPickerInfoFc.colorProcData = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "colorProcData", "I"); + ColorPickerInfoFc.prompt = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "prompt", "[B"); + ColorPickerInfoFc.editMenuID = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "editMenuID", "S"); + ColorPickerInfoFc.cutItem = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "cutItem", "S"); + ColorPickerInfoFc.copyItem = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "copyItem", "S"); + ColorPickerInfoFc.pasteItem = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "pasteItem", "S"); + ColorPickerInfoFc.clearItem = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "clearItem", "S"); + ColorPickerInfoFc.undoItem = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "undoItem", "S"); + ColorPickerInfoFc.newColorChosen = (*env)->GetFieldID(env, ColorPickerInfoFc.clazz, "newColorChosen", "Z"); + ColorPickerInfoFc.cached = 1; +} + +ColorPickerInfo *getColorPickerInfoFields(JNIEnv *env, jobject lpObject, ColorPickerInfo *lpStruct) +{ + if (!ColorPickerInfoFc.cached) cacheColorPickerInfoFids(env, lpObject); + lpStruct->theColor.profile = (CMProfileHandle)(*env)->GetIntField(env, lpObject, ColorPickerInfoFc.profile); + lpStruct->theColor.color.rgb.red = (UInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.red); + lpStruct->theColor.color.rgb.green = (UInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.green); + lpStruct->theColor.color.rgb.blue = (UInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.blue); + lpStruct->dstProfile = (CMProfileHandle)(*env)->GetIntField(env, lpObject, ColorPickerInfoFc.dstProfile); + lpStruct->flags = (UInt32)(*env)->GetIntField(env, lpObject, ColorPickerInfoFc.flags); + lpStruct->placeWhere = (DialogPlacementSpec)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.placeWhere); + lpStruct->dialogOrigin.h = (short)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.h); + lpStruct->dialogOrigin.v = (short)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.v); + lpStruct->pickerType = (OSType)(*env)->GetIntField(env, lpObject, ColorPickerInfoFc.pickerType); + lpStruct->eventProc = (UserEventUPP)(*env)->GetIntField(env, lpObject, ColorPickerInfoFc.eventProc); + lpStruct->colorProc = (ColorChangedUPP)(*env)->GetIntField(env, lpObject, ColorPickerInfoFc.colorProc); + lpStruct->colorProcData = (UInt32)(*env)->GetIntField(env, lpObject, ColorPickerInfoFc.colorProcData); + { + jbyteArray lpObject1 = (*env)->GetObjectField(env, lpObject, ColorPickerInfoFc.prompt); + (*env)->GetByteArrayRegion(env, lpObject1, 0, sizeof(lpStruct->prompt), lpStruct->prompt); + } + lpStruct->mInfo.editMenuID = (SInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.editMenuID); + lpStruct->mInfo.cutItem = (SInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.cutItem); + lpStruct->mInfo.copyItem = (SInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.copyItem); + lpStruct->mInfo.pasteItem = (SInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.pasteItem); + lpStruct->mInfo.clearItem = (SInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.clearItem); + lpStruct->mInfo.undoItem = (SInt16)(*env)->GetShortField(env, lpObject, ColorPickerInfoFc.undoItem); + lpStruct->newColorChosen = (Boolean)(*env)->GetBooleanField(env, lpObject, ColorPickerInfoFc.newColorChosen); + return lpStruct; +} + +void setColorPickerInfoFields(JNIEnv *env, jobject lpObject, ColorPickerInfo *lpStruct) +{ + if (!ColorPickerInfoFc.cached) cacheColorPickerInfoFids(env, lpObject); + (*env)->SetIntField(env, lpObject, ColorPickerInfoFc.profile, (jint)lpStruct->theColor.profile); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.red, (jshort)lpStruct->theColor.color.rgb.red); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.green, (jshort)lpStruct->theColor.color.rgb.green); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.blue, (jshort)lpStruct->theColor.color.rgb.blue); + (*env)->SetIntField(env, lpObject, ColorPickerInfoFc.dstProfile, (jint)lpStruct->dstProfile); + (*env)->SetIntField(env, lpObject, ColorPickerInfoFc.flags, (jint)lpStruct->flags); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.placeWhere, (jshort)lpStruct->placeWhere); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.h, (jshort)lpStruct->dialogOrigin.h); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.v, (jshort)lpStruct->dialogOrigin.v); + (*env)->SetIntField(env, lpObject, ColorPickerInfoFc.pickerType, (jint)lpStruct->pickerType); + (*env)->SetIntField(env, lpObject, ColorPickerInfoFc.eventProc, (jint)lpStruct->eventProc); + (*env)->SetIntField(env, lpObject, ColorPickerInfoFc.colorProc, (jint)lpStruct->colorProc); + (*env)->SetIntField(env, lpObject, ColorPickerInfoFc.colorProcData, (jint)lpStruct->colorProcData); + { + jbyteArray lpObject1 = (*env)->GetObjectField(env, lpObject, ColorPickerInfoFc.prompt); + (*env)->SetByteArrayRegion(env, lpObject1, 0, sizeof(lpStruct->prompt), lpStruct->prompt); + } + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.editMenuID, (jshort)lpStruct->mInfo.editMenuID); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.cutItem, (jshort)lpStruct->mInfo.cutItem); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.copyItem, (jshort)lpStruct->mInfo.copyItem); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.pasteItem, (jshort)lpStruct->mInfo.pasteItem); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.clearItem, (jshort)lpStruct->mInfo.clearItem); + (*env)->SetShortField(env, lpObject, ColorPickerInfoFc.undoItem, (jshort)lpStruct->mInfo.undoItem); + (*env)->SetBooleanField(env, lpObject, ColorPickerInfoFc.newColorChosen, (jboolean)lpStruct->newColorChosen); +} +#endif /* NO_ColorPickerInfo */ + +#ifndef NO_ControlButtonContentInfo +typedef struct ControlButtonContentInfo_FID_CACHE { + int cached; + jclass clazz; + jfieldID contentType, iconRef; +} ControlButtonContentInfo_FID_CACHE; + +ControlButtonContentInfo_FID_CACHE ControlButtonContentInfoFc; + +void cacheControlButtonContentInfoFids(JNIEnv *env, jobject lpObject) +{ + if (ControlButtonContentInfoFc.cached) return; + ControlButtonContentInfoFc.clazz = (*env)->GetObjectClass(env, lpObject); + ControlButtonContentInfoFc.contentType = (*env)->GetFieldID(env, ControlButtonContentInfoFc.clazz, "contentType", "S"); + ControlButtonContentInfoFc.iconRef = (*env)->GetFieldID(env, ControlButtonContentInfoFc.clazz, "iconRef", "I"); + ControlButtonContentInfoFc.cached = 1; +} + +ControlButtonContentInfo *getControlButtonContentInfoFields(JNIEnv *env, jobject lpObject, ControlButtonContentInfo *lpStruct) +{ + if (!ControlButtonContentInfoFc.cached) cacheControlButtonContentInfoFids(env, lpObject); + lpStruct->contentType = (ControlContentType)(*env)->GetShortField(env, lpObject, ControlButtonContentInfoFc.contentType); + lpStruct->u.iconRef = (void *)(*env)->GetIntField(env, lpObject, ControlButtonContentInfoFc.iconRef); + return lpStruct; +} + +void setControlButtonContentInfoFields(JNIEnv *env, jobject lpObject, ControlButtonContentInfo *lpStruct) +{ + if (!ControlButtonContentInfoFc.cached) cacheControlButtonContentInfoFids(env, lpObject); + (*env)->SetShortField(env, lpObject, ControlButtonContentInfoFc.contentType, (jshort)lpStruct->contentType); + (*env)->SetIntField(env, lpObject, ControlButtonContentInfoFc.iconRef, (jint)lpStruct->u.iconRef); +} +#endif /* NO_ControlButtonContentInfo */ + +#ifndef NO_ControlFontStyleRec +typedef struct ControlFontStyleRec_FID_CACHE { + int cached; + jclass clazz; + jfieldID flags, font, size, style, mode, just, foreColor_red, foreColor_green, foreColor_blue, backColor_red, backColor_green, backColor_blue; +} ControlFontStyleRec_FID_CACHE; + +ControlFontStyleRec_FID_CACHE ControlFontStyleRecFc; + +void cacheControlFontStyleRecFids(JNIEnv *env, jobject lpObject) +{ + if (ControlFontStyleRecFc.cached) return; + ControlFontStyleRecFc.clazz = (*env)->GetObjectClass(env, lpObject); + ControlFontStyleRecFc.flags = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "flags", "S"); + ControlFontStyleRecFc.font = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "font", "S"); + ControlFontStyleRecFc.size = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "size", "S"); + ControlFontStyleRecFc.style = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "style", "S"); + ControlFontStyleRecFc.mode = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "mode", "S"); + ControlFontStyleRecFc.just = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "just", "S"); + ControlFontStyleRecFc.foreColor_red = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "foreColor_red", "S"); + ControlFontStyleRecFc.foreColor_green = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "foreColor_green", "S"); + ControlFontStyleRecFc.foreColor_blue = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "foreColor_blue", "S"); + ControlFontStyleRecFc.backColor_red = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "backColor_red", "S"); + ControlFontStyleRecFc.backColor_green = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "backColor_green", "S"); + ControlFontStyleRecFc.backColor_blue = (*env)->GetFieldID(env, ControlFontStyleRecFc.clazz, "backColor_blue", "S"); + ControlFontStyleRecFc.cached = 1; +} + +ControlFontStyleRec *getControlFontStyleRecFields(JNIEnv *env, jobject lpObject, ControlFontStyleRec *lpStruct) +{ + if (!ControlFontStyleRecFc.cached) cacheControlFontStyleRecFids(env, lpObject); + lpStruct->flags = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.flags); + lpStruct->font = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.font); + lpStruct->size = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.size); + lpStruct->style = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.style); + lpStruct->mode = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.mode); + lpStruct->just = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.just); + lpStruct->foreColor.red = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.foreColor_red); + lpStruct->foreColor.green = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.foreColor_green); + lpStruct->foreColor.blue = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.foreColor_blue); + lpStruct->backColor.red = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.backColor_red); + lpStruct->backColor.green = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.backColor_green); + lpStruct->backColor.blue = (*env)->GetShortField(env, lpObject, ControlFontStyleRecFc.backColor_blue); + return lpStruct; +} + +void setControlFontStyleRecFields(JNIEnv *env, jobject lpObject, ControlFontStyleRec *lpStruct) +{ + if (!ControlFontStyleRecFc.cached) cacheControlFontStyleRecFids(env, lpObject); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.flags, (jshort)lpStruct->flags); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.font, (jshort)lpStruct->font); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.size, (jshort)lpStruct->size); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.style, (jshort)lpStruct->style); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.mode, (jshort)lpStruct->mode); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.just, (jshort)lpStruct->just); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.foreColor_red, (jshort)lpStruct->foreColor.red); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.foreColor_green, (jshort)lpStruct->foreColor.green); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.foreColor_blue, (jshort)lpStruct->foreColor.blue); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.backColor_red, (jshort)lpStruct->backColor.red); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.backColor_green, (jshort)lpStruct->backColor.green); + (*env)->SetShortField(env, lpObject, ControlFontStyleRecFc.backColor_blue, (jshort)lpStruct->backColor.blue); +} +#endif /* NO_ControlFontStyleRec */ + +#ifndef NO_ControlTabEntry +typedef struct ControlTabEntry_FID_CACHE { + int cached; + jclass clazz; + jfieldID icon, name, enabled; +} ControlTabEntry_FID_CACHE; + +ControlTabEntry_FID_CACHE ControlTabEntryFc; + +void cacheControlTabEntryFids(JNIEnv *env, jobject lpObject) +{ + if (ControlTabEntryFc.cached) return; + ControlTabEntryFc.clazz = (*env)->GetObjectClass(env, lpObject); + ControlTabEntryFc.icon = (*env)->GetFieldID(env, ControlTabEntryFc.clazz, "icon", "I"); + ControlTabEntryFc.name = (*env)->GetFieldID(env, ControlTabEntryFc.clazz, "name", "I"); + ControlTabEntryFc.enabled = (*env)->GetFieldID(env, ControlTabEntryFc.clazz, "enabled", "Z"); + ControlTabEntryFc.cached = 1; +} + +ControlTabEntry *getControlTabEntryFields(JNIEnv *env, jobject lpObject, ControlTabEntry *lpStruct) +{ + if (!ControlTabEntryFc.cached) cacheControlTabEntryFids(env, lpObject); + lpStruct->icon = (ControlButtonContentInfo *)(*env)->GetIntField(env, lpObject, ControlTabEntryFc.icon); + lpStruct->name = (CFStringRef)(*env)->GetIntField(env, lpObject, ControlTabEntryFc.name); + lpStruct->enabled = (Boolean)(*env)->GetBooleanField(env, lpObject, ControlTabEntryFc.enabled); + return lpStruct; +} + +void setControlTabEntryFields(JNIEnv *env, jobject lpObject, ControlTabEntry *lpStruct) +{ + if (!ControlTabEntryFc.cached) cacheControlTabEntryFids(env, lpObject); + (*env)->SetIntField(env, lpObject, ControlTabEntryFc.icon, (jint)lpStruct->icon); + (*env)->SetIntField(env, lpObject, ControlTabEntryFc.name, (jint)lpStruct->name); + (*env)->SetBooleanField(env, lpObject, ControlTabEntryFc.enabled, (jboolean)lpStruct->enabled); +} +#endif /* NO_ControlTabEntry */ + +#ifndef NO_ControlTabInfoRecV1 +typedef struct ControlTabInfoRecV1_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, iconSuiteID, name; +} ControlTabInfoRecV1_FID_CACHE; + +ControlTabInfoRecV1_FID_CACHE ControlTabInfoRecV1Fc; + +void cacheControlTabInfoRecV1Fids(JNIEnv *env, jobject lpObject) +{ + if (ControlTabInfoRecV1Fc.cached) return; + ControlTabInfoRecV1Fc.clazz = (*env)->GetObjectClass(env, lpObject); + ControlTabInfoRecV1Fc.version = (*env)->GetFieldID(env, ControlTabInfoRecV1Fc.clazz, "version", "S"); + ControlTabInfoRecV1Fc.iconSuiteID = (*env)->GetFieldID(env, ControlTabInfoRecV1Fc.clazz, "iconSuiteID", "S"); + ControlTabInfoRecV1Fc.name = (*env)->GetFieldID(env, ControlTabInfoRecV1Fc.clazz, "name", "I"); + ControlTabInfoRecV1Fc.cached = 1; +} + +ControlTabInfoRecV1 *getControlTabInfoRecV1Fields(JNIEnv *env, jobject lpObject, ControlTabInfoRecV1 *lpStruct) +{ + if (!ControlTabInfoRecV1Fc.cached) cacheControlTabInfoRecV1Fids(env, lpObject); + lpStruct->version = (SInt16)(*env)->GetShortField(env, lpObject, ControlTabInfoRecV1Fc.version); + lpStruct->iconSuiteID = (SInt16)(*env)->GetShortField(env, lpObject, ControlTabInfoRecV1Fc.iconSuiteID); + lpStruct->name = (CFStringRef)(*env)->GetIntField(env, lpObject, ControlTabInfoRecV1Fc.name); + return lpStruct; +} + +void setControlTabInfoRecV1Fields(JNIEnv *env, jobject lpObject, ControlTabInfoRecV1 *lpStruct) +{ + if (!ControlTabInfoRecV1Fc.cached) cacheControlTabInfoRecV1Fids(env, lpObject); + (*env)->SetShortField(env, lpObject, ControlTabInfoRecV1Fc.version, (jshort)lpStruct->version); + (*env)->SetShortField(env, lpObject, ControlTabInfoRecV1Fc.iconSuiteID, (jshort)lpStruct->iconSuiteID); + (*env)->SetIntField(env, lpObject, ControlTabInfoRecV1Fc.name, (jint)lpStruct->name); +} +#endif /* NO_ControlTabInfoRecV1 */ + +#ifndef NO_Cursor +typedef struct Cursor_FID_CACHE { + int cached; + jclass clazz; + jfieldID data, mask, hotSpot_v, hotSpot_h; +} Cursor_FID_CACHE; + +Cursor_FID_CACHE CursorFc; + +void cacheCursorFids(JNIEnv *env, jobject lpObject) +{ + if (CursorFc.cached) return; + CursorFc.clazz = (*env)->GetObjectClass(env, lpObject); + CursorFc.data = (*env)->GetFieldID(env, CursorFc.clazz, "data", "[S"); + CursorFc.mask = (*env)->GetFieldID(env, CursorFc.clazz, "mask", "[S"); + CursorFc.hotSpot_v = (*env)->GetFieldID(env, CursorFc.clazz, "hotSpot_v", "S"); + CursorFc.hotSpot_h = (*env)->GetFieldID(env, CursorFc.clazz, "hotSpot_h", "S"); + CursorFc.cached = 1; +} + +Cursor *getCursorFields(JNIEnv *env, jobject lpObject, Cursor *lpStruct) +{ + if (!CursorFc.cached) cacheCursorFids(env, lpObject); + { + jshortArray lpObject1 = (*env)->GetObjectField(env, lpObject, CursorFc.data); + (*env)->GetShortArrayRegion(env, lpObject1, 0, sizeof(lpStruct->data) / 2, lpStruct->data); + } + { + jshortArray lpObject1 = (*env)->GetObjectField(env, lpObject, CursorFc.mask); + (*env)->GetShortArrayRegion(env, lpObject1, 0, sizeof(lpStruct->mask) / 2, lpStruct->mask); + } + lpStruct->hotSpot.v = (*env)->GetShortField(env, lpObject, CursorFc.hotSpot_v); + lpStruct->hotSpot.h = (*env)->GetShortField(env, lpObject, CursorFc.hotSpot_h); + return lpStruct; +} + +void setCursorFields(JNIEnv *env, jobject lpObject, Cursor *lpStruct) +{ + if (!CursorFc.cached) cacheCursorFids(env, lpObject); + { + jshortArray lpObject1 = (*env)->GetObjectField(env, lpObject, CursorFc.data); + (*env)->SetShortArrayRegion(env, lpObject1, 0, sizeof(lpStruct->data) / 2, lpStruct->data); + } + { + jshortArray lpObject1 = (*env)->GetObjectField(env, lpObject, CursorFc.mask); + (*env)->SetShortArrayRegion(env, lpObject1, 0, sizeof(lpStruct->mask) / 2, lpStruct->mask); + } + (*env)->SetShortField(env, lpObject, CursorFc.hotSpot_v, (jshort)lpStruct->hotSpot.v); + (*env)->SetShortField(env, lpObject, CursorFc.hotSpot_h, (jshort)lpStruct->hotSpot.h); +} +#endif /* NO_Cursor */ + +#ifndef NO_DataBrowserCallbacks +typedef struct DataBrowserCallbacks_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, v1_itemDataCallback, v1_itemCompareCallback, v1_itemNotificationCallback, v1_addDragItemCallback, v1_acceptDragCallback, v1_receiveDragCallback, v1_postProcessDragCallback, v1_itemHelpContentCallback, v1_getContextualMenuCallback, v1_selectContextualMenuCallback; +} DataBrowserCallbacks_FID_CACHE; + +DataBrowserCallbacks_FID_CACHE DataBrowserCallbacksFc; + +void cacheDataBrowserCallbacksFids(JNIEnv *env, jobject lpObject) +{ + if (DataBrowserCallbacksFc.cached) return; + DataBrowserCallbacksFc.clazz = (*env)->GetObjectClass(env, lpObject); + DataBrowserCallbacksFc.version = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "version", "I"); + DataBrowserCallbacksFc.v1_itemDataCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_itemDataCallback", "I"); + DataBrowserCallbacksFc.v1_itemCompareCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_itemCompareCallback", "I"); + DataBrowserCallbacksFc.v1_itemNotificationCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_itemNotificationCallback", "I"); + DataBrowserCallbacksFc.v1_addDragItemCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_addDragItemCallback", "I"); + DataBrowserCallbacksFc.v1_acceptDragCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_acceptDragCallback", "I"); + DataBrowserCallbacksFc.v1_receiveDragCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_receiveDragCallback", "I"); + DataBrowserCallbacksFc.v1_postProcessDragCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_postProcessDragCallback", "I"); + DataBrowserCallbacksFc.v1_itemHelpContentCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_itemHelpContentCallback", "I"); + DataBrowserCallbacksFc.v1_getContextualMenuCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_getContextualMenuCallback", "I"); + DataBrowserCallbacksFc.v1_selectContextualMenuCallback = (*env)->GetFieldID(env, DataBrowserCallbacksFc.clazz, "v1_selectContextualMenuCallback", "I"); + DataBrowserCallbacksFc.cached = 1; +} + +DataBrowserCallbacks *getDataBrowserCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCallbacks *lpStruct) +{ + if (!DataBrowserCallbacksFc.cached) cacheDataBrowserCallbacksFids(env, lpObject); + lpStruct->version = (UInt32)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.version); + lpStruct->u.v1.itemDataCallback = (DataBrowserItemDataUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemDataCallback); + lpStruct->u.v1.itemCompareCallback = (DataBrowserItemCompareUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemCompareCallback); + lpStruct->u.v1.itemNotificationCallback = (DataBrowserItemNotificationUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemNotificationCallback); + lpStruct->u.v1.addDragItemCallback = (DataBrowserAddDragItemUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_addDragItemCallback); + lpStruct->u.v1.acceptDragCallback = (DataBrowserAcceptDragUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_acceptDragCallback); + lpStruct->u.v1.receiveDragCallback = (DataBrowserReceiveDragUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_receiveDragCallback); + lpStruct->u.v1.postProcessDragCallback = (DataBrowserPostProcessDragUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_postProcessDragCallback); + lpStruct->u.v1.itemHelpContentCallback = (DataBrowserItemHelpContentUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemHelpContentCallback); + lpStruct->u.v1.getContextualMenuCallback = (DataBrowserGetContextualMenuUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_getContextualMenuCallback); + lpStruct->u.v1.selectContextualMenuCallback = (DataBrowserSelectContextualMenuUPP)(*env)->GetIntField(env, lpObject, DataBrowserCallbacksFc.v1_selectContextualMenuCallback); + return lpStruct; +} + +void setDataBrowserCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCallbacks *lpStruct) +{ + if (!DataBrowserCallbacksFc.cached) cacheDataBrowserCallbacksFids(env, lpObject); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.version, (jint)lpStruct->version); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemDataCallback, (jint)lpStruct->u.v1.itemDataCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemCompareCallback, (jint)lpStruct->u.v1.itemCompareCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemNotificationCallback, (jint)lpStruct->u.v1.itemNotificationCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_addDragItemCallback, (jint)lpStruct->u.v1.addDragItemCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_acceptDragCallback, (jint)lpStruct->u.v1.acceptDragCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_receiveDragCallback, (jint)lpStruct->u.v1.receiveDragCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_postProcessDragCallback, (jint)lpStruct->u.v1.postProcessDragCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_itemHelpContentCallback, (jint)lpStruct->u.v1.itemHelpContentCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_getContextualMenuCallback, (jint)lpStruct->u.v1.getContextualMenuCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCallbacksFc.v1_selectContextualMenuCallback, (jint)lpStruct->u.v1.selectContextualMenuCallback); +} +#endif /* NO_DataBrowserCallbacks */ + +#ifndef NO_DataBrowserCustomCallbacks +typedef struct DataBrowserCustomCallbacks_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, v1_drawItemCallback, v1_editTextCallback, v1_hitTestCallback, v1_trackingCallback, v1_dragRegionCallback, v1_acceptDragCallback, v1_receiveDragCallback; +} DataBrowserCustomCallbacks_FID_CACHE; + +DataBrowserCustomCallbacks_FID_CACHE DataBrowserCustomCallbacksFc; + +void cacheDataBrowserCustomCallbacksFids(JNIEnv *env, jobject lpObject) +{ + if (DataBrowserCustomCallbacksFc.cached) return; + DataBrowserCustomCallbacksFc.clazz = (*env)->GetObjectClass(env, lpObject); + DataBrowserCustomCallbacksFc.version = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "version", "I"); + DataBrowserCustomCallbacksFc.v1_drawItemCallback = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "v1_drawItemCallback", "I"); + DataBrowserCustomCallbacksFc.v1_editTextCallback = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "v1_editTextCallback", "I"); + DataBrowserCustomCallbacksFc.v1_hitTestCallback = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "v1_hitTestCallback", "I"); + DataBrowserCustomCallbacksFc.v1_trackingCallback = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "v1_trackingCallback", "I"); + DataBrowserCustomCallbacksFc.v1_dragRegionCallback = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "v1_dragRegionCallback", "I"); + DataBrowserCustomCallbacksFc.v1_acceptDragCallback = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "v1_acceptDragCallback", "I"); + DataBrowserCustomCallbacksFc.v1_receiveDragCallback = (*env)->GetFieldID(env, DataBrowserCustomCallbacksFc.clazz, "v1_receiveDragCallback", "I"); + DataBrowserCustomCallbacksFc.cached = 1; +} + +DataBrowserCustomCallbacks *getDataBrowserCustomCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCustomCallbacks *lpStruct) +{ + if (!DataBrowserCustomCallbacksFc.cached) cacheDataBrowserCustomCallbacksFids(env, lpObject); + lpStruct->version = (*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.version); + lpStruct->u.v1.drawItemCallback = (DataBrowserDrawItemUPP) (*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_drawItemCallback); + lpStruct->u.v1.editTextCallback = (DataBrowserEditItemUPP)(*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_editTextCallback); + lpStruct->u.v1.hitTestCallback = (DataBrowserHitTestUPP)(*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_hitTestCallback); + lpStruct->u.v1.trackingCallback = (DataBrowserTrackingUPP)(*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_trackingCallback); + lpStruct->u.v1.dragRegionCallback = (DataBrowserItemDragRgnUPP)(*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_dragRegionCallback); + lpStruct->u.v1.acceptDragCallback = (DataBrowserItemAcceptDragUPP)(*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_acceptDragCallback); + lpStruct->u.v1.receiveDragCallback = (DataBrowserItemReceiveDragUPP)(*env)->GetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_receiveDragCallback); + return lpStruct; +} + +void setDataBrowserCustomCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCustomCallbacks *lpStruct) +{ + if (!DataBrowserCustomCallbacksFc.cached) cacheDataBrowserCustomCallbacksFids(env, lpObject); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.version, (jint)lpStruct->version); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_drawItemCallback, (jint)lpStruct->u.v1.drawItemCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_editTextCallback, (jint)lpStruct->u.v1.editTextCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_hitTestCallback, (jint)lpStruct->u.v1.hitTestCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_trackingCallback, (jint)lpStruct->u.v1.trackingCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_dragRegionCallback, (jint)lpStruct->u.v1.dragRegionCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_acceptDragCallback, (jint)lpStruct->u.v1.acceptDragCallback); + (*env)->SetIntField(env, lpObject, DataBrowserCustomCallbacksFc.v1_receiveDragCallback, (jint)lpStruct->u.v1.receiveDragCallback); +} +#endif /* NO_DataBrowserCustomCallbacks */ + +#ifndef NO_DataBrowserListViewColumnDesc +typedef struct DataBrowserListViewColumnDesc_FID_CACHE { + int cached; + jclass clazz; + jfieldID propertyDesc_propertyID, propertyDesc_propertyType, propertyDesc_propertyFlags, headerBtnDesc_version, headerBtnDesc_minimumWidth, headerBtnDesc_maximumWidth, headerBtnDesc_titleOffset, headerBtnDesc_titleString, headerBtnDesc_initialOrder, headerBtnDesc_btnFontStyle_flags, headerBtnDesc_btnFontStyle_font, headerBtnDesc_btnFontStyle_size, headerBtnDesc_btnFontStyle_style, headerBtnDesc_btnFontStyle_mode, headerBtnDesc_btnFontStyle_just, headerBtnDesc_btnFontStyle_foreColor_red, headerBtnDesc_btnFontStyle_foreColor_green, headerBtnDesc_btnFontStyle_foreColor_blue, headerBtnDesc_btnFontStyle_backColor_red, headerBtnDesc_btnFontStyle_backColor_green, headerBtnDesc_btnFontStyle_backColor_blue, headerBtnDesc_btnContentInfo_contentType, headerBtnDesc_btnContentInfo_iconRef; +} DataBrowserListViewColumnDesc_FID_CACHE; + +DataBrowserListViewColumnDesc_FID_CACHE DataBrowserListViewColumnDescFc; + +void cacheDataBrowserListViewColumnDescFids(JNIEnv *env, jobject lpObject) +{ + if (DataBrowserListViewColumnDescFc.cached) return; + DataBrowserListViewColumnDescFc.clazz = (*env)->GetObjectClass(env, lpObject); + DataBrowserListViewColumnDescFc.propertyDesc_propertyID = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "propertyDesc_propertyID", "I"); + DataBrowserListViewColumnDescFc.propertyDesc_propertyType = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "propertyDesc_propertyType", "I"); + DataBrowserListViewColumnDescFc.propertyDesc_propertyFlags = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "propertyDesc_propertyFlags", "I"); + DataBrowserListViewColumnDescFc.headerBtnDesc_version = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_version", "I"); + DataBrowserListViewColumnDescFc.headerBtnDesc_minimumWidth = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_minimumWidth", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_maximumWidth = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_maximumWidth", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_titleOffset = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_titleOffset", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_titleString = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_titleString", "I"); + DataBrowserListViewColumnDescFc.headerBtnDesc_initialOrder = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_initialOrder", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_flags = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_flags", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_font = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_font", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_size = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_size", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_style = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_style", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_mode = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_mode", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_just = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_just", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_red = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_foreColor_red", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_green = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_foreColor_green", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_blue = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_foreColor_blue", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_red = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_backColor_red", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_green = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_backColor_green", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_blue = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnFontStyle_backColor_blue", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnContentInfo_contentType = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnContentInfo_contentType", "S"); + DataBrowserListViewColumnDescFc.headerBtnDesc_btnContentInfo_iconRef = (*env)->GetFieldID(env, DataBrowserListViewColumnDescFc.clazz, "headerBtnDesc_btnContentInfo_iconRef", "I"); + DataBrowserListViewColumnDescFc.cached = 1; +} + +DataBrowserListViewColumnDesc *getDataBrowserListViewColumnDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewColumnDesc *lpStruct) +{ + if (!DataBrowserListViewColumnDescFc.cached) cacheDataBrowserListViewColumnDescFids(env, lpObject); + lpStruct->propertyDesc.propertyID = (DataBrowserPropertyID)(*env)->GetIntField(env, lpObject, DataBrowserListViewColumnDescFc.propertyDesc_propertyID); + lpStruct->propertyDesc.propertyType = (OSType)(*env)->GetIntField(env, lpObject, DataBrowserListViewColumnDescFc.propertyDesc_propertyType); + lpStruct->propertyDesc.propertyFlags = (DataBrowserPropertyFlags)(*env)->GetIntField(env, lpObject, DataBrowserListViewColumnDescFc.propertyDesc_propertyFlags); + lpStruct->headerBtnDesc.version = (UInt32)(*env)->GetIntField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_version); + lpStruct->headerBtnDesc.minimumWidth = (UInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_minimumWidth); + lpStruct->headerBtnDesc.maximumWidth = (UInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_maximumWidth); + lpStruct->headerBtnDesc.titleOffset = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_titleOffset); + lpStruct->headerBtnDesc.titleString = (CFStringRef)(*env)->GetIntField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_titleString); + lpStruct->headerBtnDesc.initialOrder = (DataBrowserSortOrder)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_initialOrder); + lpStruct->headerBtnDesc.btnFontStyle.flags = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_flags); + lpStruct->headerBtnDesc.btnFontStyle.font = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_font); + lpStruct->headerBtnDesc.btnFontStyle.size = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_size); + lpStruct->headerBtnDesc.btnFontStyle.style = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_style); + lpStruct->headerBtnDesc.btnFontStyle.mode = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_mode); + lpStruct->headerBtnDesc.btnFontStyle.just = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_just); + lpStruct->headerBtnDesc.btnFontStyle.foreColor.red = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_red); + lpStruct->headerBtnDesc.btnFontStyle.foreColor.green = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_green); + lpStruct->headerBtnDesc.btnFontStyle.foreColor.blue = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_blue); + lpStruct->headerBtnDesc.btnFontStyle.backColor.red = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_red); + lpStruct->headerBtnDesc.btnFontStyle.backColor.green = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_green); + lpStruct->headerBtnDesc.btnFontStyle.backColor.blue = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_blue); + lpStruct->headerBtnDesc.btnContentInfo.contentType = (ControlContentType)(*env)->GetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnContentInfo_contentType); + lpStruct->headerBtnDesc.btnContentInfo.u.iconRef = (IconRef)(*env)->GetIntField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnContentInfo_iconRef); + return lpStruct; +} + +void setDataBrowserListViewColumnDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewColumnDesc *lpStruct) +{ + if (!DataBrowserListViewColumnDescFc.cached) cacheDataBrowserListViewColumnDescFids(env, lpObject); + (*env)->SetIntField(env, lpObject, DataBrowserListViewColumnDescFc.propertyDesc_propertyID, (jint)lpStruct->propertyDesc.propertyID); + (*env)->SetIntField(env, lpObject, DataBrowserListViewColumnDescFc.propertyDesc_propertyType, (jint)lpStruct->propertyDesc.propertyType); + (*env)->SetIntField(env, lpObject, DataBrowserListViewColumnDescFc.propertyDesc_propertyFlags, (jint)lpStruct->propertyDesc.propertyFlags); + (*env)->SetIntField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_version, (jint)lpStruct->headerBtnDesc.version); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_minimumWidth, (jshort)lpStruct->headerBtnDesc.minimumWidth); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_maximumWidth, (jshort)lpStruct->headerBtnDesc.maximumWidth); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_titleOffset, (jshort)lpStruct->headerBtnDesc.titleOffset); + (*env)->SetIntField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_titleString, (jint)lpStruct->headerBtnDesc.titleString); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_initialOrder, (jshort)lpStruct->headerBtnDesc.initialOrder); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_flags, (jshort)lpStruct->headerBtnDesc.btnFontStyle.flags); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_font, (jshort)lpStruct->headerBtnDesc.btnFontStyle.font); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_size, (jshort)lpStruct->headerBtnDesc.btnFontStyle.size); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_style, (jshort)lpStruct->headerBtnDesc.btnFontStyle.style); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_mode, (jshort)lpStruct->headerBtnDesc.btnFontStyle.mode); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_just, (jshort)lpStruct->headerBtnDesc.btnFontStyle.just); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_red, (jshort)lpStruct->headerBtnDesc.btnFontStyle.foreColor.red); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_green, (jshort)lpStruct->headerBtnDesc.btnFontStyle.foreColor.green); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_foreColor_blue, (jshort)lpStruct->headerBtnDesc.btnFontStyle.foreColor.blue); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_red, (jshort)lpStruct->headerBtnDesc.btnFontStyle.backColor.red); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_green, (jshort)lpStruct->headerBtnDesc.btnFontStyle.backColor.green); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnFontStyle_backColor_blue, (jshort)lpStruct->headerBtnDesc.btnFontStyle.backColor.blue); + (*env)->SetShortField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnContentInfo_contentType, (jshort)lpStruct->headerBtnDesc.btnContentInfo.contentType); + (*env)->SetIntField(env, lpObject, DataBrowserListViewColumnDescFc.headerBtnDesc_btnContentInfo_iconRef, (jint)lpStruct->headerBtnDesc.btnContentInfo.u.iconRef); +} +#endif /* NO_DataBrowserListViewColumnDesc */ + +#ifndef NO_DataBrowserListViewHeaderDesc +typedef struct DataBrowserListViewHeaderDesc_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, minimumWidth, maximumWidth, titleOffset, titleString, initialOrder, btnFontStyle_flags, btnFontStyle_font, btnFontStyle_size, btnFontStyle_style, btnFontStyle_mode, btnFontStyle_just, btnFontStyle_foreColor_red, btnFontStyle_foreColor_green, btnFontStyle_foreColor_blue, btnFontStyle_backColor_red, btnFontStyle_backColor_green, btnFontStyle_backColor_blue, btnContentInfo_contentType, btnContentInfo_iconRef; +} DataBrowserListViewHeaderDesc_FID_CACHE; + +DataBrowserListViewHeaderDesc_FID_CACHE DataBrowserListViewHeaderDescFc; + +void cacheDataBrowserListViewHeaderDescFids(JNIEnv *env, jobject lpObject) +{ + if (DataBrowserListViewHeaderDescFc.cached) return; + DataBrowserListViewHeaderDescFc.clazz = (*env)->GetObjectClass(env, lpObject); + DataBrowserListViewHeaderDescFc.version = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "version", "I"); + DataBrowserListViewHeaderDescFc.minimumWidth = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "minimumWidth", "S"); + DataBrowserListViewHeaderDescFc.maximumWidth = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "maximumWidth", "S"); + DataBrowserListViewHeaderDescFc.titleOffset = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "titleOffset", "S"); + DataBrowserListViewHeaderDescFc.titleString = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "titleString", "I"); + DataBrowserListViewHeaderDescFc.initialOrder = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "initialOrder", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_flags = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_flags", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_font = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_font", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_size = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_size", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_style = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_style", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_mode = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_mode", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_just = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_just", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_red = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_foreColor_red", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_green = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_foreColor_green", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_blue = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_foreColor_blue", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_red = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_backColor_red", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_green = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_backColor_green", "S"); + DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_blue = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnFontStyle_backColor_blue", "S"); + DataBrowserListViewHeaderDescFc.btnContentInfo_contentType = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnContentInfo_contentType", "S"); + DataBrowserListViewHeaderDescFc.btnContentInfo_iconRef = (*env)->GetFieldID(env, DataBrowserListViewHeaderDescFc.clazz, "btnContentInfo_iconRef", "I"); + DataBrowserListViewHeaderDescFc.cached = 1; +} + +DataBrowserListViewHeaderDesc *getDataBrowserListViewHeaderDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewHeaderDesc *lpStruct) +{ + if (!DataBrowserListViewHeaderDescFc.cached) cacheDataBrowserListViewHeaderDescFids(env, lpObject); + lpStruct->version = (UInt32)(*env)->GetIntField(env, lpObject, DataBrowserListViewHeaderDescFc.version); + lpStruct->minimumWidth = (UInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.minimumWidth); + lpStruct->maximumWidth = (UInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.maximumWidth); + lpStruct->titleOffset = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.titleOffset); + lpStruct->titleString = (CFStringRef)(*env)->GetIntField(env, lpObject, DataBrowserListViewHeaderDescFc.titleString); + lpStruct->initialOrder = (DataBrowserSortOrder)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.initialOrder); + lpStruct->btnFontStyle.flags = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_flags); + lpStruct->btnFontStyle.font = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_font); + lpStruct->btnFontStyle.size = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_size); + lpStruct->btnFontStyle.style = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_style); + lpStruct->btnFontStyle.mode = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_mode); + lpStruct->btnFontStyle.just = (SInt16)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_just); + lpStruct->btnFontStyle.foreColor.red = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_red); + lpStruct->btnFontStyle.foreColor.green = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_green); + lpStruct->btnFontStyle.foreColor.blue = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_blue); + lpStruct->btnFontStyle.backColor.red = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_red); + lpStruct->btnFontStyle.backColor.green = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_green); + lpStruct->btnFontStyle.backColor.blue = (unsigned short)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_blue); + lpStruct->btnContentInfo.contentType = (ControlContentType)(*env)->GetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnContentInfo_contentType); + lpStruct->btnContentInfo.u.iconRef = (IconRef)(*env)->GetIntField(env, lpObject, DataBrowserListViewHeaderDescFc.btnContentInfo_iconRef); + return lpStruct; +} + +void setDataBrowserListViewHeaderDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewHeaderDesc *lpStruct) +{ + if (!DataBrowserListViewHeaderDescFc.cached) cacheDataBrowserListViewHeaderDescFids(env, lpObject); + (*env)->SetIntField(env, lpObject, DataBrowserListViewHeaderDescFc.version, (jint)lpStruct->version); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.minimumWidth, (jshort)lpStruct->minimumWidth); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.maximumWidth, (jshort)lpStruct->maximumWidth); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.titleOffset, (jshort)lpStruct->titleOffset); + (*env)->SetIntField(env, lpObject, DataBrowserListViewHeaderDescFc.titleString, (jint)lpStruct->titleString); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.initialOrder, (jshort)lpStruct->initialOrder); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_flags, (jshort)lpStruct->btnFontStyle.flags); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_font, (jshort)lpStruct->btnFontStyle.font); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_size, (jshort)lpStruct->btnFontStyle.size); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_style, (jshort)lpStruct->btnFontStyle.style); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_mode, (jshort)lpStruct->btnFontStyle.mode); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_just, (jshort)lpStruct->btnFontStyle.just); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_red, (jshort)lpStruct->btnFontStyle.foreColor.red); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_green, (jshort)lpStruct->btnFontStyle.foreColor.green); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_foreColor_blue, (jshort)lpStruct->btnFontStyle.foreColor.blue); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_red, (jshort)lpStruct->btnFontStyle.backColor.red); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_green, (jshort)lpStruct->btnFontStyle.backColor.green); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnFontStyle_backColor_blue, (jshort)lpStruct->btnFontStyle.backColor.blue); + (*env)->SetShortField(env, lpObject, DataBrowserListViewHeaderDescFc.btnContentInfo_contentType, (jshort)lpStruct->btnContentInfo.contentType); + (*env)->SetIntField(env, lpObject, DataBrowserListViewHeaderDescFc.btnContentInfo_iconRef, (jint)lpStruct->btnContentInfo.u.iconRef); +} +#endif /* NO_DataBrowserListViewHeaderDesc */ + +#ifndef NO_EventRecord +typedef struct EventRecord_FID_CACHE { + int cached; + jclass clazz; + jfieldID what, message, when, where_v, where_h, modifiers; +} EventRecord_FID_CACHE; + +EventRecord_FID_CACHE EventRecordFc; + +void cacheEventRecordFids(JNIEnv *env, jobject lpObject) +{ + if (EventRecordFc.cached) return; + EventRecordFc.clazz = (*env)->GetObjectClass(env, lpObject); + EventRecordFc.what = (*env)->GetFieldID(env, EventRecordFc.clazz, "what", "S"); + EventRecordFc.message = (*env)->GetFieldID(env, EventRecordFc.clazz, "message", "I"); + EventRecordFc.when = (*env)->GetFieldID(env, EventRecordFc.clazz, "when", "I"); + EventRecordFc.where_v = (*env)->GetFieldID(env, EventRecordFc.clazz, "where_v", "S"); + EventRecordFc.where_h = (*env)->GetFieldID(env, EventRecordFc.clazz, "where_h", "S"); + EventRecordFc.modifiers = (*env)->GetFieldID(env, EventRecordFc.clazz, "modifiers", "S"); + EventRecordFc.cached = 1; +} + +EventRecord *getEventRecordFields(JNIEnv *env, jobject lpObject, EventRecord *lpStruct) +{ + if (!EventRecordFc.cached) cacheEventRecordFids(env, lpObject); + lpStruct->what = (EventKind)(*env)->GetShortField(env, lpObject, EventRecordFc.what); + lpStruct->message = (*env)->GetIntField(env, lpObject, EventRecordFc.message); + lpStruct->when = (*env)->GetIntField(env, lpObject, EventRecordFc.when); + lpStruct->where.v = (*env)->GetShortField(env, lpObject, EventRecordFc.where_v); + lpStruct->where.h = (*env)->GetShortField(env, lpObject, EventRecordFc.where_h); + lpStruct->modifiers = (EventModifiers)(*env)->GetShortField(env, lpObject, EventRecordFc.modifiers); + return lpStruct; +} + +void setEventRecordFields(JNIEnv *env, jobject lpObject, EventRecord *lpStruct) +{ + if (!EventRecordFc.cached) cacheEventRecordFids(env, lpObject); + (*env)->SetShortField(env, lpObject, EventRecordFc.what, (jshort)lpStruct->what); + (*env)->SetIntField(env, lpObject, EventRecordFc.message, (jint)lpStruct->message); + (*env)->SetIntField(env, lpObject, EventRecordFc.when, (jint)lpStruct->when); + (*env)->SetShortField(env, lpObject, EventRecordFc.where_v, (jshort)lpStruct->where.v); + (*env)->SetShortField(env, lpObject, EventRecordFc.where_h, (jshort)lpStruct->where.h); + (*env)->SetShortField(env, lpObject, EventRecordFc.modifiers, (jshort)lpStruct->modifiers); +} +#endif /* NO_EventRecord */ + +#ifndef NO_FontInfo +typedef struct FontInfo_FID_CACHE { + int cached; + jclass clazz; + jfieldID ascent, descent, widMax, leading; +} FontInfo_FID_CACHE; + +FontInfo_FID_CACHE FontInfoFc; + +void cacheFontInfoFids(JNIEnv *env, jobject lpObject) +{ + if (FontInfoFc.cached) return; + FontInfoFc.clazz = (*env)->GetObjectClass(env, lpObject); + FontInfoFc.ascent = (*env)->GetFieldID(env, FontInfoFc.clazz, "ascent", "S"); + FontInfoFc.descent = (*env)->GetFieldID(env, FontInfoFc.clazz, "descent", "S"); + FontInfoFc.widMax = (*env)->GetFieldID(env, FontInfoFc.clazz, "widMax", "S"); + FontInfoFc.leading = (*env)->GetFieldID(env, FontInfoFc.clazz, "leading", "S"); + FontInfoFc.cached = 1; +} + +FontInfo *getFontInfoFields(JNIEnv *env, jobject lpObject, FontInfo *lpStruct) +{ + if (!FontInfoFc.cached) cacheFontInfoFids(env, lpObject); + lpStruct->ascent = (*env)->GetShortField(env, lpObject, FontInfoFc.ascent); + lpStruct->descent = (*env)->GetShortField(env, lpObject, FontInfoFc.descent); + lpStruct->widMax = (*env)->GetShortField(env, lpObject, FontInfoFc.widMax); + lpStruct->leading = (*env)->GetShortField(env, lpObject, FontInfoFc.leading); + return lpStruct; +} + +void setFontInfoFields(JNIEnv *env, jobject lpObject, FontInfo *lpStruct) +{ + if (!FontInfoFc.cached) cacheFontInfoFids(env, lpObject); + (*env)->SetShortField(env, lpObject, FontInfoFc.ascent, (jshort)lpStruct->ascent); + (*env)->SetShortField(env, lpObject, FontInfoFc.descent, (jshort)lpStruct->descent); + (*env)->SetShortField(env, lpObject, FontInfoFc.widMax, (jshort)lpStruct->widMax); + (*env)->SetShortField(env, lpObject, FontInfoFc.leading, (jshort)lpStruct->leading); +} +#endif /* NO_FontInfo */ + +#ifndef NO_FontSelectionQDStyle +typedef struct FontSelectionQDStyle_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, instance_fontFamily, instance_fontStyle, size, hasColor, reserved, color_red, color_green, color_blue; +} FontSelectionQDStyle_FID_CACHE; + +FontSelectionQDStyle_FID_CACHE FontSelectionQDStyleFc; + +void cacheFontSelectionQDStyleFids(JNIEnv *env, jobject lpObject) +{ + if (FontSelectionQDStyleFc.cached) return; + FontSelectionQDStyleFc.clazz = (*env)->GetObjectClass(env, lpObject); + FontSelectionQDStyleFc.version = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "version", "I"); + FontSelectionQDStyleFc.instance_fontFamily = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "instance_fontFamily", "S"); + FontSelectionQDStyleFc.instance_fontStyle = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "instance_fontStyle", "S"); + FontSelectionQDStyleFc.size = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "size", "S"); + FontSelectionQDStyleFc.hasColor = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "hasColor", "Z"); + FontSelectionQDStyleFc.reserved = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "reserved", "B"); + FontSelectionQDStyleFc.color_red = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "color_red", "S"); + FontSelectionQDStyleFc.color_green = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "color_green", "S"); + FontSelectionQDStyleFc.color_blue = (*env)->GetFieldID(env, FontSelectionQDStyleFc.clazz, "color_blue", "S"); + FontSelectionQDStyleFc.cached = 1; +} + +FontSelectionQDStyle *getFontSelectionQDStyleFields(JNIEnv *env, jobject lpObject, FontSelectionQDStyle *lpStruct) +{ + if (!FontSelectionQDStyleFc.cached) cacheFontSelectionQDStyleFids(env, lpObject); + lpStruct->version = (UInt32)(*env)->GetIntField(env, lpObject, FontSelectionQDStyleFc.version); + lpStruct->instance.fontFamily = (FMFontFamily)(*env)->GetShortField(env, lpObject, FontSelectionQDStyleFc.instance_fontFamily); + lpStruct->instance.fontStyle = (FMFontStyle)(*env)->GetShortField(env, lpObject, FontSelectionQDStyleFc.instance_fontStyle); + lpStruct->size = (FMFontSize)(*env)->GetShortField(env, lpObject, FontSelectionQDStyleFc.size); + lpStruct->hasColor = (Boolean)(*env)->GetBooleanField(env, lpObject, FontSelectionQDStyleFc.hasColor); + lpStruct->reserved = (UInt8)(*env)->GetByteField(env, lpObject, FontSelectionQDStyleFc.reserved); + lpStruct->color.red = (*env)->GetShortField(env, lpObject, FontSelectionQDStyleFc.color_red); + lpStruct->color.green = (*env)->GetShortField(env, lpObject, FontSelectionQDStyleFc.color_green); + lpStruct->color.blue = (*env)->GetShortField(env, lpObject, FontSelectionQDStyleFc.color_blue); + return lpStruct; +} + +void setFontSelectionQDStyleFields(JNIEnv *env, jobject lpObject, FontSelectionQDStyle *lpStruct) +{ + if (!FontSelectionQDStyleFc.cached) cacheFontSelectionQDStyleFids(env, lpObject); + (*env)->SetIntField(env, lpObject, FontSelectionQDStyleFc.version, (jint)lpStruct->version); + (*env)->SetShortField(env, lpObject, FontSelectionQDStyleFc.instance_fontFamily, (jshort)lpStruct->instance.fontFamily); + (*env)->SetShortField(env, lpObject, FontSelectionQDStyleFc.instance_fontStyle, (jshort)lpStruct->instance.fontStyle); + (*env)->SetShortField(env, lpObject, FontSelectionQDStyleFc.size, (jshort)lpStruct->size); + (*env)->SetBooleanField(env, lpObject, FontSelectionQDStyleFc.hasColor, (jboolean)lpStruct->hasColor); + (*env)->SetByteField(env, lpObject, FontSelectionQDStyleFc.reserved, (jbyte)lpStruct->reserved); + (*env)->SetShortField(env, lpObject, FontSelectionQDStyleFc.color_red, (jshort)lpStruct->color.red); + (*env)->SetShortField(env, lpObject, FontSelectionQDStyleFc.color_green, (jshort)lpStruct->color.green); + (*env)->SetShortField(env, lpObject, FontSelectionQDStyleFc.color_blue, (jshort)lpStruct->color.blue); +} +#endif /* NO_FontSelectionQDStyle */ + +#ifndef NO_GDevice +typedef struct GDevice_FID_CACHE { + int cached; + jclass clazz; + jfieldID gdRefNum, gdID, gdType, gdITable, gdResPref, gdSearchProc, gdCompProc, gdFlags, gdPMap, gdRefCon, gdNextGD, left, top, right, bottom, gdMode, gdCCBytes, gdCCDepth, gdCCXData, gdCCXMask, gdExt; +} GDevice_FID_CACHE; + +GDevice_FID_CACHE GDeviceFc; + +void cacheGDeviceFids(JNIEnv *env, jobject lpObject) +{ + if (GDeviceFc.cached) return; + GDeviceFc.clazz = (*env)->GetObjectClass(env, lpObject); + GDeviceFc.gdRefNum = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdRefNum", "S"); + GDeviceFc.gdID = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdID", "S"); + GDeviceFc.gdType = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdType", "S"); + GDeviceFc.gdITable = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdITable", "I"); + GDeviceFc.gdResPref = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdResPref", "S"); + GDeviceFc.gdSearchProc = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdSearchProc", "I"); + GDeviceFc.gdCompProc = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdCompProc", "I"); + GDeviceFc.gdFlags = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdFlags", "S"); + GDeviceFc.gdPMap = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdPMap", "I"); + GDeviceFc.gdRefCon = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdRefCon", "I"); + GDeviceFc.gdNextGD = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdNextGD", "I"); + GDeviceFc.left = (*env)->GetFieldID(env, GDeviceFc.clazz, "left", "S"); + GDeviceFc.top = (*env)->GetFieldID(env, GDeviceFc.clazz, "top", "S"); + GDeviceFc.right = (*env)->GetFieldID(env, GDeviceFc.clazz, "right", "S"); + GDeviceFc.bottom = (*env)->GetFieldID(env, GDeviceFc.clazz, "bottom", "S"); + GDeviceFc.gdMode = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdMode", "I"); + GDeviceFc.gdCCBytes = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdCCBytes", "S"); + GDeviceFc.gdCCDepth = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdCCDepth", "S"); + GDeviceFc.gdCCXData = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdCCXData", "I"); + GDeviceFc.gdCCXMask = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdCCXMask", "I"); + GDeviceFc.gdExt = (*env)->GetFieldID(env, GDeviceFc.clazz, "gdExt", "I"); + GDeviceFc.cached = 1; +} + +GDevice *getGDeviceFields(JNIEnv *env, jobject lpObject, GDevice *lpStruct) +{ + if (!GDeviceFc.cached) cacheGDeviceFids(env, lpObject); + lpStruct->gdRefNum = (*env)->GetShortField(env, lpObject, GDeviceFc.gdRefNum); + lpStruct->gdID = (*env)->GetShortField(env, lpObject, GDeviceFc.gdID); + lpStruct->gdType = (*env)->GetShortField(env, lpObject, GDeviceFc.gdType); + lpStruct->gdITable = (ITabHandle)(*env)->GetIntField(env, lpObject, GDeviceFc.gdITable); + lpStruct->gdResPref = (*env)->GetShortField(env, lpObject, GDeviceFc.gdResPref); + lpStruct->gdSearchProc = (SProcHndl)(*env)->GetIntField(env, lpObject, GDeviceFc.gdSearchProc); + lpStruct->gdCompProc = (CProcHndl)(*env)->GetIntField(env, lpObject, GDeviceFc.gdCompProc); + lpStruct->gdFlags = (*env)->GetShortField(env, lpObject, GDeviceFc.gdFlags); + lpStruct->gdPMap = (PixMapHandle)(*env)->GetIntField(env, lpObject, GDeviceFc.gdPMap); + lpStruct->gdRefCon = (*env)->GetIntField(env, lpObject, GDeviceFc.gdRefCon); + lpStruct->gdNextGD = (GDHandle)(*env)->GetIntField(env, lpObject, GDeviceFc.gdNextGD); + lpStruct->gdRect.left = (*env)->GetShortField(env, lpObject, GDeviceFc.left); + lpStruct->gdRect.top = (*env)->GetShortField(env, lpObject, GDeviceFc.top); + lpStruct->gdRect.right = (*env)->GetShortField(env, lpObject, GDeviceFc.right); + lpStruct->gdRect.bottom = (*env)->GetShortField(env, lpObject, GDeviceFc.bottom); + lpStruct->gdMode = (*env)->GetIntField(env, lpObject, GDeviceFc.gdMode); + lpStruct->gdCCBytes = (*env)->GetShortField(env, lpObject, GDeviceFc.gdCCBytes); + lpStruct->gdCCDepth = (*env)->GetShortField(env, lpObject, GDeviceFc.gdCCDepth); + lpStruct->gdCCXData = (Handle)(*env)->GetIntField(env, lpObject, GDeviceFc.gdCCXData); + lpStruct->gdCCXMask = (Handle)(*env)->GetIntField(env, lpObject, GDeviceFc.gdCCXMask); + lpStruct->gdExt = (Handle)(*env)->GetIntField(env, lpObject, GDeviceFc.gdExt); + return lpStruct; +} + +void setGDeviceFields(JNIEnv *env, jobject lpObject, GDevice *lpStruct) +{ + if (!GDeviceFc.cached) cacheGDeviceFids(env, lpObject); + (*env)->SetShortField(env, lpObject, GDeviceFc.gdRefNum, (jshort)lpStruct->gdRefNum); + (*env)->SetShortField(env, lpObject, GDeviceFc.gdID, (jshort)lpStruct->gdID); + (*env)->SetShortField(env, lpObject, GDeviceFc.gdType, (jshort)lpStruct->gdType); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdITable, (jint)lpStruct->gdITable); + (*env)->SetShortField(env, lpObject, GDeviceFc.gdResPref, (jshort)lpStruct->gdResPref); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdSearchProc, (jint)lpStruct->gdSearchProc); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdCompProc, (jint)lpStruct->gdCompProc); + (*env)->SetShortField(env, lpObject, GDeviceFc.gdFlags, (jshort)lpStruct->gdFlags); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdPMap, (jint)lpStruct->gdPMap); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdRefCon, (jint)lpStruct->gdRefCon); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdNextGD, (jint)lpStruct->gdNextGD); + (*env)->SetShortField(env, lpObject, GDeviceFc.left, (jshort)lpStruct->gdRect.left); + (*env)->SetShortField(env, lpObject, GDeviceFc.top, (jshort)lpStruct->gdRect.top); + (*env)->SetShortField(env, lpObject, GDeviceFc.right, (jshort)lpStruct->gdRect.right); + (*env)->SetShortField(env, lpObject, GDeviceFc.bottom, (jshort)lpStruct->gdRect.bottom); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdMode, (jint)lpStruct->gdMode); + (*env)->SetShortField(env, lpObject, GDeviceFc.gdCCBytes, (jshort)lpStruct->gdCCBytes); + (*env)->SetShortField(env, lpObject, GDeviceFc.gdCCDepth, (jshort)lpStruct->gdCCDepth); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdCCXData, (jint)lpStruct->gdCCXData); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdCCXMask, (jint)lpStruct->gdCCXMask); + (*env)->SetIntField(env, lpObject, GDeviceFc.gdExt, (jint)lpStruct->gdExt); +} +#endif /* NO_GDevice */ + +#ifndef NO_HICommand +typedef struct HICommand_FID_CACHE { + int cached; + jclass clazz; + jfieldID attributes, commandID, menu_menuRef, menu_menuItemIndex; +} HICommand_FID_CACHE; + +HICommand_FID_CACHE HICommandFc; + +void cacheHICommandFids(JNIEnv *env, jobject lpObject) +{ + if (HICommandFc.cached) return; + HICommandFc.clazz = (*env)->GetObjectClass(env, lpObject); + HICommandFc.attributes = (*env)->GetFieldID(env, HICommandFc.clazz, "attributes", "I"); + HICommandFc.commandID = (*env)->GetFieldID(env, HICommandFc.clazz, "commandID", "I"); + HICommandFc.menu_menuRef = (*env)->GetFieldID(env, HICommandFc.clazz, "menu_menuRef", "I"); + HICommandFc.menu_menuItemIndex = (*env)->GetFieldID(env, HICommandFc.clazz, "menu_menuItemIndex", "S"); + HICommandFc.cached = 1; +} + +HICommand *getHICommandFields(JNIEnv *env, jobject lpObject, HICommand *lpStruct) +{ + if (!HICommandFc.cached) cacheHICommandFids(env, lpObject); + lpStruct->attributes = (*env)->GetIntField(env, lpObject, HICommandFc.attributes); + lpStruct->commandID = (*env)->GetIntField(env, lpObject, HICommandFc.commandID); + lpStruct->menu.menuRef = (MenuRef)(*env)->GetIntField(env, lpObject, HICommandFc.menu_menuRef); + lpStruct->menu.menuItemIndex = (MenuItemIndex)(*env)->GetShortField(env, lpObject, HICommandFc.menu_menuItemIndex); + return lpStruct; +} + +void setHICommandFields(JNIEnv *env, jobject lpObject, HICommand *lpStruct) +{ + if (!HICommandFc.cached) cacheHICommandFids(env, lpObject); + (*env)->SetIntField(env, lpObject, HICommandFc.attributes, (jint)lpStruct->attributes); + (*env)->SetIntField(env, lpObject, HICommandFc.commandID, (jint)lpStruct->commandID); + (*env)->SetIntField(env, lpObject, HICommandFc.menu_menuRef, (jint)lpStruct->menu.menuRef); + (*env)->SetShortField(env, lpObject, HICommandFc.menu_menuItemIndex, (jshort)lpStruct->menu.menuItemIndex); +} +#endif /* NO_HICommand */ + +#ifndef NO_HMHelpContentRec +typedef struct HMHelpContentRec_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, absHotRect_top, absHotRect_left, absHotRect_bottom, absHotRect_right, tagSide, content0_contentType, content0_tagCFString, content1_contentType, content1_tagCFString; +} HMHelpContentRec_FID_CACHE; + +HMHelpContentRec_FID_CACHE HMHelpContentRecFc; + +void cacheHMHelpContentRecFids(JNIEnv *env, jobject lpObject) +{ + if (HMHelpContentRecFc.cached) return; + HMHelpContentRecFc.clazz = (*env)->GetObjectClass(env, lpObject); + HMHelpContentRecFc.version = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "version", "I"); + HMHelpContentRecFc.absHotRect_top = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "absHotRect_top", "S"); + HMHelpContentRecFc.absHotRect_left = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "absHotRect_left", "S"); + HMHelpContentRecFc.absHotRect_bottom = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "absHotRect_bottom", "S"); + HMHelpContentRecFc.absHotRect_right = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "absHotRect_right", "S"); + HMHelpContentRecFc.tagSide = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "tagSide", "S"); + HMHelpContentRecFc.content0_contentType = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "content0_contentType", "I"); + HMHelpContentRecFc.content0_tagCFString = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "content0_tagCFString", "I"); + HMHelpContentRecFc.content1_contentType = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "content1_contentType", "I"); + HMHelpContentRecFc.content1_tagCFString = (*env)->GetFieldID(env, HMHelpContentRecFc.clazz, "content1_tagCFString", "I"); + HMHelpContentRecFc.cached = 1; +} + +HMHelpContentRec *getHMHelpContentRecFields(JNIEnv *env, jobject lpObject, HMHelpContentRec *lpStruct) +{ + if (!HMHelpContentRecFc.cached) cacheHMHelpContentRecFids(env, lpObject); + lpStruct->version = (*env)->GetIntField(env, lpObject, HMHelpContentRecFc.version); + lpStruct->absHotRect.top = (*env)->GetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_top); + lpStruct->absHotRect.left = (*env)->GetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_left); + lpStruct->absHotRect.bottom = (*env)->GetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_bottom); + lpStruct->absHotRect.right = (*env)->GetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_right); + lpStruct->tagSide = (*env)->GetShortField(env, lpObject, HMHelpContentRecFc.tagSide); + lpStruct->content[0].contentType = (*env)->GetIntField(env, lpObject, HMHelpContentRecFc.content0_contentType); + lpStruct->content[0].u.tagCFString = (CFStringRef)(*env)->GetIntField(env, lpObject, HMHelpContentRecFc.content0_tagCFString); + lpStruct->content[1].contentType = (*env)->GetIntField(env, lpObject, HMHelpContentRecFc.content1_contentType); + lpStruct->content[1].u.tagCFString = (CFStringRef)(*env)->GetIntField(env, lpObject, HMHelpContentRecFc.content1_tagCFString); + return lpStruct; +} + +void setHMHelpContentRecFields(JNIEnv *env, jobject lpObject, HMHelpContentRec *lpStruct) +{ + if (!HMHelpContentRecFc.cached) cacheHMHelpContentRecFids(env, lpObject); + (*env)->SetIntField(env, lpObject, HMHelpContentRecFc.version, (jint)lpStruct->version); + (*env)->SetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_top, (jshort)lpStruct->absHotRect.top); + (*env)->SetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_left, (jshort)lpStruct->absHotRect.left); + (*env)->SetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_bottom, (jshort)lpStruct->absHotRect.bottom); + (*env)->SetShortField(env, lpObject, HMHelpContentRecFc.absHotRect_right, (jshort)lpStruct->absHotRect.right); + (*env)->SetShortField(env, lpObject, HMHelpContentRecFc.tagSide, (jshort)lpStruct->tagSide); + (*env)->SetIntField(env, lpObject, HMHelpContentRecFc.content0_contentType, (jint)lpStruct->content[0].contentType); + (*env)->SetIntField(env, lpObject, HMHelpContentRecFc.content0_tagCFString, (jint)lpStruct->content[0].u.tagCFString); + (*env)->SetIntField(env, lpObject, HMHelpContentRecFc.content1_contentType, (jint)lpStruct->content[1].contentType); + (*env)->SetIntField(env, lpObject, HMHelpContentRecFc.content1_tagCFString, (jint)lpStruct->content[1].u.tagCFString); +} +#endif /* NO_HMHelpContentRec */ + +#ifndef NO_MenuTrackingData +typedef struct MenuTrackingData_FID_CACHE { + int cached; + jclass clazz; + jfieldID menu, itemSelected, itemUnderMouse, top, left, bottom, right, virtualMenuTop, virtualMenuBottom; +} MenuTrackingData_FID_CACHE; + +MenuTrackingData_FID_CACHE MenuTrackingDataFc; + +void cacheMenuTrackingDataFids(JNIEnv *env, jobject lpObject) +{ + if (MenuTrackingDataFc.cached) return; + MenuTrackingDataFc.clazz = (*env)->GetObjectClass(env, lpObject); + MenuTrackingDataFc.menu = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "menu", "I"); + MenuTrackingDataFc.itemSelected = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "itemSelected", "S"); + MenuTrackingDataFc.itemUnderMouse = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "itemUnderMouse", "S"); + MenuTrackingDataFc.top = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "top", "S"); + MenuTrackingDataFc.left = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "left", "S"); + MenuTrackingDataFc.bottom = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "bottom", "S"); + MenuTrackingDataFc.right = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "right", "S"); + MenuTrackingDataFc.virtualMenuTop = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "virtualMenuTop", "I"); + MenuTrackingDataFc.virtualMenuBottom = (*env)->GetFieldID(env, MenuTrackingDataFc.clazz, "virtualMenuBottom", "I"); + MenuTrackingDataFc.cached = 1; +} + +MenuTrackingData *getMenuTrackingDataFields(JNIEnv *env, jobject lpObject, MenuTrackingData *lpStruct) +{ + if (!MenuTrackingDataFc.cached) cacheMenuTrackingDataFids(env, lpObject); + lpStruct->menu = (MenuRef)(*env)->GetIntField(env, lpObject, MenuTrackingDataFc.menu); + lpStruct->itemSelected = (*env)->GetShortField(env, lpObject, MenuTrackingDataFc.itemSelected); + lpStruct->itemUnderMouse = (*env)->GetShortField(env, lpObject, MenuTrackingDataFc.itemUnderMouse); + lpStruct->itemRect.top = (*env)->GetShortField(env, lpObject, MenuTrackingDataFc.top); + lpStruct->itemRect.left = (*env)->GetShortField(env, lpObject, MenuTrackingDataFc.left); + lpStruct->itemRect.bottom = (*env)->GetShortField(env, lpObject, MenuTrackingDataFc.bottom); + lpStruct->itemRect.right = (*env)->GetShortField(env, lpObject, MenuTrackingDataFc.right); + lpStruct->virtualMenuTop = (*env)->GetIntField(env, lpObject, MenuTrackingDataFc.virtualMenuTop); + lpStruct->virtualMenuBottom = (*env)->GetIntField(env, lpObject, MenuTrackingDataFc.virtualMenuBottom); + return lpStruct; +} + +void setMenuTrackingDataFields(JNIEnv *env, jobject lpObject, MenuTrackingData *lpStruct) +{ + if (!MenuTrackingDataFc.cached) cacheMenuTrackingDataFids(env, lpObject); + (*env)->SetIntField(env, lpObject, MenuTrackingDataFc.menu, (jint)lpStruct->menu); + (*env)->SetShortField(env, lpObject, MenuTrackingDataFc.itemSelected, (jshort)lpStruct->itemSelected); + (*env)->SetShortField(env, lpObject, MenuTrackingDataFc.itemUnderMouse, (jshort)lpStruct->itemUnderMouse); + (*env)->SetShortField(env, lpObject, MenuTrackingDataFc.top, (jshort)lpStruct->itemRect.top); + (*env)->SetShortField(env, lpObject, MenuTrackingDataFc.left, (jshort)lpStruct->itemRect.left); + (*env)->SetShortField(env, lpObject, MenuTrackingDataFc.bottom, (jshort)lpStruct->itemRect.bottom); + (*env)->SetShortField(env, lpObject, MenuTrackingDataFc.right, (jshort)lpStruct->itemRect.right); + (*env)->SetIntField(env, lpObject, MenuTrackingDataFc.virtualMenuTop, (jint)lpStruct->virtualMenuTop); + (*env)->SetIntField(env, lpObject, MenuTrackingDataFc.virtualMenuBottom, (jint)lpStruct->virtualMenuBottom); +} +#endif /* NO_MenuTrackingData */ + +#ifndef NO_NavDialogCreationOptions +typedef struct NavDialogCreationOptions_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, optionFlags, location_h, location_v, clientName, windowTitle, actionButtonLabel, cancelButtonLabel, saveFileName, message, preferenceKey, popupExtension, modality, parentWindow; +} NavDialogCreationOptions_FID_CACHE; + +NavDialogCreationOptions_FID_CACHE NavDialogCreationOptionsFc; + +void cacheNavDialogCreationOptionsFids(JNIEnv *env, jobject lpObject) +{ + if (NavDialogCreationOptionsFc.cached) return; + NavDialogCreationOptionsFc.clazz = (*env)->GetObjectClass(env, lpObject); + NavDialogCreationOptionsFc.version = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "version", "S"); + NavDialogCreationOptionsFc.optionFlags = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "optionFlags", "I"); + NavDialogCreationOptionsFc.location_h = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "location_h", "S"); + NavDialogCreationOptionsFc.location_v = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "location_v", "S"); + NavDialogCreationOptionsFc.clientName = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "clientName", "I"); + NavDialogCreationOptionsFc.windowTitle = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "windowTitle", "I"); + NavDialogCreationOptionsFc.actionButtonLabel = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "actionButtonLabel", "I"); + NavDialogCreationOptionsFc.cancelButtonLabel = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "cancelButtonLabel", "I"); + NavDialogCreationOptionsFc.saveFileName = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "saveFileName", "I"); + NavDialogCreationOptionsFc.message = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "message", "I"); + NavDialogCreationOptionsFc.preferenceKey = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "preferenceKey", "I"); + NavDialogCreationOptionsFc.popupExtension = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "popupExtension", "I"); + NavDialogCreationOptionsFc.modality = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "modality", "I"); + NavDialogCreationOptionsFc.parentWindow = (*env)->GetFieldID(env, NavDialogCreationOptionsFc.clazz, "parentWindow", "I"); + NavDialogCreationOptionsFc.cached = 1; +} + +NavDialogCreationOptions *getNavDialogCreationOptionsFields(JNIEnv *env, jobject lpObject, NavDialogCreationOptions *lpStruct) +{ + if (!NavDialogCreationOptionsFc.cached) cacheNavDialogCreationOptionsFids(env, lpObject); + lpStruct->version = (*env)->GetShortField(env, lpObject, NavDialogCreationOptionsFc.version); + lpStruct->optionFlags = (NavDialogOptionFlags)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.optionFlags); + lpStruct->location.h = (*env)->GetShortField(env, lpObject, NavDialogCreationOptionsFc.location_h); + lpStruct->location.v = (*env)->GetShortField(env, lpObject, NavDialogCreationOptionsFc.location_v); + lpStruct->clientName = (CFStringRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.clientName); + lpStruct->windowTitle = (CFStringRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.windowTitle); + lpStruct->actionButtonLabel = (CFStringRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.actionButtonLabel); + lpStruct->cancelButtonLabel = (CFStringRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.cancelButtonLabel); + lpStruct->saveFileName = (CFStringRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.saveFileName); + lpStruct->message = (CFStringRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.message); + lpStruct->preferenceKey = (*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.preferenceKey); + lpStruct->popupExtension = (CFArrayRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.popupExtension); + lpStruct->modality = (WindowModality)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.modality); + lpStruct->parentWindow = (WindowRef)(*env)->GetIntField(env, lpObject, NavDialogCreationOptionsFc.parentWindow); + return lpStruct; +} + +void setNavDialogCreationOptionsFields(JNIEnv *env, jobject lpObject, NavDialogCreationOptions *lpStruct) +{ + if (!NavDialogCreationOptionsFc.cached) cacheNavDialogCreationOptionsFids(env, lpObject); + (*env)->SetShortField(env, lpObject, NavDialogCreationOptionsFc.version, (jshort)lpStruct->version); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.optionFlags, (jint)lpStruct->optionFlags); + (*env)->SetShortField(env, lpObject, NavDialogCreationOptionsFc.location_h, (jshort)lpStruct->location.h); + (*env)->SetShortField(env, lpObject, NavDialogCreationOptionsFc.location_v, (jshort)lpStruct->location.v); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.clientName, (jint)lpStruct->clientName); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.windowTitle, (jint)lpStruct->windowTitle); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.actionButtonLabel, (jint)lpStruct->actionButtonLabel); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.cancelButtonLabel, (jint)lpStruct->cancelButtonLabel); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.saveFileName, (jint)lpStruct->saveFileName); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.message, (jint)lpStruct->message); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.preferenceKey, (jint)lpStruct->preferenceKey); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.popupExtension, (jint)lpStruct->popupExtension); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.modality, (jint)lpStruct->modality); + (*env)->SetIntField(env, lpObject, NavDialogCreationOptionsFc.parentWindow, (jint)lpStruct->parentWindow); +} +#endif /* NO_NavDialogCreationOptions */ + +#ifndef NO_NavReplyRecord +typedef struct NavReplyRecord_FID_CACHE { + int cached; + jclass clazz; + jfieldID version, validRecord, replacing, isStationery, translationNeeded, selection_descriptorType, selection_dataHandle, keyScript, fileTranslation, reserved1, saveFileName, saveFileExtensionHidden, reserved2, reserved; +} NavReplyRecord_FID_CACHE; + +NavReplyRecord_FID_CACHE NavReplyRecordFc; + +void cacheNavReplyRecordFids(JNIEnv *env, jobject lpObject) +{ + if (NavReplyRecordFc.cached) return; + NavReplyRecordFc.clazz = (*env)->GetObjectClass(env, lpObject); + NavReplyRecordFc.version = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "version", "S"); + NavReplyRecordFc.validRecord = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "validRecord", "Z"); + NavReplyRecordFc.replacing = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "replacing", "Z"); + NavReplyRecordFc.isStationery = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "isStationery", "Z"); + NavReplyRecordFc.translationNeeded = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "translationNeeded", "Z"); + NavReplyRecordFc.selection_descriptorType = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "selection_descriptorType", "I"); + NavReplyRecordFc.selection_dataHandle = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "selection_dataHandle", "I"); + NavReplyRecordFc.keyScript = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "keyScript", "S"); + NavReplyRecordFc.fileTranslation = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "fileTranslation", "I"); + NavReplyRecordFc.reserved1 = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "reserved1", "I"); + NavReplyRecordFc.saveFileName = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "saveFileName", "I"); + NavReplyRecordFc.saveFileExtensionHidden = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "saveFileExtensionHidden", "Z"); + NavReplyRecordFc.reserved2 = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "reserved2", "B"); + NavReplyRecordFc.reserved = (*env)->GetFieldID(env, NavReplyRecordFc.clazz, "reserved", "[B"); + NavReplyRecordFc.cached = 1; +} + +NavReplyRecord *getNavReplyRecordFields(JNIEnv *env, jobject lpObject, NavReplyRecord *lpStruct) +{ + if (!NavReplyRecordFc.cached) cacheNavReplyRecordFids(env, lpObject); + lpStruct->version = (UInt16)(*env)->GetShortField(env, lpObject, NavReplyRecordFc.version); + lpStruct->validRecord = (Boolean)(*env)->GetBooleanField(env, lpObject, NavReplyRecordFc.validRecord); + lpStruct->replacing = (Boolean)(*env)->GetBooleanField(env, lpObject, NavReplyRecordFc.replacing); + lpStruct->isStationery = (Boolean)(*env)->GetBooleanField(env, lpObject, NavReplyRecordFc.isStationery); + lpStruct->translationNeeded = (Boolean)(*env)->GetBooleanField(env, lpObject, NavReplyRecordFc.translationNeeded); + lpStruct->selection.descriptorType = (DescType)(*env)->GetIntField(env, lpObject, NavReplyRecordFc.selection_descriptorType); + lpStruct->selection.dataHandle = (AEDataStorage)(*env)->GetIntField(env, lpObject, NavReplyRecordFc.selection_dataHandle); + lpStruct->keyScript = (ScriptCode)(*env)->GetShortField(env, lpObject, NavReplyRecordFc.keyScript); + lpStruct->fileTranslation = (FileTranslationSpecArrayHandle)(*env)->GetIntField(env, lpObject, NavReplyRecordFc.fileTranslation); + lpStruct->reserved1 = (UInt32)(*env)->GetIntField(env, lpObject, NavReplyRecordFc.reserved1); + lpStruct->saveFileName = (CFStringRef)(*env)->GetIntField(env, lpObject, NavReplyRecordFc.saveFileName); + lpStruct->saveFileExtensionHidden = (Boolean)(*env)->GetBooleanField(env, lpObject, NavReplyRecordFc.saveFileExtensionHidden); + lpStruct->reserved2 = (UInt8)(*env)->GetByteField(env, lpObject, NavReplyRecordFc.reserved2); + { + jbyteArray lpObject1 = (*env)->GetObjectField(env, lpObject, NavReplyRecordFc.reserved); + (*env)->GetByteArrayRegion(env, lpObject1, 0, sizeof(lpStruct->reserved), lpStruct->reserved); + } + return lpStruct; +} + +void setNavReplyRecordFields(JNIEnv *env, jobject lpObject, NavReplyRecord *lpStruct) +{ + if (!NavReplyRecordFc.cached) cacheNavReplyRecordFids(env, lpObject); + (*env)->SetShortField(env, lpObject, NavReplyRecordFc.version, (jshort)lpStruct->version); + (*env)->SetBooleanField(env, lpObject, NavReplyRecordFc.validRecord, (jboolean)lpStruct->validRecord); + (*env)->SetBooleanField(env, lpObject, NavReplyRecordFc.replacing, (jboolean)lpStruct->replacing); + (*env)->SetBooleanField(env, lpObject, NavReplyRecordFc.isStationery, (jboolean)lpStruct->isStationery); + (*env)->SetBooleanField(env, lpObject, NavReplyRecordFc.translationNeeded, (jboolean)lpStruct->translationNeeded); + (*env)->SetIntField(env, lpObject, NavReplyRecordFc.selection_descriptorType, (jint)lpStruct->selection.descriptorType); + (*env)->SetIntField(env, lpObject, NavReplyRecordFc.selection_dataHandle, (jint)lpStruct->selection.dataHandle); + (*env)->SetShortField(env, lpObject, NavReplyRecordFc.keyScript, (jshort)lpStruct->keyScript); + (*env)->SetIntField(env, lpObject, NavReplyRecordFc.fileTranslation, (jint)lpStruct->fileTranslation); + (*env)->SetIntField(env, lpObject, NavReplyRecordFc.reserved1, (jint)lpStruct->reserved1); + (*env)->SetIntField(env, lpObject, NavReplyRecordFc.saveFileName, (jint)lpStruct->saveFileName); + (*env)->SetBooleanField(env, lpObject, NavReplyRecordFc.saveFileExtensionHidden, (jboolean)lpStruct->saveFileExtensionHidden); + (*env)->SetByteField(env, lpObject, NavReplyRecordFc.reserved2, (jbyte)lpStruct->reserved2); + { + jbyteArray lpObject1 = (*env)->GetObjectField(env, lpObject, NavReplyRecordFc.reserved); + (*env)->SetByteArrayRegion(env, lpObject1, 0, sizeof(lpStruct->reserved), lpStruct->reserved); + } +} +#endif /* NO_NavReplyRecord */ + +#ifndef NO_PixMap +typedef struct PixMap_FID_CACHE { + int cached; + jclass clazz; + jfieldID pmVersion, packType, packSize, hRes, vRes, pixelType, pixelSize, cmpCount, cmpSize, pixelFormat, pmTable, pmExt; +} PixMap_FID_CACHE; + +PixMap_FID_CACHE PixMapFc; + +void cachePixMapFids(JNIEnv *env, jobject lpObject) +{ + if (PixMapFc.cached) return; + cacheBitMapFids(env, lpObject); + PixMapFc.clazz = (*env)->GetObjectClass(env, lpObject); + PixMapFc.pmVersion = (*env)->GetFieldID(env, PixMapFc.clazz, "pmVersion", "S"); + PixMapFc.packType = (*env)->GetFieldID(env, PixMapFc.clazz, "packType", "S"); + PixMapFc.packSize = (*env)->GetFieldID(env, PixMapFc.clazz, "packSize", "I"); + PixMapFc.hRes = (*env)->GetFieldID(env, PixMapFc.clazz, "hRes", "I"); + PixMapFc.vRes = (*env)->GetFieldID(env, PixMapFc.clazz, "vRes", "I"); + PixMapFc.pixelType = (*env)->GetFieldID(env, PixMapFc.clazz, "pixelType", "S"); + PixMapFc.pixelSize = (*env)->GetFieldID(env, PixMapFc.clazz, "pixelSize", "S"); + PixMapFc.cmpCount = (*env)->GetFieldID(env, PixMapFc.clazz, "cmpCount", "S"); + PixMapFc.cmpSize = (*env)->GetFieldID(env, PixMapFc.clazz, "cmpSize", "S"); + PixMapFc.pixelFormat = (*env)->GetFieldID(env, PixMapFc.clazz, "pixelFormat", "I"); + PixMapFc.pmTable = (*env)->GetFieldID(env, PixMapFc.clazz, "pmTable", "I"); + PixMapFc.pmExt = (*env)->GetFieldID(env, PixMapFc.clazz, "pmExt", "I"); + PixMapFc.cached = 1; +} + +PixMap *getPixMapFields(JNIEnv *env, jobject lpObject, PixMap *lpStruct) +{ + if (!PixMapFc.cached) cachePixMapFids(env, lpObject); + getBitMapFields(env, lpObject, (BitMap *)lpStruct); + lpStruct->pmVersion = (*env)->GetShortField(env, lpObject, PixMapFc.pmVersion); + lpStruct->packType = (*env)->GetShortField(env, lpObject, PixMapFc.packType); + lpStruct->packSize = (*env)->GetIntField(env, lpObject, PixMapFc.packSize); + lpStruct->hRes = (*env)->GetIntField(env, lpObject, PixMapFc.hRes); + lpStruct->vRes = (*env)->GetIntField(env, lpObject, PixMapFc.vRes); + lpStruct->pixelType = (*env)->GetShortField(env, lpObject, PixMapFc.pixelType); + lpStruct->pixelSize = (*env)->GetShortField(env, lpObject, PixMapFc.pixelSize); + lpStruct->cmpCount = (*env)->GetShortField(env, lpObject, PixMapFc.cmpCount); + lpStruct->cmpSize = (*env)->GetShortField(env, lpObject, PixMapFc.cmpSize); + lpStruct->pixelFormat = (*env)->GetIntField(env, lpObject, PixMapFc.pixelFormat); + lpStruct->pmTable = (CTabHandle)(*env)->GetIntField(env, lpObject, PixMapFc.pmTable); + lpStruct->pmExt = (void *)(*env)->GetIntField(env, lpObject, PixMapFc.pmExt); + return lpStruct; +} + +void setPixMapFields(JNIEnv *env, jobject lpObject, PixMap *lpStruct) +{ + if (!PixMapFc.cached) cachePixMapFids(env, lpObject); + setBitMapFields(env, lpObject, (BitMap *)lpStruct); + (*env)->SetShortField(env, lpObject, PixMapFc.pmVersion, (jshort)lpStruct->pmVersion); + (*env)->SetShortField(env, lpObject, PixMapFc.packType, (jshort)lpStruct->packType); + (*env)->SetIntField(env, lpObject, PixMapFc.packSize, (jint)lpStruct->packSize); + (*env)->SetIntField(env, lpObject, PixMapFc.hRes, (jint)lpStruct->hRes); + (*env)->SetIntField(env, lpObject, PixMapFc.vRes, (jint)lpStruct->vRes); + (*env)->SetShortField(env, lpObject, PixMapFc.pixelType, (jshort)lpStruct->pixelType); + (*env)->SetShortField(env, lpObject, PixMapFc.pixelSize, (jshort)lpStruct->pixelSize); + (*env)->SetShortField(env, lpObject, PixMapFc.cmpCount, (jshort)lpStruct->cmpCount); + (*env)->SetShortField(env, lpObject, PixMapFc.cmpSize, (jshort)lpStruct->cmpSize); + (*env)->SetIntField(env, lpObject, PixMapFc.pixelFormat, (jint)lpStruct->pixelFormat); + (*env)->SetIntField(env, lpObject, PixMapFc.pmTable, (jint)lpStruct->pmTable); + (*env)->SetIntField(env, lpObject, PixMapFc.pmExt, (jint)lpStruct->pmExt); +} +#endif /* NO_PixMap */ + +#ifndef NO_Point +typedef struct Point_FID_CACHE { + int cached; + jclass clazz; + jfieldID v, h; +} Point_FID_CACHE; + +Point_FID_CACHE PointFc; + +void cachePointFids(JNIEnv *env, jobject lpObject) +{ + if (PointFc.cached) return; + PointFc.clazz = (*env)->GetObjectClass(env, lpObject); + PointFc.v = (*env)->GetFieldID(env, PointFc.clazz, "v", "S"); + PointFc.h = (*env)->GetFieldID(env, PointFc.clazz, "h", "S"); + PointFc.cached = 1; +} + +Point *getPointFields(JNIEnv *env, jobject lpObject, Point *lpStruct) +{ + if (!PointFc.cached) cachePointFids(env, lpObject); + lpStruct->v = (*env)->GetShortField(env, lpObject, PointFc.v); + lpStruct->h = (*env)->GetShortField(env, lpObject, PointFc.h); + return lpStruct; +} + +void setPointFields(JNIEnv *env, jobject lpObject, Point *lpStruct) +{ + if (!PointFc.cached) cachePointFids(env, lpObject); + (*env)->SetShortField(env, lpObject, PointFc.v, (jshort)lpStruct->v); + (*env)->SetShortField(env, lpObject, PointFc.h, (jshort)lpStruct->h); +} +#endif /* NO_Point */ + +#ifndef NO_RGBColor +typedef struct RGBColor_FID_CACHE { + int cached; + jclass clazz; + jfieldID red, green, blue; +} RGBColor_FID_CACHE; + +RGBColor_FID_CACHE RGBColorFc; + +void cacheRGBColorFids(JNIEnv *env, jobject lpObject) +{ + if (RGBColorFc.cached) return; + RGBColorFc.clazz = (*env)->GetObjectClass(env, lpObject); + RGBColorFc.red = (*env)->GetFieldID(env, RGBColorFc.clazz, "red", "S"); + RGBColorFc.green = (*env)->GetFieldID(env, RGBColorFc.clazz, "green", "S"); + RGBColorFc.blue = (*env)->GetFieldID(env, RGBColorFc.clazz, "blue", "S"); + RGBColorFc.cached = 1; +} + +RGBColor *getRGBColorFields(JNIEnv *env, jobject lpObject, RGBColor *lpStruct) +{ + if (!RGBColorFc.cached) cacheRGBColorFids(env, lpObject); + lpStruct->red = (*env)->GetShortField(env, lpObject, RGBColorFc.red); + lpStruct->green = (*env)->GetShortField(env, lpObject, RGBColorFc.green); + lpStruct->blue = (*env)->GetShortField(env, lpObject, RGBColorFc.blue); + return lpStruct; +} + +void setRGBColorFields(JNIEnv *env, jobject lpObject, RGBColor *lpStruct) +{ + if (!RGBColorFc.cached) cacheRGBColorFids(env, lpObject); + (*env)->SetShortField(env, lpObject, RGBColorFc.red, (jshort)lpStruct->red); + (*env)->SetShortField(env, lpObject, RGBColorFc.green, (jshort)lpStruct->green); + (*env)->SetShortField(env, lpObject, RGBColorFc.blue, (jshort)lpStruct->blue); +} +#endif /* NO_RGBColor */ + +#ifndef NO_Rect +typedef struct Rect_FID_CACHE { + int cached; + jclass clazz; + jfieldID top, left, bottom, right; +} Rect_FID_CACHE; + +Rect_FID_CACHE RectFc; + +void cacheRectFids(JNIEnv *env, jobject lpObject) +{ + if (RectFc.cached) return; + RectFc.clazz = (*env)->GetObjectClass(env, lpObject); + RectFc.top = (*env)->GetFieldID(env, RectFc.clazz, "top", "S"); + RectFc.left = (*env)->GetFieldID(env, RectFc.clazz, "left", "S"); + RectFc.bottom = (*env)->GetFieldID(env, RectFc.clazz, "bottom", "S"); + RectFc.right = (*env)->GetFieldID(env, RectFc.clazz, "right", "S"); + RectFc.cached = 1; +} + +Rect *getRectFields(JNIEnv *env, jobject lpObject, Rect *lpStruct) +{ + if (!RectFc.cached) cacheRectFids(env, lpObject); + lpStruct->top = (*env)->GetShortField(env, lpObject, RectFc.top); + lpStruct->left = (*env)->GetShortField(env, lpObject, RectFc.left); + lpStruct->bottom = (*env)->GetShortField(env, lpObject, RectFc.bottom); + lpStruct->right = (*env)->GetShortField(env, lpObject, RectFc.right); + return lpStruct; +} + +void setRectFields(JNIEnv *env, jobject lpObject, Rect *lpStruct) +{ + if (!RectFc.cached) cacheRectFids(env, lpObject); + (*env)->SetShortField(env, lpObject, RectFc.top, (jshort)lpStruct->top); + (*env)->SetShortField(env, lpObject, RectFc.left, (jshort)lpStruct->left); + (*env)->SetShortField(env, lpObject, RectFc.bottom, (jshort)lpStruct->bottom); + (*env)->SetShortField(env, lpObject, RectFc.right, (jshort)lpStruct->right); +} +#endif /* NO_Rect */ + +#ifndef NO_ThemeButtonDrawInfo +typedef struct ThemeButtonDrawInfo_FID_CACHE { + int cached; + jclass clazz; + jfieldID state, value, adornment; +} ThemeButtonDrawInfo_FID_CACHE; + +ThemeButtonDrawInfo_FID_CACHE ThemeButtonDrawInfoFc; + +void cacheThemeButtonDrawInfoFids(JNIEnv *env, jobject lpObject) +{ + if (ThemeButtonDrawInfoFc.cached) return; + ThemeButtonDrawInfoFc.clazz = (*env)->GetObjectClass(env, lpObject); + ThemeButtonDrawInfoFc.state = (*env)->GetFieldID(env, ThemeButtonDrawInfoFc.clazz, "state", "I"); + ThemeButtonDrawInfoFc.value = (*env)->GetFieldID(env, ThemeButtonDrawInfoFc.clazz, "value", "S"); + ThemeButtonDrawInfoFc.adornment = (*env)->GetFieldID(env, ThemeButtonDrawInfoFc.clazz, "adornment", "S"); + ThemeButtonDrawInfoFc.cached = 1; +} + +ThemeButtonDrawInfo *getThemeButtonDrawInfoFields(JNIEnv *env, jobject lpObject, ThemeButtonDrawInfo *lpStruct) +{ + if (!ThemeButtonDrawInfoFc.cached) cacheThemeButtonDrawInfoFids(env, lpObject); + lpStruct->state = (ThemeDrawState)(*env)->GetIntField(env, lpObject, ThemeButtonDrawInfoFc.state); + lpStruct->value = (ThemeButtonValue)(*env)->GetShortField(env, lpObject, ThemeButtonDrawInfoFc.value); + lpStruct->adornment = (ThemeButtonAdornment)(*env)->GetShortField(env, lpObject, ThemeButtonDrawInfoFc.adornment); + return lpStruct; +} + +void setThemeButtonDrawInfoFields(JNIEnv *env, jobject lpObject, ThemeButtonDrawInfo *lpStruct) +{ + if (!ThemeButtonDrawInfoFc.cached) cacheThemeButtonDrawInfoFids(env, lpObject); + (*env)->SetIntField(env, lpObject, ThemeButtonDrawInfoFc.state, (jint)lpStruct->state); + (*env)->SetShortField(env, lpObject, ThemeButtonDrawInfoFc.value, (jshort)lpStruct->value); + (*env)->SetShortField(env, lpObject, ThemeButtonDrawInfoFc.adornment, (jshort)lpStruct->adornment); +} +#endif /* NO_ThemeButtonDrawInfo */ + +#ifndef NO_TXNLongRect +typedef struct TXNLongRect_FID_CACHE { + int cached; + jclass clazz; + jfieldID top, left, bottom, right; +} TXNLongRect_FID_CACHE; + +TXNLongRect_FID_CACHE TXNLongRectFc; + +void cacheTXNLongRectFids(JNIEnv *env, jobject lpObject) +{ + if (TXNLongRectFc.cached) return; + TXNLongRectFc.clazz = (*env)->GetObjectClass(env, lpObject); + TXNLongRectFc.top = (*env)->GetFieldID(env, TXNLongRectFc.clazz, "top", "I"); + TXNLongRectFc.left = (*env)->GetFieldID(env, TXNLongRectFc.clazz, "left", "I"); + TXNLongRectFc.bottom = (*env)->GetFieldID(env, TXNLongRectFc.clazz, "bottom", "I"); + TXNLongRectFc.right = (*env)->GetFieldID(env, TXNLongRectFc.clazz, "right", "I"); + TXNLongRectFc.cached = 1; +} + +TXNLongRect *getTXNLongRectFields(JNIEnv *env, jobject lpObject, TXNLongRect *lpStruct) +{ + if (!TXNLongRectFc.cached) cacheTXNLongRectFids(env, lpObject); + lpStruct->top = (*env)->GetIntField(env, lpObject, TXNLongRectFc.top); + lpStruct->left = (*env)->GetIntField(env, lpObject, TXNLongRectFc.left); + lpStruct->bottom = (*env)->GetIntField(env, lpObject, TXNLongRectFc.bottom); + lpStruct->right = (*env)->GetIntField(env, lpObject, TXNLongRectFc.right); + return lpStruct; +} + +void setTXNLongRectFields(JNIEnv *env, jobject lpObject, TXNLongRect *lpStruct) +{ + if (!TXNLongRectFc.cached) cacheTXNLongRectFids(env, lpObject); + (*env)->SetIntField(env, lpObject, TXNLongRectFc.top, (jint)lpStruct->top); + (*env)->SetIntField(env, lpObject, TXNLongRectFc.left, (jint)lpStruct->left); + (*env)->SetIntField(env, lpObject, TXNLongRectFc.bottom, (jint)lpStruct->bottom); + (*env)->SetIntField(env, lpObject, TXNLongRectFc.right, (jint)lpStruct->right); +} +#endif /* NO_TXNLongRect */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.h new file mode 100644 index 0000000000..a3a58b7450 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.h @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +/** + * JNI SWT object field getters and setters declarations for Mac/Carbon structs. + */ + +#include <Carbon/Carbon.h> + +#ifndef NO_AEDesc +AEDesc *getAEDescFields(JNIEnv *env, jobject lpObject, AEDesc *lpStruct); +void setAEDescFields(JNIEnv *env, jobject lpObject, AEDesc *lpStruct); +#else +#define getAEDescFields(a,b,c) NULL +#define setAEDescFields(a,b,c) +#endif /* NO_AEDesc */ + +#ifndef NO_ATSTrapezoid +ATSTrapezoid *getATSTrapezoidFields(JNIEnv *env, jobject lpObject, ATSTrapezoid *lpStruct); +void setATSTrapezoidFields(JNIEnv *env, jobject lpObject, ATSTrapezoid *lpStruct); +#else +#define getATSTrapezoidFields(a,b,c) NULL +#define setATSTrapezoidFields(a,b,c) +#endif /* NO_ATSTrapezoid */ + +#ifndef NO_AlertStdCFStringAlertParamRec +AlertStdCFStringAlertParamRec *getAlertStdCFStringAlertParamRecFields(JNIEnv *env, jobject lpObject, AlertStdCFStringAlertParamRec *lpStruct); +void setAlertStdCFStringAlertParamRecFields(JNIEnv *env, jobject lpObject, AlertStdCFStringAlertParamRec *lpStruct); +#else +#define getAlertStdCFStringAlertParamRecFields(a,b,c) NULL +#define setAlertStdCFStringAlertParamRecFields(a,b,c) +#endif /* NO_AlertStdCFStringAlertParamRec */ + +#ifndef NO_BitMap +BitMap *getBitMapFields(JNIEnv *env, jobject lpObject, BitMap *lpStruct); +void setBitMapFields(JNIEnv *env, jobject lpObject, BitMap *lpStruct); +#else +#define getBitMapFields(a,b,c) NULL +#define setBitMapFields(a,b,c) +#endif /* NO_BitMap */ + +#ifndef NO_CFRange +CFRange *getCFRangeFields(JNIEnv *env, jobject lpObject, CFRange *lpStruct); +void setCFRangeFields(JNIEnv *env, jobject lpObject, CFRange *lpStruct); +#else +#define getCFRangeFields(a,b,c) NULL +#define setCFRangeFields(a,b,c) +#endif /* NO_CFRange */ + +#ifndef NO_CGPoint +CGPoint *getCGPointFields(JNIEnv *env, jobject lpObject, CGPoint *lpStruct); +void setCGPointFields(JNIEnv *env, jobject lpObject, CGPoint *lpStruct); +#else +#define getCGPointFields(a,b,c) NULL +#define setCGPointFields(a,b,c) +#endif /* NO_CGPoint */ + +#ifndef NO_CGRect +CGRect *getCGRectFields(JNIEnv *env, jobject lpObject, CGRect *lpStruct); +void setCGRectFields(JNIEnv *env, jobject lpObject, CGRect *lpStruct); +#else +#define getCGRectFields(a,b,c) NULL +#define setCGRectFields(a,b,c) +#endif /* NO_CGRect */ + +#ifndef NO_ColorPickerInfo +ColorPickerInfo *getColorPickerInfoFields(JNIEnv *env, jobject lpObject, ColorPickerInfo *lpStruct); +void setColorPickerInfoFields(JNIEnv *env, jobject lpObject, ColorPickerInfo *lpStruct); +#else +#define getColorPickerInfoFields(a,b,c) NULL +#define setColorPickerInfoFields(a,b,c) +#endif /* NO_ColorPickerInfo */ + +#ifndef NO_ControlButtonContentInfo +ControlButtonContentInfo *getControlButtonContentInfoFields(JNIEnv *env, jobject lpObject, ControlButtonContentInfo *lpStruct); +void setControlButtonContentInfoFields(JNIEnv *env, jobject lpObject, ControlButtonContentInfo *lpStruct); +#else +#define getControlButtonContentInfoFields(a,b,c) NULL +#define setControlButtonContentInfoFields(a,b,c) +#endif /* NO_ControlButtonContentInfo */ + +#ifndef NO_ControlFontStyleRec +ControlFontStyleRec *getControlFontStyleRecFields(JNIEnv *env, jobject lpObject, ControlFontStyleRec *lpStruct); +void setControlFontStyleRecFields(JNIEnv *env, jobject lpObject, ControlFontStyleRec *lpStruct); +#else +#define getControlFontStyleRecFields(a,b,c) NULL +#define setControlFontStyleRecFields(a,b,c) +#endif /* NO_ControlFontStyleRec */ + +#ifndef NO_ControlTabEntry +ControlTabEntry *getControlTabEntryFields(JNIEnv *env, jobject lpObject, ControlTabEntry *lpStruct); +void setControlTabEntryFields(JNIEnv *env, jobject lpObject, ControlTabEntry *lpStruct); +#else +#define getControlTabEntryFields(a,b,c) NULL +#define setControlTabEntryFields(a,b,c) +#endif /* NO_ControlTabEntry */ + +#ifndef NO_ControlTabInfoRecV1 +ControlTabInfoRecV1 *getControlTabInfoRecV1Fields(JNIEnv *env, jobject lpObject, ControlTabInfoRecV1 *lpStruct); +void setControlTabInfoRecV1Fields(JNIEnv *env, jobject lpObject, ControlTabInfoRecV1 *lpStruct); +#else +#define getControlTabInfoRecV1Fields(a,b,c) NULL +#define setControlTabInfoRecV1Fields(a,b,c) +#endif /* NO_ControlTabInfoRecV1 */ + +#ifndef NO_Cursor +Cursor *getCursorFields(JNIEnv *env, jobject lpObject, Cursor *lpStruct); +void setCursorFields(JNIEnv *env, jobject lpObject, Cursor *lpStruct); +#else +#define getCursorFields(a,b,c) NULL +#define setCursorFields(a,b,c) +#endif /* NO_Cursor */ + +#ifndef NO_DataBrowserCallbacks +DataBrowserCallbacks *getDataBrowserCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCallbacks *lpStruct); +void setDataBrowserCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCallbacks *lpStruct); +#else +#define getDataBrowserCallbacksFields(a,b,c) NULL +#define setDataBrowserCallbacksFields(a,b,c) +#endif /* NO_DataBrowserCallbacks */ + +#ifndef NO_DataBrowserCustomCallbacks +DataBrowserCustomCallbacks *getDataBrowserCustomCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCustomCallbacks *lpStruct); +void setDataBrowserCustomCallbacksFields(JNIEnv *env, jobject lpObject, DataBrowserCustomCallbacks *lpStruct); +#else +#define getDataBrowserCustomCallbacksFields(a,b,c) NULL +#define setDataBrowserCustomCallbacksFields(a,b,c) +#endif /* NO_DataBrowserCustomCallbacks */ + +#ifndef NO_DataBrowserListViewColumnDesc +DataBrowserListViewColumnDesc *getDataBrowserListViewColumnDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewColumnDesc *lpStruct); +void setDataBrowserListViewColumnDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewColumnDesc *lpStruct); +#else +#define getDataBrowserListViewColumnDescFields(a,b,c) NULL +#define setDataBrowserListViewColumnDescFields(a,b,c) +#endif /* NO_DataBrowserListViewColumnDesc */ + +#ifndef NO_DataBrowserListViewHeaderDesc +DataBrowserListViewHeaderDesc *getDataBrowserListViewHeaderDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewHeaderDesc *lpStruct); +void setDataBrowserListViewHeaderDescFields(JNIEnv *env, jobject lpObject, DataBrowserListViewHeaderDesc *lpStruct); +#else +#define getDataBrowserListViewHeaderDescFields(a,b,c) NULL +#define setDataBrowserListViewHeaderDescFields(a,b,c) +#endif /* NO_DataBrowserListViewHeaderDesc */ + +#ifndef NO_EventRecord +EventRecord *getEventRecordFields(JNIEnv *env, jobject lpObject, EventRecord *lpStruct); +void setEventRecordFields(JNIEnv *env, jobject lpObject, EventRecord *lpStruct); +#else +#define getEventRecordFields(a,b,c) NULL +#define setEventRecordFields(a,b,c) +#endif /* NO_EventRecord */ + +#ifndef NO_FontInfo +FontInfo *getFontInfoFields(JNIEnv *env, jobject lpObject, FontInfo *lpStruct); +void setFontInfoFields(JNIEnv *env, jobject lpObject, FontInfo *lpStruct); +#else +#define getFontInfoFields(a,b,c) NULL +#define setFontInfoFields(a,b,c) +#endif /* NO_FontInfo */ + +#ifndef NO_FontSelectionQDStyle +FontSelectionQDStyle *getFontSelectionQDStyleFields(JNIEnv *env, jobject lpObject, FontSelectionQDStyle *lpStruct); +void setFontSelectionQDStyleFields(JNIEnv *env, jobject lpObject, FontSelectionQDStyle *lpStruct); +#else +#define getFontSelectionQDStyleFields(a,b,c) NULL +#define setFontSelectionQDStyleFields(a,b,c) +#endif /* NO_FontSelectionQDStyle */ + +#ifndef NO_GDevice +GDevice *getGDeviceFields(JNIEnv *env, jobject lpObject, GDevice *lpStruct); +void setGDeviceFields(JNIEnv *env, jobject lpObject, GDevice *lpStruct); +#else +#define getGDeviceFields(a,b,c) NULL +#define setGDeviceFields(a,b,c) +#endif /* NO_GDevice */ + +#ifndef NO_HICommand +HICommand *getHICommandFields(JNIEnv *env, jobject lpObject, HICommand *lpStruct); +void setHICommandFields(JNIEnv *env, jobject lpObject, HICommand *lpStruct); +#else +#define getHICommandFields(a,b,c) NULL +#define setHICommandFields(a,b,c) +#endif /* NO_HICommand */ + +#ifndef NO_HMHelpContentRec +HMHelpContentRec *getHMHelpContentRecFields(JNIEnv *env, jobject lpObject, HMHelpContentRec *lpStruct); +void setHMHelpContentRecFields(JNIEnv *env, jobject lpObject, HMHelpContentRec *lpStruct); +#else +#define getHMHelpContentRecFields(a,b,c) NULL +#define setHMHelpContentRecFields(a,b,c) +#endif /* NO_HMHelpContentRec */ + +#ifndef NO_MenuTrackingData +MenuTrackingData *getMenuTrackingDataFields(JNIEnv *env, jobject lpObject, MenuTrackingData *lpStruct); +void setMenuTrackingDataFields(JNIEnv *env, jobject lpObject, MenuTrackingData *lpStruct); +#else +#define getMenuTrackingDataFields(a,b,c) NULL +#define setMenuTrackingDataFields(a,b,c) +#endif /* NO_MenuTrackingData */ + +#ifndef NO_NavDialogCreationOptions +NavDialogCreationOptions *getNavDialogCreationOptionsFields(JNIEnv *env, jobject lpObject, NavDialogCreationOptions *lpStruct); +void setNavDialogCreationOptionsFields(JNIEnv *env, jobject lpObject, NavDialogCreationOptions *lpStruct); +#else +#define getNavDialogCreationOptionsFields(a,b,c) NULL +#define setNavDialogCreationOptionsFields(a,b,c) +#endif /* NO_NavDialogCreationOptions */ + +#ifndef NO_PixMap +PixMap *getPixMapFields(JNIEnv *env, jobject lpObject, PixMap *lpStruct); +void setPixMapFields(JNIEnv *env, jobject lpObject, PixMap *lpStruct); +#else +#define getPixMapFields(a,b,c) NULL +#define setPixMapFields(a,b,c) +#endif /* NO_PixMap */ + +#ifndef NO_NavReplyRecord +NavReplyRecord *getNavReplyRecordFields(JNIEnv *env, jobject lpObject, NavReplyRecord *lpStruct); +void setNavReplyRecordFields(JNIEnv *env, jobject lpObject, NavReplyRecord *lpStruct); +#else +#define getNavReplyRecordFields(a,b,c) NULL +#define setNavReplyRecordFields(a,b,c) +#endif /* NO_NavReplyRecord */ + +#ifndef NO_Point +Point *getPointFields(JNIEnv *env, jobject lpObject, Point *lpStruct); +void setPointFields(JNIEnv *env, jobject lpObject, Point *lpStruct); +#else +#define getPointFields(a,b,c) NULL +#define setPointFields(a,b,c) +#endif /* NO_Point */ + +#ifndef NO_RGBColor +RGBColor *getRGBColorFields(JNIEnv *env, jobject lpObject, RGBColor *lpStruct); +void setRGBColorFields(JNIEnv *env, jobject lpObject, RGBColor *lpStruct); +#else +#define getRGBColorFields(a,b,c) NULL +#define setRGBColorFields(a,b,c) +#endif /* NO_RGBColor */ + +#ifndef NO_Rect +Rect *getRectFields(JNIEnv *env, jobject lpObject, Rect *lpStruct); +void setRectFields(JNIEnv *env, jobject lpObject, Rect *lpStruct); +#else +#define getRectFields(a,b,c) NULL +#define setRectFields(a,b,c) +#endif /* NO_Rect */ + +#ifndef NO_ThemeButtonDrawInfo +ThemeButtonDrawInfo *getThemeButtonDrawInfoFields(JNIEnv *env, jobject lpObject, ThemeButtonDrawInfo *lpStruct); +void setThemeButtonDrawInfoFields(JNIEnv *env, jobject lpObject, ThemeButtonDrawInfo *lpStruct); +#else +#define getThemeButtonDrawInfoFields(a,b,c) NULL +#define setThemeButtonDrawInfoFields(a,b,c) +#endif /* NO_ThemeButtonDrawInfo */ + +#ifndef NO_TXNLongRect +TXNLongRect *getTXNLongRectFields(JNIEnv *env, jobject lpObject, TXNLongRect *lpStruct); +void setTXNLongRectFields(JNIEnv *env, jobject lpObject, TXNLongRect *lpStruct); +#else +#define getTXNLongRectFields(a,b,c) NULL +#define setTXNLongRectFields(a,b,c) +#endif /* NO_TXNLongRect */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c index 77016f03fa..65628583d8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c @@ -3,3644 +3,7470 @@ * This file is made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version */ -#ifndef _Included_JNIOut -#include "org_eclipse_swt_internal_carbon_OS.h" +/** + * SWT OS natives implementation. + */ + +#include "swt.h" +#include "structs.h" + +#define OS_NATIVE(func) Java_org_eclipse_swt_internal_carbon_OS_##func + +#ifndef NO_ActiveNonFloatingWindow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ActiveNonFloatingWindow + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("ActiveNonFloatingWindow\n") + + return (jint)ActiveNonFloatingWindow(); +} #endif -#include <Carbon/Carbon.h> - -//#define USE_ATSUI 1 +#ifndef NO_AddDataBrowserItems +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AddDataBrowserItems + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4) +{ + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("AddDataBrowserItems\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)AddDataBrowserItems((ControlRef)arg0, (DataBrowserItemID)arg1, (UInt32)arg2, (const DataBrowserItemID *)lparg3, (DataBrowserPropertyID)arg4); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; +} +#endif /* NO_AddDataBrowserItems */ + +#ifndef NO_AddDataBrowserListViewColumn +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AddDataBrowserListViewColumn + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + DataBrowserListViewColumnDesc _arg1={0}, *lparg1=NULL; + jint rc; + + DEBUG_CALL("AddDataBrowserListViewColumn\n") + + if (arg1) lparg1 = getDataBrowserListViewColumnDescFields(env, arg1, &_arg1); + rc = (jint)AddDataBrowserListViewColumn((ControlRef)arg0, (DataBrowserListViewColumnDesc *)lparg1, (DataBrowserTableViewColumnIndex)arg2); + if (arg1) setDataBrowserListViewColumnDescFields(env, arg1, lparg1); + return rc; +} +#endif /* NO_AddDataBrowserListViewColumn */ + +#ifndef NO_AECountItems +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AECountItems + (JNIEnv *env, jclass that, jobject arg0, jintArray arg1) +{ + AEDesc _arg0, *lparg0=NULL; + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("AECountItems\n") + + if (arg0) lparg0 = getAEDescFields(env, arg0, &_arg0); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)AECountItems((const AEDescList *)lparg0, (long *)lparg1); + if (arg0) setAEDescFields(env, arg0, lparg0); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; +} +#endif /* NO_AECountItems */ + +#ifndef NO_AEGetNthPtr +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AEGetNthPtr + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4, jint arg5, jint arg6, jintArray arg7) +{ + AEDesc _arg0, *lparg0=NULL; + jint *lparg3=NULL; + jint *lparg4=NULL; + jint *lparg7=NULL; + jint rc; + + DEBUG_CALL("AEGetNthPtr\n") + + if (arg0) lparg0 = getAEDescFields(env, arg0, &_arg0); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL); + rc = (jint)AEGetNthPtr((const AEDescList *)lparg0, arg1, (DescType)arg2, (AEKeyword *)lparg3, (DescType *)lparg4, (void *)arg5, (Size)arg6, (Size *)lparg7); + if (arg0) setAEDescFields(env, arg0, lparg0); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0); + return rc; +} +#endif /* NO_AEGetNthPtr */ -static const Rect NULL_RECT; +#ifndef NO_AEProcessAppleEvent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AEProcessAppleEvent + (JNIEnv *env, jclass that, jobject arg0) +{ + EventRecord _arg0, *lparg0=NULL; + jint rc; -// forward declarations -static Point point(JNIEnv *env, jshortArray a); -static void copyEvent(JNIEnv *env, jintArray eData, EventRecord *event); -static void copyEventData(JNIEnv *env, EventRecord *event, jintArray eData); + DEBUG_CALL("AEProcessAppleEvent\n") -#ifdef DEBUG -#define RC(f) checkStatus(__LINE__, (f)) + if (arg0) lparg0 = getEventRecordFields(env, arg0, &_arg0); + rc = (jint)AEProcessAppleEvent((const EventRecord *)lparg0); + if (arg0) setEventRecordFields(env, arg0, lparg0); + return rc; +} +#endif /* NO_AEProcessAppleEvent */ + +#ifndef NO_AppendMenuItemTextWithCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AppendMenuItemTextWithCFString + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jshortArray arg4) +{ + jshort *lparg4=NULL; + jint rc; -static int checkStatus(int line, int rc) { - switch (rc) { - case 0: - case eventNotHandledErr: - case eventLoopTimedOutErr: - case errControlIsNotEmbedder: - break; - default: - //fprintf(stderr, "OS: line: %d %d\n", line, rc); - break; - } - return rc; + DEBUG_CALL("AppendMenuItemTextWithCFString\n") + + if (arg4) lparg4 = (*env)->GetShortArrayElements(env, arg4, NULL); + rc = (jint)AppendMenuItemTextWithCFString((MenuRef)arg0, (CFStringRef)arg1, (MenuItemAttributes)arg2, (MenuCommand)arg3, (MenuItemIndex *)lparg4); + if (arg4) (*env)->ReleaseShortArrayElements(env, arg4, lparg4, 0); + return rc; +} +#endif /* NO_AppendMenuItemTextWithCFString */ + +#ifndef NO_ATSUCreateStyle +JNIEXPORT jint JNICALL OS_NATIVE(ATSUCreateStyle) + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + jint rc; + + DEBUG_CALL("ATSUCreateStyle\n") + + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + rc = (jint)ATSUCreateStyle((ATSUStyle *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + return rc; } -#else -#define RC(f) f #endif -//---- fonts +#ifndef NO_ATSUCreateTextLayout +JNIEXPORT jint JNICALL OS_NATIVE(ATSUCreateTextLayout) + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + jint rc; + + DEBUG_CALL("ATSUCreateTextLayout\n") -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_FMGetFontFamilyFromName(JNIEnv *env, jclass zz, - jbyteArray name) { - jbyte *sa= (*env)->GetByteArrayElements(env, name, 0); - jshort id= (jshort) FMGetFontFamilyFromName((ConstStr255Param) sa); - (*env)->ReleaseByteArrayElements(env, name, sa, 0); - return id; + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + rc = (jint)ATSUCreateTextLayout((ATSUTextLayout *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + return rc; } +#endif + +#ifndef NO_ATSUDisposeStyle +JNIEXPORT jint JNICALL OS_NATIVE(ATSUDisposeStyle) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("ATSUDisposeStyle\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FMGetFontFamilyName(JNIEnv *env, jclass zz, - jshort id, jbyteArray name) { - Str255 s; - jint status= (jshort) RC(FMGetFontFamilyName((FMFontFamily) id, s)); - jbyte *sa= (*env)->GetByteArrayElements(env, name, 0); - memcpy(sa, s, 255); - (*env)->ReleaseByteArrayElements(env, name, sa, 0); - return status; + return (jint)ATSUDisposeStyle((ATSUStyle)arg0); } +#endif -/* -void lisAllFonts() { - FMFontFamilyIterator iter; - FMFontFamily family; - FMCreateFontFamilyIterator(NULL, NULL, kFMUseGlobalScopeOption, &iter); - - while (FMGetNextFontFamily(&iter, &family) != kFMIterationCompleted) { - Str255 name; - FMGetFontFamilyName(family, name); - name[name[0]+1]= 0; - fprintf(stderr, "fontfamily: %s\n", &name[1]); - } - FMDisposeFontFamilyIterator(&iter); -} -*/ - -//---- Appearance Manager - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RegisterAppearanceClient(JNIEnv *env, jclass zz) { - return (jint) RC(RegisterAppearanceClient()); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeWindowBackground(JNIEnv *env, jclass zz, - jint wHandle, jshort brush, jboolean update) { - return (jint) RC(SetThemeWindowBackground((WindowRef) wHandle, (ThemeBrush) brush, (Boolean) update)); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeTextBox(JNIEnv *env, jclass zz, - jint sHandle, jshort fontID, jint state, jboolean wrapToWidth, jshortArray bounds, jshort just, jint context) { - - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - jint status= RC(DrawThemeTextBox((CFStringRef)sHandle, (ThemeFontID)fontID, (ThemeDrawState)state, - (Boolean)wrapToWidth, (const Rect*)sa, (SInt16)just, (void*)context)); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeTextDimensions(JNIEnv *env, jclass zz, - jint sHandle, jshort fontID, jint state, jboolean wrapToWidth, jshortArray size, jshortArray baseLine) { - - jshort *sa= (*env)->GetShortArrayElements(env, size, 0); - jint status= RC(GetThemeTextDimensions((CFStringRef)sHandle, (ThemeFontID)fontID, (ThemeDrawState)state, - (Boolean)wrapToWidth, (Point*)sa, (SInt16*)baseLine)); - (*env)->ReleaseShortArrayElements(env, size, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeEditTextFrame(JNIEnv *env, jclass zz, - jshortArray bounds, jint state) { - jint *sa= (*env)->GetIntArrayElements(env, bounds, 0); - OSStatus status= RC(DrawThemeEditTextFrame((Rect*)sa, state)); - (*env)->ReleaseIntArrayElements(env, bounds, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeFocusRect(JNIEnv *env, jclass zz, - jshortArray bounds, jboolean hasFocus) { - jint *sa= (*env)->GetIntArrayElements(env, bounds, 0); - OSStatus status= RC(DrawThemeFocusRect((Rect*)sa, hasFocus)); - (*env)->ReleaseIntArrayElements(env, bounds, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeGenericWell(JNIEnv *env, jclass zz, - jshortArray bounds, jint state, jboolean fillCenter) { - jint *sa= (*env)->GetIntArrayElements(env, bounds, 0); - OSStatus status= RC(DrawThemeGenericWell((Rect*)sa, state, fillCenter)); - (*env)->ReleaseIntArrayElements(env, bounds, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeSeparator(JNIEnv *env, jclass zz, - jshortArray bounds, jint state) { - jint *sa= (*env)->GetIntArrayElements(env, bounds, 0); - OSStatus status= RC(DrawThemeSeparator((Rect*)sa, state)); - (*env)->ReleaseIntArrayElements(env, bounds, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeFont(JNIEnv *env, jclass zz, - jshort themeFontId, jshort scriptCode, jbyteArray fontName, jshortArray fontSize, jbyteArray style) { - jbyte *sa= NULL; - jshort * sb= NULL; - jbyte *sc= NULL; - jint status= 0; - if (fontName != NULL) - sa= (*env)->GetByteArrayElements(env, fontName, 0); - sb= (*env)->GetShortArrayElements(env, fontSize, 0); - sc= (*env)->GetByteArrayElements(env, style, 0); - status= (jint) RC(GetThemeFont((ThemeFontID)themeFontId, (ScriptCode)scriptCode, (unsigned char*)sa, (SInt16*)sb, (Style*)sc)); - if (sa != NULL) - (*env)->ReleaseByteArrayElements(env, fontName, sa, 0); - (*env)->ReleaseShortArrayElements(env, fontSize, sb, 0); - (*env)->ReleaseByteArrayElements(env, style, sc, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeButton(JNIEnv *env, jclass zz, - jshortArray bounds, jshort kind, jshortArray newInfoArray, jshortArray prevInfoArray, jint eraseProc, - jint labelProc, jint userData) { - ThemeButtonDrawInfo info; - ThemeButtonDrawInfo newInfo, *prevInfo= NULL; - jint status= 0; - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - jshort *sb= (*env)->GetShortArrayElements(env, newInfoArray, 0); - jshort *sc= NULL; - - - newInfo.state= sb[0]; - newInfo.value= sb[1]; - newInfo.adornment= sb[2]; - - if (prevInfoArray != NULL) { - sc= (*env)->GetShortArrayElements(env, prevInfoArray, 0); - info.state= sc[0]; - info.value= sc[1]; - info.adornment= sc[2]; - prevInfo= &info; - } - - status= (jint) RC(DrawThemeButton((const Rect *)sa, (ThemeButtonKind)kind, &newInfo, prevInfo, (ThemeEraseUPP)eraseProc, - (ThemeButtonDrawUPP) labelProc, (UInt32)userData)); - - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); - (*env)->ReleaseShortArrayElements(env, newInfoArray, sb, 0); - if (sc != NULL) - (*env)->ReleaseShortArrayElements(env, prevInfoArray, sc, 0); - - return status; +#ifndef NO_ATSUDisposeTextLayout +JNIEXPORT jint JNICALL OS_NATIVE(ATSUDisposeTextLayout) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("ATSUDisposeTextLayout\n") + + return (jint)ATSUDisposeTextLayout((ATSUTextLayout)arg0); } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeBackground(JNIEnv *env, jclass zz, - jshort brush, jshort depth, jboolean isColorDevice) { - return RC(SetThemeBackground(brush, depth, isColorDevice)); +#ifndef NO_ATSUDrawText +JNIEXPORT jint JNICALL OS_NATIVE(ATSUDrawText) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4) +{ + DEBUG_CALL("ATSUDrawText\n") + + return (jint)ATSUDrawText((ATSUTextLayout)arg0, (UniCharArrayOffset)arg1, (UniCharCount)arg2, (ATSUTextMeasurement)arg3, (ATSUTextMeasurement)arg4); } +#endif + +#ifndef NO_ATSUGetGlyphBounds +JNIEXPORT jint JNICALL OS_NATIVE(ATSUGetGlyphBounds) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jshort arg5, jint arg6, jint arg7, jintArray arg8) +{ + jint *lparg8=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeDrawingState(JNIEnv *env, jclass zz, - jintArray state) { - jint *sa= (*env)->GetIntArrayElements(env, state, 0); - jint status= (jint) RC(GetThemeDrawingState((ThemeDrawingState*) sa)); - (*env)->ReleaseIntArrayElements(env, state, sa, 0); - return status; + DEBUG_CALL("ATSUGetGlyphBounds\n") + + if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL); + rc = (jint)ATSUGetGlyphBounds((ATSUTextLayout)arg0, (ATSUTextMeasurement)arg1, (ATSUTextMeasurement)arg2, (UniCharArrayOffset)arg3, (UniCharCount)arg4, (UInt16)arg5, (ItemCount)arg6, (ATSTrapezoid *)arg7, (ItemCount *)lparg8); + if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0); + return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeDrawingState(JNIEnv *env, jclass zz, - jint state, jboolean disposeNow) { - return RC(SetThemeDrawingState((ThemeDrawingState)state, disposeNow)); +#ifndef NO_ATSUSetAttributes +JNIEXPORT jint JNICALL OS_NATIVE(ATSUSetAttributes) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4) +{ + jint *lparg2=NULL; + jint *lparg3=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("ATSUSetAttributes\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)ATSUSetAttributes((ATSUStyle)arg0, (ItemCount)arg1, (ATSUAttributeTag *)lparg2, (ByteCount *)lparg3, (ATSUAttributeValuePtr *)lparg4); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; +} +#endif + +#ifndef NO_ATSUSetLayoutControls +JNIEXPORT jint JNICALL OS_NATIVE(ATSUSetLayoutControls) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4) +{ + jint *lparg2=NULL; + jint *lparg3=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("ATSUSetLayoutControls\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)ATSUSetLayoutControls((ATSUTextLayout)arg0, (ItemCount)arg1, (ATSUAttributeTag *)lparg2, (ByteCount *)lparg3, (ATSUAttributeValuePtr *)lparg4); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif -//---- tabs +#ifndef NO_ATSUSetRunStyle +JNIEXPORT jint JNICALL OS_NATIVE(ATSUSetRunStyle) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + DEBUG_CALL("ATSUSetRunStyle\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_setTabText(JNIEnv *env, jclass zz, - jint cHandle, jint index, jint sHandle) { - ControlTabInfoRecV1 tab; - - tab.version= kControlTabInfoVersionOne; - tab.iconSuiteID= 0; - tab.name= (CFStringRef) sHandle; - return RC(SetControlData((ControlRef)cHandle, index, kControlTabInfoTag, sizeof(ControlTabInfoRecV1), &tab)); + return (jint)ATSUSetRunStyle((ATSUTextLayout)arg0, (ATSUStyle)arg1, (UniCharArrayOffset)arg2, (UniCharCount)arg3); } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_setTabIcon(JNIEnv *env, jclass zz, - jint cHandle, jint index, jint iconHandle) { - ControlButtonContentInfo tab; - CIconHandle ih= (CIconHandle) iconHandle; - - tab.contentType= kControlContentCIconHandle; - tab.u.cIconHandle= ih; - - return RC(SetControlData((ControlRef)cHandle, index, kControlTabImageContentTag, sizeof(ControlButtonContentInfo), &tab)); +#ifndef NO_ATSUSetTextPointerLocation +JNIEXPORT jint JNICALL OS_NATIVE(ATSUSetTextPointerLocation) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4) +{ + DEBUG_CALL("ATSUSetTextPointerLocation\n") + + return (jint)ATSUSetTextPointerLocation((ATSUTextLayout)arg0, (ConstUniCharArrayPtr)arg1, (UniCharArrayOffset)arg2, (UniCharCount)arg3, (UniCharCount)arg4); } +#endif -//---- Combo +#ifndef NO_AutoSizeDataBrowserListViewColumns +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AutoSizeDataBrowserListViewColumns + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("AutoSizeDataBrowserListViewColumns\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlPopupMenuHandle(JNIEnv *env, jclass zz, - jint cHandle, jint mHandle) { - SetControlPopupMenuHandle((ControlRef)cHandle, (MenuRef) mHandle); + return (jint)AutoSizeDataBrowserListViewColumns((ControlRef)arg0); } +#endif /* NO_AutoSizeDataBrowserListViewColumns */ -//---- DataBrowser +#ifndef NO_BeginUpdate +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_BeginUpdate + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("BeginUpdate\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_createDataBrowserControl(JNIEnv *env, jclass zz, jint wHandle) { - ControlRef controlRef; - DataBrowserCallbacks callbacks; - - CreateDataBrowserControl((WindowRef)wHandle, &NULL_RECT, kDataBrowserListView, &controlRef); - - callbacks.version= kDataBrowserLatestCallbacks; - InitDataBrowserCallbacks(&callbacks); - SetDataBrowserCallbacks(controlRef, &callbacks); - - return (jint) controlRef; -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_setDataBrowserCallbacks(JNIEnv *env, jclass zz, - jint cHandle, jint dataUPP, jint compareUPP, jint notificationUPP) { - DataBrowserCallbacks callbacks; - GetDataBrowserCallbacks((ControlRef) cHandle, &callbacks); - callbacks.u.v1.itemDataCallback= (DataBrowserItemDataUPP) dataUPP; - callbacks.u.v1.itemCompareCallback= (DataBrowserItemCompareUPP) compareUPP; - callbacks.u.v1.itemNotificationCallback= (DataBrowserItemNotificationUPP) notificationUPP; - SetDataBrowserCallbacks((ControlRef) cHandle, &callbacks); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_newColumnDesc(JNIEnv *env, jclass zz, - jint propertyID, jint propertyType, jint propertyFlags, jshort minimumWidth, jshort maximumWidth) { - - DataBrowserListViewColumnDesc *columnDesc= (DataBrowserListViewColumnDesc*) calloc(sizeof(DataBrowserListViewColumnDesc), 1); - - columnDesc->propertyDesc.propertyID= propertyID; - columnDesc->propertyDesc.propertyType= propertyType; - columnDesc->propertyDesc.propertyFlags= propertyFlags; - - columnDesc->headerBtnDesc.version= kDataBrowserListViewLatestHeaderDesc; - columnDesc->headerBtnDesc.minimumWidth= minimumWidth; - columnDesc->headerBtnDesc.maximumWidth= maximumWidth; + BeginUpdate((WindowRef)arg0); +} +#endif /* NO_BeginUpdate */ - columnDesc->headerBtnDesc.titleOffset= 0; - columnDesc->headerBtnDesc.titleString= NULL; - columnDesc->headerBtnDesc.initialOrder= kDataBrowserOrderIncreasing; - - /* - columnDesc.headerBtnDesc.titleAlignment= teCenter; - columnDesc.headerBtnDesc.titleFontTypeID= kControlFontViewSystemFont; - columnDesc.headerBtnDesc.btnFontStyle= normal; - */ +#ifndef NO_BringToFront +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_BringToFront + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("BringToFront\n") - return (jint)columnDesc; + BringToFront((WindowRef)arg0); } +#endif /* NO_BringToFront */ + +#ifndef NO_CFRelease +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFRelease + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CFRelease\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AutoSizeDataBrowserListViewColumns(JNIEnv *env, jclass zz, - jint cHandle) { - return RC(AutoSizeDataBrowserListViewColumns((ControlRef) cHandle)); + CFRelease((CFTypeRef)arg0); } +#endif /* NO_CFRelease */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserActiveItems(JNIEnv *env, jclass zz, - jint cHandle, jboolean active) { - return RC(SetDataBrowserActiveItems((ControlRef) cHandle, (Boolean)active)); +#ifndef NO_CFStringCreateWithCharacters +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringCreateWithCharacters + (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2) +{ + jchar *lparg1=NULL; + jint rc; + + DEBUG_CALL("CFStringCreateWithCharacters\n") + + if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL); + rc = (jint)CFStringCreateWithCharacters((CFAllocatorRef)arg0, (const UniChar *)lparg1, (CFIndex)arg2); + if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_CFStringCreateWithCharacters */ + +#ifndef NO_CFStringGetBytes +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringGetBytes + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jbyte arg3, jboolean arg4, jbyteArray arg5, jint arg6, jintArray arg7) +{ + CFRange _arg1, *lparg1=NULL; + jbyte *lparg5=NULL; + jint *lparg7=NULL; + jint rc; + + DEBUG_CALL("CFStringGetBytes\n") + + if (arg1) lparg1 = getCFRangeFields(env, arg1, &_arg1); + if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL); + if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL); + rc = (jint)CFStringGetBytes((CFStringRef)arg0, (CFRange)*lparg1, (CFStringEncoding)arg2, (UInt8)arg3, (Boolean)arg4, (UInt8 *)lparg5, (CFIndex)arg6, (CFIndex *)lparg7); + if (arg1) setCFRangeFields(env, arg1, lparg1); + if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0); + if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0); + return rc; +} +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AddDataBrowserItems(JNIEnv *env, jclass zz, - jint cHandle, jint containerID, jint numItems, jintArray items, jint sortProperty) { - jint *sa= NULL; - OSStatus status; - if (items != 0) - sa= (*env)->GetIntArrayElements(env, items, 0); - status= RC(AddDataBrowserItems((ControlRef) cHandle, containerID, numItems, (const DataBrowserItemID*) sa, sortProperty)); - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, items, sa, 0); - return (jint) status; +#ifndef NO_CFStringCreateWithBytes +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringCreateWithBytes + (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jboolean arg4) +{ + jbyte *lparg1=NULL; + jint rc; + + DEBUG_CALL("CFStringCreateWithBytes\n") + + if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL); + rc = (jint)CFStringCreateWithBytes((CFAllocatorRef)arg0, (const UInt8 *)lparg1, (CFIndex)arg2, (CFStringEncoding)arg3, (Boolean)arg4); + if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif + +#ifndef NO_CFStringGetCharacters +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringGetCharacters + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jcharArray arg2) +{ + CFRange _arg1, *lparg1=NULL; + jchar *lparg2=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveDataBrowserItems(JNIEnv *env, jclass zz, - jint cHandle, jint containerID, jint numItems, jintArray items, jint sortProperty) { - jint *sa= NULL; - OSStatus status; - if (items != 0) - sa= (*env)->GetIntArrayElements(env, items, 0); - status= RC(RemoveDataBrowserItems((ControlRef) cHandle, containerID, numItems, (const DataBrowserItemID*) sa, sortProperty)); - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, items, sa, 0); - return (jint) status; + DEBUG_CALL("CFStringGetCharacters\n") + + if (arg1) lparg1 = getCFRangeFields(env, arg1, &_arg1); + if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL); + CFStringGetCharacters((CFStringRef)arg0, (CFRange)*lparg1, (UniChar *)lparg2); + if (arg1) setCFRangeFields(env, arg1, lparg1); + if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0); } +#endif /* NO_CFStringGetCharacters */ + +#ifndef NO_CFStringGetLength +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringGetLength + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CFStringGetLength\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataText(JNIEnv *env, jclass zz, - jint itemId, jint sHandle) { - return (jint) RC(SetDataBrowserItemDataText((DataBrowserItemDataRef) itemId, (CFStringRef)sHandle)); + return (jint)CFStringGetLength((CFStringRef)arg0); } +#endif /* NO_CFStringGetLength */ + +#ifndef NO_CFStringGetSystemEncoding +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringGetSystemEncoding + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("CFStringGetSystemEncoding\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataBooleanValue(JNIEnv *env, jclass zz, - jint itemId, jboolean value) { - return (jint) RC(SetDataBrowserItemDataBooleanValue((DataBrowserItemDataRef) itemId, (Boolean)value)); + return (jint)CFStringGetSystemEncoding(); } +#endif + +#ifndef NO_CFURLCopyFileSystemPath +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFURLCopyFileSystemPath + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CFURLCopyFileSystemPath\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataItemID(JNIEnv *env, jclass zz, - jint itemId, jint itemID) { - return (jint) RC(SetDataBrowserItemDataItemID((DataBrowserItemDataRef) itemId, (DataBrowserItemID)itemID)); + return (jint)CFURLCopyFileSystemPath((CFURLRef)arg0, (CFURLPathStyle)arg1); } +#endif /* NO_CFURLCopyFileSystemPath */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataIcon(JNIEnv *env, jclass zz, - jint itemId, jint iconRef) { - return (jint) RC(SetDataBrowserItemDataIcon((DataBrowserItemDataRef) itemId, (IconRef)iconRef)); +#ifndef NO_CFURLCopyLastPathComponent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFURLCopyLastPathComponent + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CFURLCopyLastPathComponent\n") + + return (jint)CFURLCopyLastPathComponent((CFURLRef)arg0); } +#endif + +#ifndef NO_CFURLCreateCopyAppendingPathComponent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFURLCreateCopyAppendingPathComponent + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3) +{ + DEBUG_CALL("CFURLCreateCopyAppendingPathComponent\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataButtonValue(JNIEnv *env, jclass zz, - jint itemId, jshort themeButtonValue) { - return (jint) RC(SetDataBrowserItemDataButtonValue((DataBrowserItemDataRef) itemId, (ThemeButtonValue)themeButtonValue)); + return (jint)CFURLCreateCopyAppendingPathComponent((CFAllocatorRef)arg0, (CFURLRef)arg1, (CFStringRef)arg2, (Boolean)arg3); } +#endif + +#ifndef NO_CFURLCreateCopyDeletingLastPathComponent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFURLCreateCopyDeletingLastPathComponent + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CFURLCreateCopyDeletingLastPathComponent\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserHasScrollBars(JNIEnv *env, jclass zz, - jint cHandle, jboolean hScroll, jboolean vScroll) { - return RC(SetDataBrowserHasScrollBars((ControlRef) cHandle, hScroll, vScroll)); + return (jint)CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef)arg0, (CFURLRef)arg1); } +#endif + +#ifndef NO_CFURLCreateFromFSRef +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFURLCreateFromFSRef + (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + jint rc; + + DEBUG_CALL("CFURLCreateFromFSRef\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserListViewHeaderBtnHeight(JNIEnv *env, jclass zz, - jint cHandle, jshort height) { - return RC(SetDataBrowserListViewHeaderBtnHeight((ControlRef) cHandle, height)); + if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL); + rc = (jint)CFURLCreateFromFSRef((CFAllocatorRef)arg0, (const struct FSRef *)lparg1); + if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_CFURLCreateFromFSRef */ + +#ifndef NO_CGBitmapContextCreate +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGBitmapContextCreate + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6) +{ + DEBUG_CALL("CGBitmapContextCreate\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AddDataBrowserListViewColumn(JNIEnv *env, jclass zz, - jint cHandle, jint handle, jint index) { - return RC(AddDataBrowserListViewColumn((ControlRef)cHandle, (DataBrowserListViewColumnDesc*)handle, (DataBrowserTableViewColumnIndex)index)); + return (jint)CGBitmapContextCreate((void *)arg0, (size_t)arg1, (size_t)arg2, (size_t)arg3, (size_t)arg4, (CGColorSpaceRef)arg5, (CGImageAlphaInfo)arg6); } +#endif /* NO_CGBitmapContextCreate */ + +#ifndef NO_CGColorSpaceCreateDeviceRGB +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGColorSpaceCreateDeviceRGB + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("CGColorSpaceCreateDeviceRGB\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_UpdateDataBrowserItems(JNIEnv *env, jclass zz, - jint cHandle, jint container, jint numItems, jintArray items, jint preSortProperty, jint propertyID) { - jint *sa= (*env)->GetIntArrayElements(env, items, 0); - jint status= RC(UpdateDataBrowserItems((ControlRef)cHandle, (DataBrowserItemID)container, numItems, sa, - (DataBrowserPropertyID)preSortProperty, (DataBrowserPropertyID) propertyID)); - (*env)->ReleaseIntArrayElements(env, items, sa, 0); - return status; + return (jint)CGColorSpaceCreateDeviceRGB(); } +#endif /* NO_CGColorSpaceCreateDeviceRGB */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserSelectionFlags(JNIEnv *env, jclass zz, - jint cHandle, jint selectionFlags) { - return RC(SetDataBrowserSelectionFlags((ControlRef)cHandle, (DataBrowserSelectionFlags) selectionFlags)); +#ifndef NO_CGColorSpaceRelease +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGColorSpaceRelease + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGColorSpaceRelease\n") + + CGColorSpaceRelease((CGColorSpaceRef)arg0); } +#endif /* NO_CGColorSpaceRelease */ + +#ifndef NO_CGContextAddArc +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextAddArc + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2, jfloat arg3, jfloat arg4, jfloat arg5, jboolean arg6) +{ + DEBUG_CALL("CGContextAddArc\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItemCount(JNIEnv *env, jclass zz, - jint cHandle, jint container, jboolean recurse, jint state, jintArray numItems) { - jint *sa= (*env)->GetIntArrayElements(env, numItems, 0); - OSStatus status= RC(GetDataBrowserItemCount((ControlRef)cHandle, (DataBrowserItemID)container, recurse, state, sa)); - (*env)->ReleaseIntArrayElements(env, numItems, sa, 0); - return status; + CGContextAddArc((CGContextRef)arg0, (float)arg1, (float)arg2, (float)arg3, (float)arg4, (float)arg5, (Boolean)arg6); } +#endif /* NO_CGContextAddArc */ + +#ifndef NO_CGContextAddArcToPoint +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextAddArcToPoint + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2, jfloat arg3, jfloat arg4, jfloat arg5) +{ + DEBUG_CALL("CGContextAddArcToPoint\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItems(JNIEnv *env, jclass zz, - jint cHandle, jint container, jboolean recurse, jint state, jint items) { - return RC(GetDataBrowserItems((ControlRef)cHandle, (DataBrowserItemID)container, recurse, - (DataBrowserItemState)state, (Handle)items)); + CGContextAddArcToPoint((CGContextRef)arg0, (float)arg1, (float)arg2, (float)arg3, (float)arg4, (float)arg5); } +#endif /* NO_CGContextAddArc */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserSelectedItems(JNIEnv *env, jclass zz, - jint cHandle, jint numItems, jintArray items, jint operation) { - jint *sa= (*env)->GetIntArrayElements(env, items, 0); - OSStatus status= RC(SetDataBrowserSelectedItems((ControlRef)cHandle, numItems, (DataBrowserItemID*)sa, operation)); - (*env)->ReleaseIntArrayElements(env, items, sa, 0); - return status; +#ifndef NO_CGContextAddLineToPoint +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextAddLineToPoint + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("CGContextAddLineToPoint\n") + + CGContextAddLineToPoint((CGContextRef)arg0, arg1, arg2); } +#endif /* NO_CGContextAddLineToPoint */ + +#ifndef NO_CGContextAddLines +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextAddLines + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + jfloat *lparg1=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RevealDataBrowserItem(JNIEnv *env, jclass zz, - jint cHandle, jint item, jint propertyID, jboolean centerInView) { - return RC(RevealDataBrowserItem((ControlRef)cHandle, item, propertyID, centerInView)); + DEBUG_CALL("CGContextAddLines\n") + + if (arg1) lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL); + CGContextAddLines((CGContextRef)arg0, (const CGPoint *)lparg1, (size_t)arg2); + if (arg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, 0); } +#endif /* NO_CGContextAddLines */ + +#ifndef NO_CGContextBeginPath +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextBeginPath + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextBeginPath\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsDataBrowserItemSelected(JNIEnv *env, jclass zz, - jint cHandle, jint item) { - return IsDataBrowserItemSelected((ControlRef)cHandle, item); + CGContextBeginPath((CGContextRef)arg0); } +#endif /* NO_CGContextBeginPath */ + +#ifndef NO_CGContextClip +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextClip + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextClip\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserScrollPosition(JNIEnv *env, jclass zz, - jint cHandle, jintArray top, jintArray left) { - jint *sa= (*env)->GetIntArrayElements(env, top, 0); - jint *sb= (*env)->GetIntArrayElements(env, left, 0); - jint status= RC(GetDataBrowserScrollPosition((ControlRef)cHandle, (UInt32*)sa, (UInt32*)sb)); - (*env)->ReleaseIntArrayElements(env, top, sa, 0); - (*env)->ReleaseIntArrayElements(env, left, sb, 0); - return status; + CGContextClip((CGContextRef)arg0); } +#endif /* NO_CGContextClip */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserScrollPosition(JNIEnv *env, jclass zz, - jint cHandle, jint top, jint left) { - return RC(SetDataBrowserScrollPosition((ControlRef)cHandle, (UInt32)top, (UInt32)left)); +#ifndef NO_CGContextClosePath +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextClosePath + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextClosePath\n") + + CGContextClosePath((CGContextRef)arg0); } +#endif /* NO_CGContextClosePath */ + +#ifndef NO_CGContextDrawImage +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextDrawImage + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + CGRect _arg1, *lparg1=NULL; + + DEBUG_CALL("CGContextDrawImage\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserTarget(JNIEnv *env, jclass zz, - jint cHandle, jint rootID) { - return RC(SetDataBrowserTarget((ControlRef)cHandle, (DataBrowserItemID)rootID)); + if (arg1) lparg1 = getCGRectFields(env, arg1, &_arg1); + CGContextDrawImage((CGContextRef)arg0, (CGRect)*lparg1, (CGImageRef)arg2); + if (arg1) setCGRectFields(env, arg1, lparg1); } +#endif /* NO_CGContextDrawImage */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserListViewDisclosureColumn(JNIEnv *env, jclass zz, - jint cHandle, jint colID, jboolean b) { - return RC(SetDataBrowserListViewDisclosureColumn((ControlRef)cHandle, (DataBrowserTableViewColumnID)colID, (Boolean)b)); +#ifndef NO_CGContextFillPath +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextFillPath + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextFillPath\n") + + CGContextFillPath((CGContextRef)arg0); } +#endif /* NO_CGContextFillPath */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItemPartBounds(JNIEnv *env, jclass zz, - jint cHandle, jint item, jint property, jint part, jshortArray bounds) { - jint *sa= (*env)->GetIntArrayElements(env, bounds, 0); - int rc= RC(GetDataBrowserItemPartBounds((ControlRef)cHandle, item, property, part, (Rect*) sa)); - (*env)->ReleaseIntArrayElements(env, bounds, sa, 0); - return rc; +#ifndef NO_CGContextFillRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextFillRect + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + CGRect _arg1, *lparg1=NULL; + + DEBUG_CALL("CGContextFillRect\n") + + if (arg1) lparg1 = getCGRectFields(env, arg1, &_arg1); + CGContextFillRect((CGContextRef)arg0, (CGRect)*lparg1); + if (arg1) setCGRectFields(env, arg1, lparg1); +} +#endif /* NO_CGContextFillRect */ + +#ifndef NO_CGContextFlush +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextFlush + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("CGContextFlush\n") + + CGContextFlush((CGContextRef)arg0); +} +#endif /* NO_CGContextFlush */ + +#ifndef NO_CGContextGetTextPosition +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextGetTextPosition + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + CGPoint _arg1, *lparg1=NULL; + + DEBUG_CALL("CGContextGetTextPosition\n") + + if (arg1) lparg1 = getCGPointFields(env, arg1, &_arg1); + *lparg1 = CGContextGetTextPosition((CGContextRef)arg0); + if (arg1) setCGPointFields(env, arg1, lparg1); +} +#endif /* NO_CGContextGetTextPosition */ + +#ifndef NO_CGContextMoveToPoint +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextMoveToPoint + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("CGContextMoveToPoint\n") + + CGContextMoveToPoint((CGContextRef)arg0, (float)arg1, (float)arg2); +} +#endif /* NO_CGContextMoveToPoint */ + +#ifndef NO_CGContextRelease +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextRelease + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextRelease\n") + + CGContextRelease((CGContextRef)arg0); +} +#endif /* NO_CGContextRelease */ + +#ifndef NO_CGContextRestoreGState +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextRestoreGState + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextRestoreGState\n") + + CGContextRestoreGState((CGContextRef)arg0); +} +#endif /* NO_CGContextRestoreGState */ + +#ifndef NO_CGContextSaveGState +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSaveGState + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextSaveGState\n") + + CGContextSaveGState((CGContextRef)arg0); +} +#endif /* NO_CGContextSaveGState */ + +#ifndef NO_CGContextScaleCTM +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextScaleCTM + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("CGContextScaleCTM\n") + + CGContextScaleCTM((CGContextRef)arg0, (float)arg1, (float)arg2); } +#endif /* NO_CGContextScaleCTM */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_OpenDataBrowserContainer(JNIEnv *env, jclass zz, - jint cHandle, jint container) { - return RC(OpenDataBrowserContainer((ControlRef)cHandle, container)); +#ifndef NO_CGContextSelectFont +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSelectFont + (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jfloat arg2, jint arg3) +{ + jbyte *lparg1=NULL; + + DEBUG_CALL("CGContextSelectFont\n") + + if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL); + CGContextSelectFont((CGContextRef)arg0, (const char *)lparg1, (float)arg2, (CGTextEncoding)arg3); + if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); +} +#endif /* NO_CGContextSelectFont */ + +#ifndef NO_CGContextSetFillColor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetFillColor + (JNIEnv *env, jclass that, jint arg0, jfloatArray arg1) +{ + jfloat *lparg1=NULL; + + DEBUG_CALL("CGContextSetFillColor\n") + + if (arg1) lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL); + CGContextSetFillColor((CGContextRef)arg0, (const float *)lparg1); + if (arg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, 0); +} +#endif /* NO_CGContextSetFillColor */ + +#ifndef NO_CGContextSetFillColorSpace +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetFillColorSpace + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CGContextSetFillColorSpace\n") + + CGContextSetFillColorSpace((CGContextRef)arg0, (CGColorSpaceRef)arg1); +} +#endif /* NO_CGContextSetFillColorSpace */ + +#ifndef NO_CGContextSetFontSize +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetFontSize + (JNIEnv *env, jclass that, jint arg0, jfloat arg1) +{ + DEBUG_CALL("CGContextSetFontSize\n") + + CGContextSetFontSize((CGContextRef)arg0, (float)arg1); +} +#endif /* NO_CGContextSetFontSize */ + +#ifndef NO_CGContextSetLineDash +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetLineDash + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloatArray arg2, jint arg3) +{ + jfloat *lparg2=NULL; + + DEBUG_CALL("CGContextSetLineDash\n") + + if (arg2) lparg2 = (*env)->GetFloatArrayElements(env, arg2, NULL); + CGContextSetLineDash((CGContextRef)arg0, (float)arg1, (const float *)lparg2, (size_t)arg3); + if (arg2) (*env)->ReleaseFloatArrayElements(env, arg2, lparg2, 0); } +#endif /* NO_CGContextSetLineDash */ + +#ifndef NO_CGContextSetLineWidth +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetLineWidth + (JNIEnv *env, jclass that, jint arg0, jfloat arg1) +{ + DEBUG_CALL("CGContextSetLineWidth\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CloseDataBrowserContainer(JNIEnv *env, jclass zz, - jint cHandle, jint container) { - return RC(CloseDataBrowserContainer((ControlRef)cHandle, container)); + CGContextSetLineWidth((CGContextRef)arg0, (float)arg1); } +#endif /* NO_CGContextSetLineWidth */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItemState(JNIEnv *env, jclass zz, - jint cHandle, jint item, jshortArray state) { - jint *sa= (*env)->GetIntArrayElements(env, state, 0); - int rc= RC(GetDataBrowserItemState((ControlRef)cHandle, item, (DataBrowserItemState*) sa)); - (*env)->ReleaseIntArrayElements(env, state, sa, 0); +#ifndef NO_CGContextSetRGBFillColor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetRGBFillColor + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2, jfloat arg3, jfloat arg4) +{ + DEBUG_CALL("CGContextSetRGBFillColor\n") + + CGContextSetRGBFillColor((CGContextRef)arg0, (float)arg1, (float)arg2, (float)arg3, (float)arg4); +} +#endif /* NO_CGContextSetRGBFillColor */ + +#ifndef NO_CGContextSetRGBStrokeColor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetRGBStrokeColor + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2, jfloat arg3, jfloat arg4) +{ + DEBUG_CALL("CGContextSetRGBStrokeColor\n") + + CGContextSetRGBStrokeColor((CGContextRef)arg0, (float)arg1, (float)arg2, (float)arg3, (float)arg4); +} +#endif /* NO_CGContextSetRGBStrokeColor */ + +#ifndef NO_CGContextSetStrokeColor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetStrokeColor + (JNIEnv *env, jclass that, jint arg0, jfloatArray arg1) +{ + jfloat *lparg1=NULL; + + DEBUG_CALL("CGContextSetStrokeColor\n") + + if (arg1) lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL); + CGContextSetStrokeColor((CGContextRef)arg0, (const float *)lparg1); + if (arg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, 0); +} +#endif /* NO_CGContextSetStrokeColor */ + +#ifndef NO_CGContextSetStrokeColorSpace +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetStrokeColorSpace + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CGContextSetStrokeColorSpace\n") + + CGContextSetStrokeColorSpace((CGContextRef)arg0, (CGColorSpaceRef)arg1); +} +#endif /* NO_CGContextSetStrokeColorSpace */ + +#ifndef NO_CGContextSetTextDrawingMode +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetTextDrawingMode + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CGContextSetTextDrawingMode\n") + + CGContextSetTextDrawingMode((CGContextRef)arg0, (CGTextDrawingMode)arg1); +} +#endif /* NO_CGContextSetTextDrawingMode */ + +#ifndef NO_CGContextSetTextMatrix +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetTextMatrix + (JNIEnv *env, jclass that, jint arg0, jfloatArray arg1) +{ + jfloat *lparg1=NULL; + + DEBUG_CALL("CGContextSetTextMatrix\n") + + if (arg1) lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL); + CGContextSetTextMatrix((CGContextRef)arg0, *(CGAffineTransform *)lparg1); + if (arg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, 0); +} +#endif /* NO_CGContextSetTextMatrix */ + +#ifndef NO_CGContextSetTextPosition +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSetTextPosition + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("CGContextSetTextPosition\n") + + CGContextSetTextPosition((CGContextRef)arg0, (float)arg1, (float)arg2); +} +#endif /* NO_CGContextSetTextPosition */ + +#ifndef NO_CGContextShowText +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextShowText + (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2) +{ + jbyte *lparg1=NULL; + + DEBUG_CALL("CGContextShowText\n") + + if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL); + CGContextShowText((CGContextRef)arg0, (const char *)lparg1, (size_t)arg2); + if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); +} +#endif /* NO_CGContextShowText */ + +#ifndef NO_CGContextShowTextAtPoint +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextShowTextAtPoint + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2, jbyteArray arg3, jint arg4) +{ + jbyte *lparg3=NULL; + + DEBUG_CALL("CGContextShowTextAtPoint\n") + + if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL); + CGContextShowTextAtPoint((CGContextRef)arg0, (float)arg1, (float)arg2, (const char *)lparg3, (size_t)arg4); + if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0); +} +#endif /* NO_CGContextShowTextAtPoint */ + +#ifndef NO_CGContextStrokePath +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextStrokePath + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGContextStrokePath\n") + + CGContextStrokePath((CGContextRef)arg0); +} +#endif /* NO_CGContextStrokePath */ + +#ifndef NO_CGContextStrokeRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextStrokeRect + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + CGRect _arg1, *lparg1=NULL; + + DEBUG_CALL("CGContextStrokeRect\n") + + if (arg1) lparg1 = getCGRectFields(env, arg1, &_arg1); + CGContextStrokeRect((CGContextRef)arg0, (CGRect)*lparg1); + if (arg1) setCGRectFields(env, arg1, lparg1); +} +#endif /* NO_CGContextStrokeRect */ + +#ifndef NO_CGContextTranslateCTM +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextTranslateCTM + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("CGContextTranslateCTM\n") + + CGContextTranslateCTM((CGContextRef)arg0, (float)arg1, (float)arg2); +} +#endif /* NO_CGContextTranslateCTM */ + +#ifndef NO_CGContextSynchronize +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSynchronize + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("CGContextSynchronize\n") + + CGContextSynchronize((CGContextRef)arg0); +} +#endif /* NO_CGContextSynchronize */ + +#ifndef NO_CGDataProviderCreateWithData +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGDataProviderCreateWithData + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + DEBUG_CALL("CGDataProviderCreateWithData\n") + + return (jint)CGDataProviderCreateWithData((void *)arg0, (const void *)arg1, (size_t)arg2, (void *)arg3); +} +#endif /* NO_CGDataProviderCreateWithData */ + +#ifndef NO_CGDataProviderRelease +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGDataProviderRelease + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGDataProviderRelease\n") + + CGDataProviderRelease((CGDataProviderRef)arg0); +} +#endif /* NO_CGDataProviderRelease */ + +#ifndef NO_CGImageCreate +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageCreate + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jfloatArray arg8, jboolean arg9, jint arg10) +{ + jfloat *lparg8=NULL; + jint rc; + + DEBUG_CALL("CGImageCreate\n") + + if (arg8) lparg8 = (*env)->GetFloatArrayElements(env, arg8, NULL); + rc = (jint)CGImageCreate((size_t)arg0, (size_t)arg1, (size_t)arg2, (size_t)arg3, (size_t)arg4, (CGColorSpaceRef)arg5, (CGImageAlphaInfo)arg6, (CGDataProviderRef)arg7, (const float *)lparg8, (Boolean)arg9, (CGColorRenderingIntent)arg10); + if (arg8) (*env)->ReleaseFloatArrayElements(env, arg8, lparg8, 0); return rc; } +#endif /* NO_CGImageCreate */ -//---- events +#ifndef NO_CGImageGetAlphaInfo +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageGetAlphaInfo + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageGetAlphaInfo\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CallNextEventHandler(JNIEnv *env, jclass zz, - jint nextHandler, jint eventRefHandle) { - return (jint) CallNextEventHandler((EventHandlerCallRef) nextHandler, (EventRef) eventRefHandle); + return (jint)CGImageGetAlphaInfo((CGImageRef)arg0); } +#endif /* NO_CGImageGetAlphaInfo */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventHICommand(JNIEnv *env, jclass zz, - jint eRefHandle, jintArray outParamType) { - jint status; - HICommand command; - - status= (jint) RC(GetEventParameter((EventRef)eRefHandle, kEventParamDirectObject, typeHICommand, - NULL, sizeof(HICommand), NULL, &command)); - - if (outParamType != NULL) { - jint *sa= (*env)->GetIntArrayElements(env, outParamType, 0); - sa[0]= (jint) command.attributes; - sa[1]= (jint) command.commandID; - sa[2]= (jint) command.menu.menuRef; - sa[3]= (jint) command.menu.menuItemIndex; - (*env)->ReleaseIntArrayElements(env, outParamType, sa, 0); - } - - return status; -} - - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3I_3I_3B(JNIEnv *env, jclass zz, - jint eRefHandle, jint paramName, jint paramType, jintArray outParamType, jintArray outActualSize, jbyteArray data) { - jint status; - jint *sa= NULL; - jint *sb= NULL; - jbyte *sc= NULL; - int size= 0; - - if (outParamType != NULL) - sa= (*env)->GetIntArrayElements(env, outParamType, 0); - if (outActualSize != NULL) - sb= (*env)->GetIntArrayElements(env, outActualSize, 0); - if (data != NULL) { - sc= (*env)->GetByteArrayElements(env, data, 0); - size= (*env)->GetArrayLength(env, data); - } - - status= (jint) RC(GetEventParameter((EventRef)eRefHandle, (EventParamName)paramName, (EventParamType)paramType, - (EventParamType*)sa, size * sizeof(jbyte), (UInt32*)sb, (void*)sc)); - - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, outParamType, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, outActualSize, sb, 0); - if (sc != NULL) - (*env)->ReleaseByteArrayElements(env, data, sc, 0); - - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3I_3I_3C(JNIEnv *env, jclass zz, - jint eRefHandle, jint paramName, jint paramType, jintArray outParamType, jintArray outActualSize, jcharArray data) { - jint status; - jint *sa= NULL; - jint *sb= NULL; - jchar *sc= NULL; - int size= 0; - - if (outParamType != NULL) - sa= (*env)->GetIntArrayElements(env, outParamType, 0); - if (outActualSize != NULL) - sb= (*env)->GetIntArrayElements(env, outActualSize, 0); - if (data != NULL) { - sc= (*env)->GetCharArrayElements(env, data, 0); - size= (*env)->GetArrayLength(env, data); - } - - status= (jint) RC(GetEventParameter((EventRef)eRefHandle, (EventParamName)paramName, (EventParamType)paramType, - (EventParamType*)sa, size * sizeof(jchar), (UInt32*)sb, (void*)sc)); - - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, outParamType, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, outActualSize, sb, 0); - if (sc != NULL) - (*env)->ReleaseCharArrayElements(env, data, sc, 0); - - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3I_3I_3S(JNIEnv *env, jclass zz, - jint eRefHandle, jint paramName, jint paramType, jintArray outParamType, jintArray outActualSize, jshortArray data) { - jint status; - jint *sa= NULL; - jint *sb= NULL; - jshort *sc= NULL; - int size= 0; - - if (outParamType != NULL) - sa= (*env)->GetIntArrayElements(env, outParamType, 0); - if (outActualSize != NULL) - sb= (*env)->GetIntArrayElements(env, outActualSize, 0); - if (data != NULL) { - sc= (*env)->GetShortArrayElements(env, data, 0); - size= (*env)->GetArrayLength(env, data); - } - - status= (jint) RC(GetEventParameter((EventRef)eRefHandle, (EventParamName)paramName, (EventParamType)paramType, - (EventParamType*)sa, size * sizeof(jshort), (UInt32*)sb, (void*)sc)); - - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, outParamType, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, outActualSize, sb, 0); - if (sc != NULL) - (*env)->ReleaseShortArrayElements(env, data, sc, 0); - - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3I_3I_3I(JNIEnv *env, jclass zz, - jint eRefHandle, jint paramName, jint paramType, jintArray outParamType, jintArray outActualSize, jintArray data) { - jint status; - jint *sa= NULL; - jint *sb= NULL; - jint *sc= NULL; - int size= 0; - - if (outParamType != NULL) - sa= (*env)->GetIntArrayElements(env, outParamType, 0); - if (outActualSize != NULL) - sb= (*env)->GetIntArrayElements(env, outActualSize, 0); - if (data != NULL) { - sc= (*env)->GetIntArrayElements(env, data, 0); - size= (*env)->GetArrayLength(env, data); - } - - status= (jint) RC(GetEventParameter((EventRef)eRefHandle, (EventParamName)paramName, (EventParamType)paramType, - (EventParamType*)sa, size * sizeof(jint), (UInt32*)sb, (void*)sc)); - - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, outParamType, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, outActualSize, sb, 0); - if (sc != NULL) - (*env)->ReleaseIntArrayElements(env, data, sc, 0); +#ifndef NO_CGImageGetBitsPerComponent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageGetBitsPerComponent + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageGetBitsPerComponent\n") - return status; + return (jint)CGImageGetBitsPerComponent((CGImageRef)arg0); } +#endif /* NO_CGImageGetBitsPerComponent */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetEventParameter(JNIEnv *env, jclass zz, - jint eRefHandle, jint paramName, jint paramType, jcharArray data) { - jint status; - jchar *sc= NULL; - int size= 0; - - if (data != NULL) { - sc= (*env)->GetCharArrayElements(env, data, 0); - size= (*env)->GetArrayLength(env, data); - } - - status= (jint) RC(SetEventParameter((EventRef)eRefHandle, (EventParamName)paramName, (EventParamType)paramType, - size * sizeof(jchar), (void*)sc)); - - if (sc != NULL) - (*env)->ReleaseCharArrayElements(env, data, sc, 0); +#ifndef NO_CGImageGetBitsPerPixel +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageGetBitsPerPixel + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageGetBitsPerPixel\n") - return status; + return (jint)CGImageGetBitsPerPixel((CGImageRef)arg0); } +#endif /* NO_CGImageGetBitsPerPixel */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InstallEventHandler(JNIEnv *env, jclass zz, - jint eventTargetRef, jint eventHandlerUPP, jintArray eventTypes, jint clientData) { - jint *sa= (*env)->GetIntArrayElements(env, eventTypes, 0); - jsize length= (*env)->GetArrayLength(env, eventTypes); - jint status; - - status= (jint) RC(InstallEventHandler( - (EventTargetRef) eventTargetRef, - (EventHandlerUPP) eventHandlerUPP, - length/2, (EventTypeSpec*) sa, - (void*) clientData, - NULL - )); - - (*env)->ReleaseIntArrayElements(env, eventTypes, sa, 0); - - return status; +#ifndef NO_CGImageGetBytesPerRow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageGetBytesPerRow + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageGetBytesPerRow\n") + + return (jint)CGImageGetBytesPerRow((CGImageRef)arg0); +} +#endif /* NO_CGImageGetBytesPerRow */ + +#ifndef NO_CGImageGetColorSpace +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageGetColorSpace + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageGetColorSpace\n") + + return (jint)CGImageGetColorSpace((CGImageRef)arg0); +} +#endif /* NO_CGImageGetColorSpace */ + +#ifndef NO_CGImageGetHeight +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageGetHeight + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageGetHeight\n") + + return (jint)CGImageGetHeight((CGImageRef)arg0); +} +#endif /* NO_CGImageGetHeight */ + +#ifndef NO_CGImageGetWidth +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageGetWidth + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageGetWidth\n") + + return (jint)CGImageGetWidth((CGImageRef)arg0); } +#endif /* NO_CGImageGetWidth */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlEventTarget(JNIEnv *env, jclass zz, jint cHandle) { - return (jint) GetControlEventTarget((ControlRef) cHandle); +#ifndef NO_CGImageRelease +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGImageRelease + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CGImageRelease\n") + + CGImageRelease((CGImageRef)arg0); } +#endif /* NO_CGImageRelease */ + +#ifndef NO_CallNextEventHandler +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CallNextEventHandler + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CallNextEventHandler\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuEventTarget(JNIEnv *env, jclass zz, jint mHandle) { - return (jint) GetMenuEventTarget((MenuRef) mHandle); + return (jint)CallNextEventHandler((EventHandlerCallRef)arg0, (EventRef)arg1); } +#endif /* NO_CallNextEventHandler */ + +#ifndef NO_CharWidth +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_CharWidth + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("CharWidth\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetUserFocusEventTarget(JNIEnv *env, jclass zz) { - return (jint) GetUserFocusEventTarget(); + return (jshort)CharWidth((CharParameter)arg0); } +#endif /* NO_CharWidth */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetApplicationEventTarget(JNIEnv *env, jclass zz) { - return (jint) GetApplicationEventTarget(); +#ifndef NO_ClearCurrentScrap +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClearCurrentScrap + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("ClearCurrentScrap\n") + + return (jint)ClearCurrentScrap(); } +#endif /* NO_ClearCurrentScrap */ + +#ifndef NO_ClearKeyboardFocus +JNIEXPORT jint JNICALL OS_NATIVE(ClearKeyboardFocus) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("ClearKeyboardFocus\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetUserFocusWindow(JNIEnv *env, jclass zz) { - return (jint) GetUserFocusWindow(); + return (jint)ClearKeyboardFocus((WindowRef)arg0); } +#endif -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_EventAvail(JNIEnv *env, jclass zz, jshort mask, jint eHandle) { - return (jboolean) EventAvail(mask, (EventRecord*) eHandle); +#ifndef NO_ClearMenuBar +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClearMenuBar + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("ClearMenuBar\n") + + ClearMenuBar(); } +#endif /* NO_ClearMenuBar */ + +#ifndef NO_ClipCGContextToRegion +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClipCGContextToRegion + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + Rect _arg1, *lparg1=NULL; + jint rc; -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetNextEvent(JNIEnv *env, jclass zz, jshort mask, jintArray eData) { - EventRecord event; - jboolean rc= GetNextEvent(mask, &event); - copyEvent(env, eData, &event); + DEBUG_CALL("ClipCGContextToRegion\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + rc = (jint)ClipCGContextToRegion((CGContextRef)arg0, (const Rect *)lparg1, (RgnHandle)arg2); + if (arg1) setRectFields(env, arg1, lparg1); return rc; } +#endif /* NO_ClipCGContextToRegion */ + +#ifndef NO_CloseDataBrowserContainer +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CloseDataBrowserContainer + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CloseDataBrowserContainer\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_WaitNextEvent(JNIEnv *env, jclass zz, jshort mask, jintArray eData, jint sleeptime) { - EventRecord event; - jboolean rc= WaitNextEvent(mask, &event, sleeptime, nil); - copyEvent(env, eData, &event); + return (jint)CloseDataBrowserContainer((ControlRef)arg0, (DataBrowserItemID)arg1); +} +#endif /* NO_CloseDataBrowserContainer */ + +#ifndef NO_ClosePoly +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClosePoly + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("ClosePoly\n") + + ClosePoly(); +} +#endif /* NO_ClosePoly */ + +#ifndef NO_CollapseWindow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CollapseWindow + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("CollapseWindow\n") + + return (jint)CollapseWindow((WindowRef)arg0, (Boolean)arg1); +} +#endif /* NO_CollapseWindow */ + +#ifndef NO_ConvertEventRefToEventRecord +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_ConvertEventRefToEventRecord + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + EventRecord _arg1, *lparg1=NULL; + jboolean rc; + + DEBUG_CALL("ConvertEventRefToEventRecord\n") + + if (arg1) lparg1 = getEventRecordFields(env, arg1, &_arg1); + rc = (jboolean)ConvertEventRefToEventRecord((EventRef)arg0, (EventRecord *)lparg1); + if (arg1) setEventRecordFields(env, arg1, lparg1); return rc; } +#endif /* NO_ConvertEventRefToEventRecord */ -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_StillDown(JNIEnv *env, jclass zz) { - return (jboolean) StillDown(); +#ifndef NO_CopyBits +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyBits + (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jshort arg4, jint arg5) +{ + Rect _arg2, *lparg2=NULL; + Rect _arg3, *lparg3=NULL; + + DEBUG_CALL("CopyBits\n") + + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + if (arg3) lparg3 = getRectFields(env, arg3, &_arg3); + CopyBits((const BitMap *)arg0, (const BitMap *)arg1, (const Rect *)lparg2, (const Rect *)lparg3, (short)arg4, (RgnHandle)arg5); + if (arg2) setRectFields(env, arg2, lparg2); + if (arg3) setRectFields(env, arg3, lparg3); +} +#endif /* NO_CopyBits */ + +#ifndef NO_CopyControlTitleAsCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyControlTitleAsCFString + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("CopyControlTitleAsCFString\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)CopyControlTitleAsCFString((ControlRef)arg0, (CFStringRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_CopyControlTitleAsCFString */ + +#ifndef NO_CopyDeepMask +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyDeepMask + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jobject arg4, jobject arg5, jshort arg6, jint arg7) +{ + Rect _arg3, *lparg3=NULL; + Rect _arg4, *lparg4=NULL; + Rect _arg5, *lparg5=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMouse(JNIEnv *env, jclass zz, jshortArray where) { - jshort *sa= (*env)->GetShortArrayElements(env, where, 0); - GetMouse((struct Point*)sa); - (*env)->ReleaseShortArrayElements(env, where, sa, 0); + DEBUG_CALL("CopyDeepMask\n") + + if (arg3) lparg3 = getRectFields(env, arg3, &_arg3); + if (arg4) lparg4 = getRectFields(env, arg4, &_arg4); + if (arg5) lparg5 = getRectFields(env, arg5, &_arg5); + CopyDeepMask((const BitMap *)arg0, (const BitMap *)arg1, (const BitMap *)arg2, (const Rect *)lparg3, (const Rect *)lparg4, (const Rect *)lparg5, (short)arg6, (RgnHandle)arg7); + if (arg3) setRectFields(env, arg3, lparg3); + if (arg4) setRectFields(env, arg4, lparg4); + if (arg5) setRectFields(env, arg5, lparg5); } +#endif /* NO_CopyDeepMask */ + +#ifndef NO_CopyMenuItemTextAsCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyMenuItemTextAsCFString + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_AEProcessAppleEvent(JNIEnv *env, jclass zz, - jintArray eventData) { - EventRecord event; - copyEventData(env, &event, eventData); - AEProcessAppleEvent(&event); + DEBUG_CALL("CopyMenuItemTextAsCFString\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)CopyMenuItemTextAsCFString((MenuRef)arg0, (MenuItemIndex)arg1, (CFStringRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_CopyMenuItemTextAsCFString */ + +#ifndef NO_CopyRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyRgn + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("CopyRgn\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_MenuEvent(JNIEnv *env, jclass zz, - jintArray eventData) { - EventRecord event; - copyEventData(env, &event, eventData); - return (jint) MenuEvent(&event); + CopyRgn((RgnHandle)arg0, (RgnHandle)arg1); } +#endif /* NO_CopyRgn */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PostEvent(JNIEnv *env, jclass zz, jshort kind, jint message) { - return RC(PostEvent(kind, message)); +#ifndef NO_CountMenuItems +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_CountMenuItems + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("CountMenuItems\n") + + return (jshort)CountMenuItems((MenuRef)arg0); } +#endif /* NO_CountMenuItems */ + +#ifndef NO_CountSubControls +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CountSubControls + (JNIEnv *env, jclass that, jint arg0, jshortArray arg1) +{ + jshort *lparg1=NULL; + jint rc; + + DEBUG_CALL("CountSubControls\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetKeyboardFocus(JNIEnv *env, jclass zz, jint wHandle, jintArray cHandle) { - jint *sa= (*env)->GetIntArrayElements(env, cHandle, 0); - int rc= RC(GetKeyboardFocus((WindowRef) wHandle, (ControlRef*) sa)); - (*env)->ReleaseIntArrayElements(env, cHandle, sa, 0); + if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); + rc = (jint)CountSubControls((ControlRef)arg0, (UInt16 *)lparg1); + if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0); return rc; } +#endif /* NO_CountSubControls */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AdvanceKeyboardFocus(JNIEnv *env, jclass zz, jint wHandle) { - return RC(AdvanceKeyboardFocus((WindowRef) wHandle)); +#ifndef NO_CreateBevelButtonControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateBevelButtonControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jshort arg3, jshort arg4, jint arg5, jshort arg6, jshort arg7, jshort arg8, jintArray arg9) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg9=NULL; + jint rc; + + DEBUG_CALL("CreateBevelButtonControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg9) lparg9 = (*env)->GetIntArrayElements(env, arg9, NULL); + rc = (jint)CreateBevelButtonControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (ControlBevelThickness)arg3, (ControlBevelButtonBehavior)arg4, (ControlButtonContentInfoPtr)arg5, (SInt16)arg6, (ControlBevelButtonMenuBehavior)arg7, (ControlBevelButtonMenuPlacement)arg8, (ControlRef *)lparg9); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg9) (*env)->ReleaseIntArrayElements(env, arg9, lparg9, 0); + return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetKeyboardFocus(JNIEnv *env, jclass zz, - jint wHandle, jint cHandle, jshort part) { - return (jint) RC(SetKeyboardFocus((WindowRef) wHandle, (ControlRef) cHandle, part)); +#ifndef NO_CreateCheckBoxControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateCheckBoxControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3, jboolean arg4, jintArray arg5) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("CreateCheckBoxControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)CreateCheckBoxControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (SInt32)arg3, (Boolean)arg4, (ControlRef *)lparg5); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif + +#ifndef NO_CreateCGContextForPort +JNIEXPORT jint JNICALL OS_NATIVE(CreateCGContextForPort) + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("CreateCGContextForPort\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentEventLoop(JNIEnv *env, jclass zz) { - return (jint) GetCurrentEventLoop(); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)CreateCGContextForPort((CGrafPtr)arg0, (CGContextRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsShowContextualMenuClick(JNIEnv *env, jclass zz, jintArray eventData) { - EventRecord event; - copyEventData(env, &event, eventData); - return (jboolean) IsShowContextualMenuClick(&event); +#ifndef NO_CreateDataBrowserControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateDataBrowserControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jintArray arg3) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("CreateDataBrowserControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)CreateDataBrowserControl((WindowRef)arg0, (const Rect *)lparg1, (DataBrowserViewStyle)arg2, (ControlRef *)lparg3); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_CreateDataBrowserControl */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ContextualMenuSelect(JNIEnv *env, jclass zz, - jint mHandle, jshortArray location, jshortArray menuId, jshortArray index) { - UInt32 outUserSelectionType; - jshort *sa= (*env)->GetShortArrayElements(env, menuId, 0); - jshort *sb= (*env)->GetShortArrayElements(env, index, 0); - jint status= RC(ContextualMenuSelect( - (MenuRef) mHandle, - point(env, location), - false, - 0, // kCMHelpItemOtherHelp, - 0, // "\pinHelpItemString", - NULL, - &outUserSelectionType, - (SInt16*) sa, - (MenuItemIndex*) sb)); - (*env)->ReleaseShortArrayElements(env, menuId, sa, 0); - (*env)->ReleaseShortArrayElements(env, index, sb, 0); - return status; +#ifndef NO_CreateEvent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateEvent + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jdouble arg3, jint arg4, jintArray arg5) +{ + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("CreateEvent\n") + + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)CreateEvent((CFAllocatorRef)arg0, (UInt32)arg1, (UInt32)arg2, (EventTime)arg3, (EventAttributes)arg4, (EventRef *)lparg5); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_CreateEvent */ + +#ifndef NO_CreateGroupBoxControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateGroupBoxControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jboolean arg3, jintArray arg4) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("CreateGroupBoxControl\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InstallEventLoopTimer(JNIEnv *env, jclass zz, - jint inEventLoop, jdouble inFireDelay, jdouble inInterval, jint inTimerProc, jint inTimerData, jintArray outTimer) { - jint *sa= (*env)->GetIntArrayElements(env, outTimer, 0); - int rc= RC(InstallEventLoopTimer((EventLoopRef) inEventLoop, (EventTimerInterval) inFireDelay, (EventTimerInterval) inInterval, - (EventLoopTimerUPP) inTimerProc, (void*) inTimerData, (EventLoopTimerRef*) sa)); - (*env)->ReleaseIntArrayElements(env, outTimer, sa, 0); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)CreateGroupBoxControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (Boolean)arg3, (ControlRef *)lparg4); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveEventLoopTimer(JNIEnv *env, jclass zz, jint timer) { - return RC(RemoveEventLoopTimer((EventLoopTimerRef) timer)); +#ifndef NO_CreateIconControl +JNIEXPORT jint JNICALL OS_NATIVE(CreateIconControl) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jobject arg2, jboolean arg3, jintArray arg4) +{ + Rect _arg1, *lparg1=NULL; + ControlButtonContentInfo _arg2, *lparg2=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("CreateIconControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = getControlButtonContentInfoFields(env, arg2, &_arg2); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)CreateIconControl((WindowRef)arg0, lparg1, lparg2, arg3, (ControlRef *)lparg4); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) setControlButtonContentInfoFields(env, arg2, lparg2); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif -JNIEXPORT jdouble JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetLastUserEventTime(JNIEnv *env, jclass zz) { - return GetLastUserEventTime(); +#ifndef NO_CreateNewMenu +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateNewMenu + (JNIEnv *env, jclass that, jshort arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("CreateNewMenu\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)CreateNewMenu((MenuID)arg0, (MenuAttributes)arg1, (MenuRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_CreateNewMenu */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ReceiveNextEvent(JNIEnv *env, jclass zz, - jintArray eventTypeSpecList, jdouble inTimeout, jboolean inPullEvent, jintArray outEvent) { - jint status; - jint *sa= NULL, *sb= NULL; - UInt32 inNumTypes= 0; - if (eventTypeSpecList != NULL) { - sa= (*env)->GetIntArrayElements(env, eventTypeSpecList, 0); - inNumTypes= (*env)->GetArrayLength(env, eventTypeSpecList)/2; - } - if (outEvent != NULL) - sb= (*env)->GetIntArrayElements(env, outEvent, 0); - status= (jint) RC(ReceiveNextEvent(inNumTypes, (const EventTypeSpec*) sa, inTimeout, inPullEvent, (EventRef*) sb)); - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, eventTypeSpecList, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, outEvent, sb, 0); - return status; +#ifndef NO_CreateNewWindow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateNewWindow + (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jintArray arg3) +{ + Rect _arg2, *lparg2=NULL; + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("CreateNewWindow\n") + + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)CreateNewWindow((WindowClass)arg0, (WindowAttributes)arg1, (const Rect *)lparg2, (WindowRef *)lparg3); + if (arg2) setRectFields(env, arg2, lparg2); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_CreateNewWindow */ + +#ifndef NO_CreatePopupArrowControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreatePopupArrowControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jshort arg2, jshort arg3, jintArray arg4) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("CreatePopupArrowControl\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventDispatcherTarget(JNIEnv *env, jclass zz) { - return (jint) GetEventDispatcherTarget(); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)CreatePopupArrowControl((WindowRef)arg0, (const Rect *)lparg1, (ControlPopupArrowOrientation)arg2, (ControlPopupArrowSize)arg3, (ControlRef *)lparg4); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SendEventToEventTarget(JNIEnv *env, jclass zz, jint eHandle, jint target) { - return (jint) RC(SendEventToEventTarget((EventRef)eHandle, (EventTargetRef) target)); +#ifndef NO_CreatePopupButtonControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreatePopupButtonControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jshort arg3, jboolean arg4, jshort arg5, jshort arg6, jint arg7, jintArray arg8) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg8=NULL; + jint rc; + + DEBUG_CALL("CreatePopupButtonControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL); + rc = (jint)CreatePopupButtonControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (SInt16)arg3, (Boolean)arg4, (SInt16)arg5, (SInt16)arg6, (Style)arg7, (ControlRef *)lparg8); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0); + return rc; } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ReleaseEvent(JNIEnv *env, jclass zz, jint eHandle) { - ReleaseEvent((EventRef)eHandle); +#ifndef NO_CreateProgressBarControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateProgressBarControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3, jint arg4, jboolean arg5, jintArray arg6) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg6=NULL; + jint rc; + + DEBUG_CALL("CreateProgressBarControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL); + rc = (jint)CreateProgressBarControl((WindowRef)arg0, (const Rect *)lparg1, (SInt32)arg2, (SInt32)arg3, (SInt32) arg4, (Boolean)arg5, (ControlRef *)lparg6); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0); + return rc; } +#endif NO_CreateProgressBarControl -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_ConvertEventRefToEventRecord(JNIEnv *env, jclass zz, jint eHandle, jintArray data) { - EventRecord event; - jboolean rc= ConvertEventRefToEventRecord((EventRef) eHandle, &event); - copyEvent(env, data, &event); +#ifndef NO_CreatePushButtonControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreatePushButtonControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jintArray arg3) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("CreatePushButtonControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)CreatePushButtonControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (ControlRef *)lparg3); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); return rc; } +#endif /* NO_CreatePushButtonControl */ + +#ifndef NO_CreatePushButtonWithIconControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreatePushButtonWithIconControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jobject arg3, jshort arg4, jintArray arg5) +{ + Rect _arg1, *lparg1=NULL; + ControlButtonContentInfo _arg3, *lparg3=NULL; + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("CreatePushButtonWithIconControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg3) lparg3 = getControlButtonContentInfoFields(env, arg3, &_arg3); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)CreatePushButtonWithIconControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (ControlButtonContentInfo *)lparg3, (ControlPushButtonIconAlignment)arg4, (ControlRef *)lparg5); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg3) setControlButtonContentInfoFields(env, arg3, lparg3); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; +} +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InstallStandardEventHandler(JNIEnv *env, jclass zz, jint target) { - return (jint) RC(InstallStandardEventHandler((EventTargetRef) target)); +#ifndef NO_CreateRadioButtonControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateRadioButtonControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3, jboolean arg4, jintArray arg5) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("CreateRadioButtonControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)CreateRadioButtonControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (SInt32)arg3, (Boolean)arg4, (ControlRef *)lparg5); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif + +#ifndef NO_CreateRootControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateRootControl + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowEventTarget(JNIEnv *env, jclass zz, jint wHandle) { - return (jint) GetWindowEventTarget((WindowRef) wHandle); + DEBUG_CALL("CreateRootControl\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)CreateRootControl((WindowRef)arg0, (ControlRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_CreateRootControl */ + +#ifndef NO_CreateScrollBarControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateScrollBarControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3, jint arg4, jint arg5, jboolean arg6, jint arg7, jintArray arg8) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg8=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventClass(JNIEnv *env, jclass zz, jint eHandle) { - return (jint) GetEventClass((EventRef) eHandle); + DEBUG_CALL("CreateScrollBarControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL); + rc = (jint)CreateScrollBarControl((WindowRef)arg0, (const Rect *)lparg1, (SInt32)arg2, (SInt32)arg3, (SInt32) arg4, (ControlSliderOrientation)arg5, (Boolean)arg6, (ControlActionUPP)arg7, (ControlRef *)lparg8); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0); + return rc; } +#endif NO_CreateScrollBarControl + +#ifndef NO_CreateSeparatorControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateSeparatorControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jintArray arg2) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg2=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventKind(JNIEnv *env, jclass zz, jint eHandle) { - return (jint) GetEventKind((EventRef) eHandle); + DEBUG_CALL("CreateSeparatorControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)CreateSeparatorControl((WindowRef)arg0, (const Rect *)lparg1, (ControlRef *)lparg2); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_CreateSeparatorControl */ -JNIEXPORT jdouble JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventTime(JNIEnv *env, jclass zz, jint eHandle) { - return (jdouble) GetEventTime((EventRef) eHandle); +#ifndef NO_CreateSliderControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateSliderControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3, jint arg4, jint arg5, short arg6, jboolean arg7, jint arg8, jintArray arg9) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg9=NULL; + jint rc; + + DEBUG_CALL("CreateSliderControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg9) lparg9 = (*env)->GetIntArrayElements(env, arg9, NULL); + rc = (jint)CreateSliderControl((WindowRef)arg0, (const Rect *)lparg1, (SInt32)arg2, (SInt32)arg3, (SInt32) arg4, (ControlSliderOrientation)arg5, (UInt16)arg6, (Boolean)arg7, (ControlActionUPP)arg8, (ControlRef *)lparg9); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg9) (*env)->ReleaseIntArrayElements(env, arg9, lparg9, 0); + return rc; } +#endif NO_CreateSliderControl -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMouseLocation(JNIEnv *env, jclass zz, jint eHandle, jshortArray loc) { - jshort *sa= (*env)->GetShortArrayElements(env, loc, 0); - jint status= RC(GetEventParameter((EventRef) eHandle, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, (Point*)sa)); - (*env)->ReleaseShortArrayElements(env, loc, sa, 0); - return status; +#ifndef NO_CreateStandardAlert +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateStandardAlert + (JNIEnv *env, jclass that, jshort arg0, jint arg1, jint arg2, jobject arg3, jintArray arg4) +{ + AlertStdCFStringAlertParamRec _arg3, *lparg3=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("CreateStandardAlert\n") + + if (arg3) lparg3 = getAlertStdCFStringAlertParamRecFields(env, arg3, &_arg3); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)CreateStandardAlert((AlertType)arg0, (CFStringRef)arg1, (CFStringRef)arg2, (const AlertStdCFStringAlertParamRec *)lparg3, (DialogRef *)lparg4); + if (arg3) setAlertStdCFStringAlertParamRecFields(env, arg3, lparg3); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TrackMouseLocation(JNIEnv *env, jclass zz, - jint portHandle, jshortArray loc, jshortArray part) { - jshort *sa= (*env)->GetShortArrayElements(env, loc, 0); - jshort *sb= (*env)->GetShortArrayElements(env, part, 0); - jint status= RC(TrackMouseLocation((GrafPtr) portHandle, (Point*) sa, sb)); - (*env)->ReleaseShortArrayElements(env, loc, sa, 0); - (*env)->ReleaseShortArrayElements(env, part, sb, 0); - return status; +#ifndef NO_CreateStaticTextControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateStaticTextControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jobject arg3, jintArray arg4) +{ + Rect _arg1, *lparg1=NULL; + ControlFontStyleRec _arg3, *lparg3=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("CreateStaticTextControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg3) lparg3 = getControlFontStyleRecFields(env, arg3, &_arg3); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)CreateStaticTextControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (const ControlFontStyleRec *)lparg3, (ControlRef *)lparg4); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg3) setControlFontStyleRecFields(env, arg3, lparg3); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_CreateStaticTextControl */ + +#ifndef NO_CreateTabsControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateTabsControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jshort arg2, jshort arg3, jshort arg4, jint arg5, jintArray arg6) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg6=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetGlobalMouse(JNIEnv *env, jclass zz, jshortArray where) { - jshort *sa= (*env)->GetShortArrayElements(env, where, 0); - GetGlobalMouse((Point*)sa); - (*env)->ReleaseShortArrayElements(env, where, sa, 0); + DEBUG_CALL("CreateTabsControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL); + rc = (jint)CreateTabsControl((WindowRef)arg0, (const Rect *)lparg1, (ControlTabSize)arg2, (ControlTabDirection)arg3, (UInt16)arg4, (const ControlTabEntry *)arg5, (ControlRef *)lparg6); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0); + return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateEvent(JNIEnv *env, jclass zz, - jint allocator, jint classID, jint kind, jdouble when, jint flags, jintArray eventRef) { - jint *sa= (*env)->GetIntArrayElements(env, eventRef, 0); - jint status= RC(CreateEvent((CFAllocatorRef)allocator, classID, kind, (EventTime)when, (EventAttributes)flags, (EventRef*) sa)); - (*env)->ReleaseIntArrayElements(env, eventRef, sa, 0); - return status; +#ifndef NO_CreateEditUnicodeTextControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateEditUnicodeTextControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jboolean arg3, jobject arg4, jintArray arg5) +{ + Rect _arg1, *lparg1=NULL; + ControlFontStyleRec _arg4, *lparg4=NULL; + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("CreateEditUnicodeTextControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg4) lparg4 = getControlFontStyleRecFields(env, arg4, &_arg4); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)CreateEditUnicodeTextControl((WindowRef)arg0, (const Rect *)lparg1, (CFStringRef)arg2, (Boolean) arg3, (const ControlFontStyleRec *)lparg4, (ControlRef *)lparg5); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg4) setControlFontStyleRecFields(env, arg4, lparg4); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_CreateEditUnicodeTextControl */ + +#ifndef NO_CreateUserPaneControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateUserPaneControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jintArray arg3) +{ + Rect _arg1, *lparg1=NULL; + jint *lparg3=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PostEventToQueue(JNIEnv *env, jclass zz, - jint queue, jint event, jshort priority) { - return RC(PostEventToQueue((EventQueueRef)queue, (EventRef)event, (EventPriority) priority)); + DEBUG_CALL("CreateUserPaneControl\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)CreateUserPaneControl((WindowRef)arg0, (const Rect *)lparg1, (UInt32)arg2, (ControlRef *)lparg3); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_CreateUserPaneControl */ + +#ifndef NO_CreateWindowGroup +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateWindowGroup + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMainEventQueue(JNIEnv *env, jclass zz) { - return (jint) GetMainEventQueue(); + DEBUG_CALL("CreateWindowGroup\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)CreateWindowGroup((WindowGroupAttributes)arg0, (WindowGroupRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif -//---- Cursors +#ifndef NO_DeleteMenu +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DeleteMenu + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("DeleteMenu\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCursor(JNIEnv *env, jclass zz, - jshort id) { - return (jint) GetCursor(id); + DeleteMenu((MenuID)arg0); } +#endif /* NO_DeleteMenu */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewCursor(JNIEnv *env, jclass zz, - jshort hotX, jshort hotY, jshortArray data, jshortArray mask) { - - jshort *sa= (*env)->GetShortArrayElements(env, data, 0); - jshort *sb= (*env)->GetShortArrayElements(env, mask, 0); +#ifndef NO_DeleteMenuItem +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DeleteMenuItem + (JNIEnv *env, jclass that, jint arg0, jshort arg1) +{ + DEBUG_CALL("DeleteMenuItem\n") - Cursor *c= (Cursor*) NewPtrClear(sizeof(Cursor)); - memcpy(&c->data, sa, sizeof (Bits16)); - memcpy(&c->mask, sb, sizeof (Bits16)); - c->hotSpot.h= hotX; - c->hotSpot.v= hotY; + DeleteMenuItem((MenuRef)arg0, (short)arg1); +} +#endif /* NO_DeleteMenuItem */ - (*env)->ReleaseShortArrayElements(env, data, sa, 0); - (*env)->ReleaseShortArrayElements(env, mask, sb, 0); - - return (jint) c; +#ifndef NO_DeleteMenuItems +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DeleteMenuItems + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2) +{ + DEBUG_CALL("DeleteMenuItems\n") + + return (jint)DeleteMenuItems((MenuRef)arg0, (MenuItemIndex)arg1, (ItemCount)arg2); } +#endif /* NO_DeleteMenuItems */ + +#ifndef NO_DiffRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DiffRgn + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("DiffRgn\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetCursor(JNIEnv *env, jclass zz, jint cursor) { - SetCursor((const Cursor*)cursor); + DiffRgn((RgnHandle)arg0, (RgnHandle)arg1, (RgnHandle)arg2); } +#endif /* NO_DiffRgn */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeCursor(JNIEnv *env, jclass zz, jint cursor) { - return (jint) SetThemeCursor((ThemeCursor)cursor); +#ifndef NO_DisableControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisableControl + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisableControl\n") + + return (jint)DisableControl((ControlRef)arg0); } +#endif /* NO_DisableControl */ -//---- GrafPort +#ifndef NO_DisableMenuCommand +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisableMenuCommand + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("DisableMenuCommand\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetQDGlobalsScreenBits(JNIEnv *env, jclass zz, - jint bitmap) { - return (jint) GetQDGlobalsScreenBits((BitMap*)bitmap); + DisableMenuCommand((MenuRef)arg0, (MenuCommand)arg1); } +#endif /* NO_DisableMenuCommand */ + +#ifndef NO_DisableMenuItem +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisableMenuItem + (JNIEnv *env, jclass that, jint arg0, jshort arg1) +{ + DEBUG_CALL("DisableMenuItem\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDSwapTextFlags(JNIEnv *env, jclass zz, jint flags) { - return (jint) SwapQDTextFlags(flags); + DisableMenuItem((MenuRef)arg0, (MenuItemIndex)arg1); } +#endif /* NO_DisableMenuItem */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDSetPatternOrigin(JNIEnv *env, jclass zz, - jshortArray o) { - QDSetPatternOrigin(point(env, o)); +#ifndef NO_DisposeControl +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeControl + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisposeControl\n") + + DisposeControl((ControlRef)arg0); } +#endif /* NO_DisposeControl */ + +#ifndef NO_DisposeGWorld +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeGWorld + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisposeGWorld\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPort(JNIEnv *env, jclass zz) { - GrafPtr p; - GetPort(&p); - return (jint) p; + DisposeGWorld((GWorldPtr)arg0); } +#endif /* NO_DisposeGWorld */ + +#ifndef NO_DisposeHandle +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeHandle + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisposeHandle\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetPort(JNIEnv *env, jclass zz, - jint portHandle) { - SetPort((GrafPtr) portHandle); + DisposeHandle((Handle)arg0); } +#endif /* NO_DisposeHandle */ -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsValidPort(JNIEnv *env, jclass zz, - jint portHandle) { - return (jboolean) IsValidPort((CGrafPtr)portHandle); +#ifndef NO_DisposeMenu +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeMenu + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisposeMenu\n") + + DisposeMenu((MenuRef)arg0); } +#endif /* NO_DisposeMenu */ + +#ifndef NO_DisposePtr +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposePtr + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisposePtr\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetPortWindowPort(JNIEnv *env, jclass zz, jint wHandle) { - SetPortWindowPort((WindowRef) wHandle); + DisposePtr((Ptr)arg0); } +#endif /* NO_DisposePtr */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortBounds(JNIEnv *env, jclass zz, - jint port, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - GetPortBounds((CGrafPtr) port, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); +#ifndef NO_DisposeRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeRgn + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisposeRgn\n") + + DisposeRgn((RgnHandle)arg0); } +#endif /* NO_DisposeRgn */ + +#ifndef NO_DisposeWindow +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeWindow + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("DisposeWindow\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EraseRect(JNIEnv *env, jclass zz, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - EraseRect((Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + DisposeWindow((WindowRef)arg0); } +#endif /* NO_DisposeWindow */ + +#ifndef NO_DrawMenuBar +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawMenuBar + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("DrawMenuBar\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrameRect(JNIEnv *env, jclass zz, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - FrameRect((Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + DrawMenuBar(); } +#endif /* NO_DrawMenuBar */ + +#ifndef NO_DrawText +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawText + (JNIEnv *env, jclass that, jbyteArray arg0, jshort arg1, jshort arg2) +{ + jbyte *lparg0=NULL; + + DEBUG_CALL("DrawText\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintRect(JNIEnv *env, jclass zz, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - PaintRect((Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); + DrawText((const void *)lparg0, (short)arg1, (short)arg2); + if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); } +#endif /* NO_DrawText */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrameOval(JNIEnv *env, jclass zz, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - FrameOval((Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); +#ifndef NO_DrawThemeButton +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeButton + (JNIEnv *env, jclass that, jobject arg0, jshort arg1, jobject arg2, jobject arg3, jint arg4, jint arg5, jint arg6) +{ + Rect _arg0, *lparg0=NULL; + ThemeButtonDrawInfo _arg2, *lparg2=NULL; + ThemeButtonDrawInfo _arg3, *lparg3=NULL; + jint rc; + + DEBUG_CALL("DrawThemeButton\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + if (arg2) lparg2 = getThemeButtonDrawInfoFields(env, arg2, &_arg2); + if (arg3) lparg3 = getThemeButtonDrawInfoFields(env, arg3, &_arg3); + rc = (jint)DrawThemeButton((Rect *)lparg0, (ThemeButtonKind)arg1, (const ThemeButtonDrawInfo *)lparg2, (const ThemeButtonDrawInfo *)lparg3, (ThemeEraseUPP)arg4, (ThemeButtonDrawUPP)arg5, (UInt32)arg6); + if (arg0) setRectFields(env, arg0, lparg0); + if (arg2) setThemeButtonDrawInfoFields(env, arg2, lparg2); + if (arg3) setThemeButtonDrawInfoFields(env, arg3, lparg3); + return rc; } +#endif /* NO_DrawThemeButton */ + +#ifndef NO_DrawThemeEditTextFrame +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeEditTextFrame + (JNIEnv *env, jclass that, jobject arg0, jint arg1) +{ + Rect _arg0, *lparg0=NULL; + jint rc; + + DEBUG_CALL("DrawThemeEditTextFrame\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintOval(JNIEnv *env, jclass zz, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - PaintOval((Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + rc = (jint)DrawThemeEditTextFrame((const Rect *)lparg0, (ThemeDrawState)arg1); + if (arg0) setRectFields(env, arg0, lparg0); + return rc; } +#endif /* NO_DrawThemeEditTextFrame */ + +#ifndef NO_DrawThemeFocusRect +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeFocusRect + (JNIEnv *env, jclass that, jobject arg0, jboolean arg1) +{ + Rect _arg0, *lparg0=NULL; + jint rc; + + DEBUG_CALL("DrawThemeFocusRect\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrameRoundRect(JNIEnv *env, jclass zz, - jshortArray bounds, jshort ovalWidth, jshort ovalHeight) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - FrameRoundRect((Rect*) sa, ovalWidth, ovalHeight); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + rc = (jint)DrawThemeFocusRect((const Rect *)lparg0, (Boolean)arg1); + if (arg0) setRectFields(env, arg0, lparg0); + return rc; } +#endif /* NO_DrawThemeFocusRect */ + +#ifndef NO_DrawThemeSeparator +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeSeparator + (JNIEnv *env, jclass that, jobject arg0, jint arg1) +{ + Rect _arg0, *lparg0=NULL; + jint rc; + + DEBUG_CALL("DrawThemeSeparator\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintRoundRect(JNIEnv *env, jclass zz, - jshortArray bounds, jshort ovalWidth, jshort ovalHeight) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - PaintRoundRect((Rect*) sa, ovalWidth, ovalHeight); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + rc = (jint)DrawThemeSeparator((const Rect *)lparg0, (ThemeDrawState)arg1); + if (arg0) setRectFields(env, arg0, lparg0); + return rc; } +#endif /* NO_DrawThemeSeparator */ + +#ifndef NO_DrawThemeTextBox +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawThemeTextBox + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jboolean arg3, jobject arg4, jshort arg5, jint arg6) +{ + Rect _arg4, *lparg4=NULL; + jint rc; + + DEBUG_CALL("DrawThemeTextBox\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_NormalizeThemeDrawingState(JNIEnv *env, jclass zz) { - NormalizeThemeDrawingState(); + if (arg4) lparg4 = getRectFields(env, arg4, &_arg4); + rc = (jint)DrawThemeTextBox((CFStringRef)arg0, (ThemeFontID)arg1, (ThemeDrawState)arg2, (Boolean)arg3, (const Rect *)lparg4, (SInt16)arg5, (void *)arg6); + if (arg4) setRectFields(env, arg4, lparg4); + return rc; } +#endif /* NO_DrawThemeTextBox */ + +#ifndef NO_EmbedControl +JNIEXPORT jint JNICALL OS_NATIVE(EmbedControl) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("EmbedControl\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextFont(JNIEnv *env, jclass zz, jshort fontID) { - TextFont(fontID); + return (jint)EmbedControl((ControlRef)arg0, (ControlRef)arg1); } +#endif + +#ifndef NO_EmptyRect +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_EmptyRect + (JNIEnv *env, jclass that, jobject arg0) +{ + Rect _arg0, *lparg0=NULL; + jboolean rc; + + DEBUG_CALL("EmptyRect\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextSize(JNIEnv *env, jclass zz, jshort size) { - TextSize(size); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + rc = (jboolean)EmptyRect((const Rect *)lparg0); + if (arg0) setRectFields(env, arg0, lparg0); + return rc; } +#endif /* NO_EmptyRect */ + +#ifndef NO_EmptyRgn +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_EmptyRgn + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("EmptyRgn\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextFace(JNIEnv *env, jclass zz, jshort face) { - TextFace(face); + return (jboolean)EmptyRgn((RgnHandle)arg0); } +#endif /* NO_EmptyRgn */ + +#ifndef NO_EnableControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_EnableControl + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("EnableControl\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextMode(JNIEnv *env, jclass zz, jshort mode) { - TextMode(mode); + return (jint)EnableControl((ControlRef)arg0); } +#endif /* NO_EnableControl */ -#ifdef USE_ATSUI +#ifndef NO_EnableMenuCommand +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EnableMenuCommand + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("EnableMenuCommand\n") -static ATSUTextLayout fgTextLayout; -static ATSUStyle fgStyle; -static int fgTextLayoutInitialized; -static ATSUAttributeTag fgATSUAttributeTag[4]; -static ByteCount fgByteCount[4]; -static ATSUAttributeValuePtr fgATSUAttributeValuePtr[4]; + EnableMenuCommand((MenuRef)arg0, (MenuCommand)arg1); +} +#endif /* NO_EnableMenuCommand */ -static void initATSUI(ATSUFontID font, short size, short face) { - ATSUFontID f= 0; - Fixed s= size << 16; - Boolean isBold= false; - Boolean isItalic= false; - int n= 3; - - if ((face & bold) != 0) - isBold= true; - if ((face & italic) != 0) - isItalic= true; - - if (ATSUFONDtoFontID(font, (Style) normal, &f) != 0) - fprintf(stderr, "ATSUFONDtoFontID: error\n"); - else if (f != 0) - n++; - - if (fgTextLayoutInitialized == 0) { - if (ATSUCreateTextLayout(&fgTextLayout) != 0) - - if (ATSUSetTransientFontMatching(fgTextLayout, true) != 0) - fprintf(stderr, "ATSUSetTransientFontMatching1: error\n"); - - if (ATSUCreateStyle(&fgStyle) != 0) - fprintf(stderr, "ATSUCreateStyle: error\n"); - - fgATSUAttributeTag[0]= kATSUSizeTag; - fgATSUAttributeTag[1]= kATSUQDBoldfaceTag; - fgATSUAttributeTag[2]= kATSUQDItalicTag; - fgATSUAttributeTag[3]= kATSUFontTag; - - fgByteCount[0]= sizeof(Fixed); - fgByteCount[1]= sizeof(Boolean); - fgByteCount[2]= sizeof(Boolean); - fgByteCount[3]= sizeof(ATSUFontID); - - fgTextLayoutInitialized= 1; - } else { - if (ATSUSetTransientFontMatching(fgTextLayout, true) != 0) - fprintf(stderr, "ATSUSetTransientFontMatching2: error\n"); - } - - fgATSUAttributeValuePtr[0]= &s; - fgATSUAttributeValuePtr[1]= &isBold; - fgATSUAttributeValuePtr[2]= &isItalic; - fgATSUAttributeValuePtr[3]= &f; - - if (ATSUSetAttributes(fgStyle, n, fgATSUAttributeTag, fgByteCount, fgATSUAttributeValuePtr) != 0) - fprintf(stderr, "ATSUSetAttributes: error\n"); +#ifndef NO_EnableMenuItem +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EnableMenuItem + (JNIEnv *env, jclass that, jint arg0, jshort arg1) +{ + DEBUG_CALL("EnableMenuItem\n") + + EnableMenuItem((MenuRef)arg0, (MenuItemIndex)arg1); } -#endif +#endif /* NO_EnableMenuItem */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawText(JNIEnv *env, jclass zz, - jstring s, jshort font, jshort size, jshort face) { -#ifdef USE_ATSUI - - if (s != NULL) { - const jchar *ss= (*env)->GetStringChars(env, s, NULL); - int l= (*env)->GetStringLength(env, s); - - initATSUI(font, size, face); - - if (ATSUSetTextPointerLocation(fgTextLayout, (ConstUniCharArrayPtr)ss, kATSUFromTextBeginning, kATSUToTextEnd, l) != 0) - fprintf(stderr, "ATSUSetTextPointerLocation: error\n"); - - if (ATSUSetRunStyle(fgTextLayout, fgStyle, (UniCharArrayOffset) 0, (UniCharCount) l) != 0) - fprintf(stderr, "ATSUSetRunStyle: error\n"); +#ifndef NO_EndUpdate +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EndUpdate + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("EndUpdate\n") + + EndUpdate((WindowRef)arg0); +} +#endif /* NO_EndUpdate */ + +#ifndef NO_EqualRect +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_EqualRect + (JNIEnv *env, jclass that, jobject arg0, jobject arg1) +{ + Rect _arg0, *lparg0=NULL; + Rect _arg1, *lparg1=NULL; + jboolean rc; + + DEBUG_CALL("EqualRect\n") - if (ATSUDrawText(fgTextLayout, kATSUFromTextBeginning, kATSUToTextEnd , kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc) != 0) - fprintf(stderr, "ATSUDrawText: error\n"); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + rc = (jboolean)EqualRect((const Rect *)lparg0, (const Rect *)lparg1); + if (arg0) setRectFields(env, arg0, lparg0); + if (arg1) setRectFields(env, arg1, lparg1); + return rc; +} +#endif /* NO_EqualRect */ + +#ifndef NO_EraseRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EraseRect + (JNIEnv *env, jclass that, jobject arg0) +{ + Rect _arg0, *lparg0=NULL; + + DEBUG_CALL("EraseRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + EraseRect((const Rect *)lparg0); + if (arg0) setRectFields(env, arg0, lparg0); +} +#endif /* NO_EraseRect */ - (*env)->ReleaseStringChars(env, s, ss); - } -#else +#ifndef NO_EraseRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EraseRgn + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("EraseRgn\n") - const char *ss= (*env)->GetStringUTFChars(env, s, NULL); - DrawText(ss, 0, (short)strlen(ss)); - (*env)->ReleaseStringUTFChars(env, s, ss); + EraseRgn((RgnHandle)arg0); +} +#endif /* NO_EraseRgn */ + +#ifndef NO_FPIsFontPanelVisible +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_FPIsFontPanelVisible + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("FPIsFontPanelVisible\n") + + return (jboolean)FPIsFontPanelVisible(); +} #endif + +#ifndef NO_FetchFontInfo +JNIEXPORT jint JNICALL OS_NATIVE(FetchFontInfo) + (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jshort arg2, jobject arg3) +{ + FontInfo _arg3, *lparg3=NULL; + jint rc; + + DEBUG_CALL("FetchFontInfo\n") + + if (arg3) lparg3 = getFontInfoFields(env, arg3, &_arg3); + rc = (jint)FetchFontInfo(arg0, arg1, arg2, lparg3); + if (arg3) setFontInfoFields(env, arg3, lparg3); + return rc; } +#endif -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextWidth(JNIEnv *env, jclass zz, - jstring s, jshort font, jshort size, jshort face) { - jshort width= 0; +#ifndef NO_Fix2Long +JNIEXPORT jint JNICALL OS_NATIVE(Fix2Long) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("Fix2Long\n") -#ifdef USE_ATSUI - if (s != NULL) { - ATSTrapezoid trap; - ItemCount n; - const jchar *ss= (*env)->GetStringChars(env, s, NULL); - int l= (*env)->GetStringLength(env, s); - - initATSUI(font, size, face); + return (jint)Fix2Long((Fixed)arg0); +} +#endif NO_Fix2Long - if (ATSUSetTextPointerLocation(fgTextLayout, (ConstUniCharArrayPtr)ss, kATSUFromTextBeginning, kATSUToTextEnd, l) != 0) - fprintf(stderr, "ATSUSetTextPointerLocation: error\n"); - - if (ATSUSetRunStyle(fgTextLayout, fgStyle, (UniCharArrayOffset) 0, (UniCharCount) l) != 0) - fprintf(stderr, "ATSUSetRunStyle: error\n"); - - if (ATSUGetGlyphBounds(fgTextLayout, (ATSUTextMeasurement)0, (ATSUTextMeasurement)0, - kATSUFromTextBeginning, kATSUToTextEnd, kATSUseDeviceOrigins, 1, &trap, &n) != 0) - fprintf(stderr, "ATSUGetGlyphBounds: error\n"); - - (*env)->ReleaseStringChars(env, s, ss); +#ifndef NO_FMCreateFontFamilyIterator +JNIEXPORT jint JNICALL OS_NATIVE(FMCreateFontFamilyIterator) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + DEBUG_CALL("FMCreateFontFamilyIterator\n") - width= HiWord(trap.lowerRight.x); - } -#else - const char *ss= (*env)->GetStringUTFChars(env, s, NULL); - width= TextWidth(ss, 0, (short)strlen(ss)); - (*env)->ReleaseStringUTFChars(env, s, ss); + return (jint)FMCreateFontFamilyIterator((const FMFilter *)arg0, (void *)arg1, (OptionBits)arg2, (FMFontFamilyIterator *)arg3); +} #endif - return width; + +#ifndef NO_FMCreateFontFamilyInstanceIterator +JNIEXPORT jint JNICALL OS_NATIVE(FMCreateFontFamilyInstanceIterator) + (JNIEnv *env, jclass that, jshort arg0, jint arg1) +{ + DEBUG_CALL("FMCreateFontFamilyInstanceIterator\n") + + return (jint)FMCreateFontFamilyInstanceIterator((FMFontFamily)arg0, (FMFontFamilyInstanceIterator *)arg1); } +#endif -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_CharWidth(JNIEnv *env, jclass zz, jbyte c) { - return (jshort) CharWidth(c); +#ifndef NO_FMDisposeFontFamilyIterator +JNIEXPORT jint JNICALL OS_NATIVE(FMDisposeFontFamilyIterator) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("FMDisposeFontFamilyIterator\n") + + return (jint)FMDisposeFontFamilyIterator((FMFontFamilyIterator *)arg0); } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetFontInfo(JNIEnv *env, jclass zz, jshortArray info) { - jshort *sa= (*env)->GetShortArrayElements(env, info, 0); - GetFontInfo((FontInfo*) sa); - (*env)->ReleaseShortArrayElements(env, info, sa, 0); +#ifndef NO_FMDisposeFontFamilyInstanceIterator +JNIEXPORT jint JNICALL OS_NATIVE(FMDisposeFontFamilyInstanceIterator) + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("FMDisposeFontFamilyInstanceIterator\n") + + return (jint)FMDisposeFontFamilyInstanceIterator((FMFontFamilyInstanceIterator *)arg0); } +#endif + +#ifndef NO_FMGetFontFamilyFromName +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_FMGetFontFamilyFromName + (JNIEnv *env, jclass that, jbyteArray arg0) +{ + jbyte *lparg0=NULL; + jshort rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetFractEnable(JNIEnv *env, jclass zz, jboolean enable) { - SetFractEnable(enable); + DEBUG_CALL("FMGetFontFamilyFromName\n") + + if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); + rc = (jshort)FMGetFontFamilyFromName((ConstStr255Param)lparg0); + if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + return rc; } +#endif /* NO_FMGetFontFamilyFromName */ + +#ifndef NO_FMGetFontFamilyName +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FMGetFontFamilyName + (JNIEnv *env, jclass that, jshort arg0, jbyteArray arg1) +{ + jbyte *lparg1=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PenSize(JNIEnv *env, jclass zz, jshort h, jshort v) { - PenSize(h, v); + DEBUG_CALL("FMGetFontFamilyName\n") + + if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL); + rc = (jint)FMGetFontFamilyName(arg0, lparg1); + if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_FMGetFontFamilyName */ + +#ifndef NO_FMGetFontFromFontFamilyInstance +JNIEXPORT jint JNICALL OS_NATIVE(FMGetFontFromFontFamilyInstance) + (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jintArray arg2, jshortArray arg3) +{ + jint *lparg2=NULL; + jshort *lparg3=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_MoveTo(JNIEnv *env, jclass zz, jshort h, jshort v) { - MoveTo(h, v); + DEBUG_CALL("FMGetFontFromFontFamilyInstance\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL); + rc = (jint)FMGetFontFromFontFamilyInstance((FMFontFamily)arg0, (FMFontStyle)arg1, (FMFont *)lparg2, (FMFontStyle *)lparg3); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif + +#ifndef NO_FMGetNextFontFamily +JNIEXPORT jint JNICALL OS_NATIVE(FMGetNextFontFamily) + (JNIEnv *env, jclass that, jint arg0, jshortArray arg1) +{ + jshort *lparg1=NULL; + jint rc; + + DEBUG_CALL("FMGetNextFontFamily\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_LineTo(JNIEnv *env, jclass zz, jshort h, jshort v) { - LineTo(h, v); + if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); + rc = (jint)FMGetNextFontFamily((FMFontFamilyIterator *)arg0, (FMFontFamily *)lparg1); + if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClipRect(JNIEnv *env, jclass zz, jshortArray clip) { - jshort *sa= (*env)->GetShortArrayElements(env, clip, 0); - ClipRect((Rect*) sa); - (*env)->ReleaseShortArrayElements(env, clip, sa, 0); +#ifndef NO_FMGetNextFontFamilyInstance +JNIEXPORT jint JNICALL OS_NATIVE(FMGetNextFontFamilyInstance) + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jshortArray arg2, jshortArray arg3) +{ + jint *lparg1=NULL; + jshort *lparg2=NULL; + jshort *lparg3=NULL; + jint rc; + + DEBUG_CALL("FMGetNextFontFamilyInstance\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL); + rc = (jint)FMGetNextFontFamilyInstance((FMFontFamilyInstanceIterator *)arg0, (FMFont *)lparg1, (FMFontStyle *)lparg2, (FMFontSize *)lparg3); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif + +#ifndef NO_FPShowHideFontPanel +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FPShowHideFontPanel + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("FPShowHideFontPanel\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ScrollRect(JNIEnv *env, jclass zz, jshortArray r, jshort dh, jshort dv, jint rgn) { - jshort *sa= (*env)->GetShortArrayElements(env, r, 0); - ScrollRect((Rect*) sa, dh, dv, (RgnHandle) rgn); - (*env)->ReleaseShortArrayElements(env, r, sa, 0); + return (jint)FPShowHideFontPanel(); } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDFlushPortBuffer(JNIEnv *env, jclass zz, jint port, jint rgnHandle) { - QDFlushPortBuffer((GrafPtr) port, (RgnHandle) rgnHandle); +#ifndef NO_FindWindow +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_FindWindow + (JNIEnv *env, jclass that, jobject arg0, jintArray arg1) +{ + Point _arg0, *lparg0=NULL; + jint *lparg1=NULL; + jshort rc; + + DEBUG_CALL("FindWindow\n") + + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jshort)FindWindow((Point)*lparg0, (WindowRef *)lparg1); + if (arg0) setPointFields(env, arg0, lparg0); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_FindWindow */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortVisibleRegion(JNIEnv *env, jclass zz, jint pHandle, - jint rgnHandle) { - return (jint) GetPortVisibleRegion((CGrafPtr) pHandle, (RgnHandle) rgnHandle); +#ifndef NO_FrameOval +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrameOval + (JNIEnv *env, jclass that, jobject arg0) +{ + Rect _arg0, *lparg0=NULL; + + DEBUG_CALL("FrameOval\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + FrameOval((const Rect *)lparg0); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_FrameOval */ + +#ifndef NO_FramePoly +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FramePoly + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("FramePoly\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetPortVisibleRegion(JNIEnv *env, jclass zz, jint pHandle, - jint rgnHandle) { - SetPortVisibleRegion((CGrafPtr) pHandle, (RgnHandle) rgnHandle); + FramePoly((PolyHandle)arg0); } +#endif /* NO_FramePoly */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDGetDirtyRegion(JNIEnv *env, jclass zz, jint pHandle, - jint rgnHandle) { - return (jint) RC(QDGetDirtyRegion((CGrafPtr) pHandle, (RgnHandle) rgnHandle)); +#ifndef NO_FrameRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrameRect + (JNIEnv *env, jclass that, jobject arg0) +{ + Rect _arg0, *lparg0=NULL; + + DEBUG_CALL("FrameRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + FrameRect((const Rect *)lparg0); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_FrameRect */ + +#ifndef NO_FrameRoundRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrameRoundRect + (JNIEnv *env, jclass that, jobject arg0, jshort arg1, jshort arg2) +{ + Rect _arg0, *lparg0=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDSetDirtyRegion(JNIEnv *env, jclass zz, jint pHandle, - jint rgnHandle) { - return (jint) RC(QDSetDirtyRegion((CGrafPtr) pHandle, (RgnHandle) rgnHandle)); + DEBUG_CALL("FrameRoundRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + FrameRoundRect((const Rect *)lparg0, (short)arg1, (short)arg2); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_FrameRoundRect */ + +#ifndef NO_FrontWindow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrontWindow + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("FrontWindow\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_LockPortBits(JNIEnv *env, jclass zz, jint pHandle) { - return (jint) RC(LockPortBits((GrafPtr) pHandle)); + return (jint)FrontWindow(); } +#endif /* NO_FrontWindow */ + +#ifndef NO_GetAppFont +JNIEXPORT jshort JNICALL OS_NATIVE(GetAppFont) + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetAppFont\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_UnlockPortBits(JNIEnv *env, jclass zz, jint pHandle) { - return (jint) RC(UnlockPortBits((GrafPtr) pHandle)); + return (jshort)GetAppFont(); } +#endif + +#ifndef NO_GetApplicationEventTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetApplicationEventTarget + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetApplicationEventTarget\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_RGBForeColor(JNIEnv *enc, jclass zz, jshort red, jshort green, jshort blue) { - struct RGBColor c; - c.red= red; - c.green= green; - c.blue= blue; - RGBForeColor(&c); + return (jint)GetApplicationEventTarget(); } +#endif /* NO_GetApplicationEventTarget */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_RGBBackColor(JNIEnv *enc, jclass zz, jshort red, jshort green, jshort blue) { - struct RGBColor c; - c.red= red; - c.green= green; - c.blue= blue; - RGBBackColor(&c); +#ifndef NO_GetAvailableWindowAttributes +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetAvailableWindowAttributes + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetAvailableWindowAttributes\n") + + return (jint)GetAvailableWindowAttributes((WindowClass)arg0); } +#endif /* NO_GetAvailableWindowAttributes */ + +#ifndef NO_GetAvailableWindowPositioningBounds +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetAvailableWindowPositioningBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetAvailableWindowPositioningBounds\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowFromPort(JNIEnv *env, jclass zz, jint pHandle) { - return (jint) GetWindowFromPort((GrafPtr)pHandle); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + rc = (jint)GetAvailableWindowPositioningBounds((GDHandle)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); + return rc; } +#endif /* NO_GetAvailableWindowPositioningBounds */ + +#ifndef NO_GetBestControlRect +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetBestControlRect + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jshortArray arg2) +{ + Rect _arg1, *lparg1=NULL; + jshort *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetBestControlRect\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvertRect(JNIEnv *env, jclass zz, jshort x, jshort y, jshort w, jshort h) { - Rect r; - SetRect(&r, x, y, x+w, y+h); - InvertRect(&r); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL); + rc = (jint)GetBestControlRect((ControlRef)arg0, (Rect *)lparg1, (SInt16 *)lparg2); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetBestControlRect */ -//---- Regions +#ifndef NO_GetCaretTime +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCaretTime + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetCaretTime\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewRgn(JNIEnv *env, jclass zz) { - return (jint) NewRgn(); + return (jint)GetCaretTime(); } +#endif /* NO_GetCaretTime */ + +#ifndef NO_GetClip +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetClip + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetClip\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetEmptyRgn(JNIEnv *env, jclass zz, jint rgnHandle) { - SetEmptyRgn((RgnHandle)rgnHandle); + GetClip((RgnHandle)arg0); } +#endif /* NO_GetClip */ + +#ifndef NO_GetControl32BitMaximum +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControl32BitMaximum + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControl32BitMaximum\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_RectRgn(JNIEnv *env, jclass zz, jint rgnHandle, jshortArray rect) { - jshort *sa= (*env)->GetShortArrayElements(env, rect, 0); - RectRgn((RgnHandle) rgnHandle, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, rect, sa, 0); + return (jint)GetControl32BitMaximum((ControlRef)arg0); } +#endif /* NO_GetControl32BitMaximum */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetRegionBounds(JNIEnv *env, jclass zz, jint rgnHandle, - jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - GetRegionBounds((RgnHandle) rgnHandle, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); +#ifndef NO_GetControl32BitMinimum +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControl32BitMinimum + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControl32BitMinimum\n") + + return (jint)GetControl32BitMinimum((ControlRef)arg0); } +#endif /* NO_GetControl32BitMinimum */ + +#ifndef NO_GetControl32BitValue +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControl32BitValue + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControl32BitValue\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetRectRgn(JNIEnv *env, jclass zz, jint rgnHandle, - jshort left, jshort top, jshort right, jshort bottom) { - SetRectRgn((RgnHandle)rgnHandle, left, top, right, bottom); + return (jint)GetControl32BitValue((ControlRef)arg0); } +#endif /* NO_GetControl32BitValue */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SectRgn(JNIEnv *env, jclass zz, jint ra, jint rb, jint dest) { - SectRgn((RgnHandle) ra, (RgnHandle) rb, (RgnHandle) dest); +#ifndef NO_GetControlBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("GetControlBounds\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + GetControlBounds((ControlRef)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_GetControlBounds */ + +#ifndef NO_GetControlData__ISIILorg_eclipse_swt_internal_carbon_Rect_2_3I +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlData__ISIILorg_eclipse_swt_internal_carbon_Rect_2_3I + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jint arg3, jobject arg4, jintArray arg5) +{ + Rect _arg4, *lparg4=NULL; + jint *lparg5=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_UnionRgn(JNIEnv *env, jclass zz, jint ra, jint rb, jint dest) { - UnionRgn((RgnHandle) ra, (RgnHandle) rb, (RgnHandle) dest); + DEBUG_CALL("GetControlData__ISIILorg_eclipse_swt_internal_carbon_Rect_2_3I\n") + + if (arg4) lparg4 = getRectFields(env, arg4, &_arg4); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)GetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (void *)lparg4, (Size *)lparg5); + if (arg4) setRectFields(env, arg4, lparg4); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_GetControlData__ISIILorg_eclipse_swt_internal_carbon_Rect_2_3I */ + +#ifndef NO_GetControlData__ISII_3I_3I +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlData__ISII_3I_3I + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jint arg3, jintArray arg4, jintArray arg5) +{ + jint *lparg4=NULL; + jint *lparg5=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DiffRgn(JNIEnv *env, jclass zz, jint ra, jint rb, jint dest) { - DiffRgn((RgnHandle) ra, (RgnHandle) rb, (RgnHandle) dest); + DEBUG_CALL("GetControlData__ISII_3I_3I\n") + + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)GetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (void *)lparg4, (Size *)lparg5); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_GetControlData__ISII_3I_3I */ + +#ifndef NO_GetControlData__ISII_3S_3I +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlData__ISII_3S_3I + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jint arg3, jshortArray arg4, jintArray arg5) +{ + jshort *lparg4=NULL; + jint *lparg5=NULL; + jint rc; -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_PtInRgn(JNIEnv *env, jclass zz, jshortArray pt, jint rgnHandle) { - return (jboolean) PtInRgn(point(env, pt), (RgnHandle) rgnHandle); + DEBUG_CALL("GetControlData__ISII_3S_3I\n") + + if (arg4) lparg4 = (*env)->GetShortArrayElements(env, arg4, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)GetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (void *)lparg4, (Size *)lparg5); + if (arg4) (*env)->ReleaseShortArrayElements(env, arg4, lparg4, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_GetControlData__ISII_3S_3I */ -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_RectInRgn(JNIEnv *env, jclass zz, jshortArray rect, jint rgnHandle) { - jshort *sa= (*env)->GetShortArrayElements(env, rect, 0); - jboolean status= (jboolean) RectInRgn((struct Rect*)sa, (RgnHandle) rgnHandle); - (*env)->ReleaseShortArrayElements(env, rect, sa, 0); - return status; -} +#ifndef NO_GetControlData__ISII_3B_3I +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlData__ISII_3B_3I + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jint arg3, jbyteArray arg4, jintArray arg5) +{ + jbyte *lparg4=NULL; + jint *lparg5=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyRgn(JNIEnv *env, jclass zz, jint src, jint dest) { - CopyRgn((RgnHandle) src, (RgnHandle) dest); + DEBUG_CALL("GetControlData__ISII_3B_3I\n") + + if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)GetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (void *)lparg4, (Size *)lparg5); + if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetClip(JNIEnv *env, jclass zz, jint rgnHandle) { - GetClip((RgnHandle)rgnHandle); +#endif + +#ifndef NO_GetControlFeatures +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlFeatures + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetControlFeatures\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)GetControlFeatures((ControlRef)arg0, (UInt32 *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetControlFeatures */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetClip(JNIEnv *env, jclass zz, jint rgnHandle) { - SetClip((RgnHandle)rgnHandle); +#ifndef NO_GetControlEventTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlEventTarget + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControlEventTarget\n") + + return (jint)GetControlEventTarget((ControlRef)arg0); } +#endif /* NO_GetControlEventTarget */ + +#ifndef NO_GetControlOwner +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlOwner + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControlOwner\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortClipRegion(JNIEnv *env, jclass zz, - jint port, jint rgnHandle) { - GetPortClipRegion((CGrafPtr)port, (RgnHandle)rgnHandle); + return (jint)GetControlOwner((ControlRef)arg0); } +#endif /* NO_GetControlOwner */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetOrigin(JNIEnv *env, jclass zz, jshort h, jshort v) { - SetOrigin(h, v); +#ifndef NO_GetControlProperty +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlProperty + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4, jintArray arg5) +{ + jint *lparg4=NULL; + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("GetControlProperty\n") + + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)GetControlProperty((ControlRef)arg0, arg1, arg2, arg3, (UInt32 *)lparg4, (void *)lparg5); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif + +#ifndef NO_GetControlReference +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlReference + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControlReference\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeRgn(JNIEnv *env, jclass zz, jint rgnHandle) { - DisposeRgn((RgnHandle)rgnHandle); + return (jint)GetControlReference((ControlRef)arg0); } +#endif /* NO_GetControlReference */ + +#ifndef NO_GetControlRegion +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlRegion + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2) +{ + DEBUG_CALL("GetControlRegion\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_EmptyRgn(JNIEnv *env, jclass zz, jint rgnHandle) { - return (jboolean) EmptyRgn((RgnHandle)rgnHandle); + return (jint)GetControlRegion((ControlRef)arg0, (ControlPartCode)arg1, (RgnHandle)arg2); } +#endif /* NO_GetControlRegion */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_OffsetRgn(JNIEnv *env, jclass zz, - jint rgnHandle, jshort dh, jshort dv) { - OffsetRgn((RgnHandle)rgnHandle, dh, dv); +#ifndef NO_GetControlValue +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlValue + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControlValue\n") + + return (jshort)GetControlValue((ControlRef)arg0); } +#endif /* NO_GetControlValue */ + +#ifndef NO_GetControlViewSize +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlViewSize + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetControlViewSize\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EraseRgn(JNIEnv *env, jclass zz, jint rgnHandle) { - EraseRgn((RgnHandle) rgnHandle); + return (jint)GetControlViewSize((ControlRef)arg0); } +#endif /* NO_GetControlViewSize */ + +#ifndef NO_GetCurrentEventButtonState +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentEventButtonState + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetCurrentEventButtonState\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvertRgn(JNIEnv *env, jclass zz, jint rgnHandle) { - InvertRgn((RgnHandle) rgnHandle); + return (jint)GetCurrentEventButtonState(); } +#endif /* NO_GetCurrentEventButtonState */ -//---- Polygons +#ifndef NO_GetCurrentEventLoop +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentEventLoop + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetCurrentEventLoop\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_OpenPoly(JNIEnv *env, jclass zz) { - return (jint) OpenPoly(); + return (jint)GetCurrentEventLoop(); } +#endif /* NO_GetCurrentEventLoop */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClosePoly(JNIEnv *env, jclass zz) { - ClosePoly(); +#ifndef NO_GetCurrentEventKeyModifiers +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentEventKeyModifiers + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetCurrentEventKeyModifiers\n") + + return (jint)GetCurrentEventKeyModifiers(); } +#endif /* NO_GetCurrentEventKeyModifiers */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_OffsetPoly(JNIEnv *env, jclass zz, jint polyHandle, jshort dx, jshort dy) { - OffsetPoly((PolyPtr *)polyHandle, dx, dy); +#ifndef NO_GetCurrentEventQueue +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentEventQueue + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetCurrentEventQueue\n") + + return (jint)GetCurrentEventQueue(); } +#endif /* NO_GetCurrentEventQueue */ + +#ifndef NO_GetCurrentProcess +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentProcess + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + jint rc; + + DEBUG_CALL("GetCurrentProcess\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_FramePoly(JNIEnv *env, jclass zz, jint polyHandle) { - FramePoly((PolyPtr *)polyHandle); + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + rc = (jint)GetCurrentProcess((ProcessSerialNumber *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + return rc; } +#endif /* NO_GetCurrentProcess */ + +#ifndef NO_GetCurrentScrap +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentScrap + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + jint rc; + + DEBUG_CALL("GetCurrentScrap\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintPoly(JNIEnv *env, jclass zz, jint polyHandle) { - PaintPoly((PolyPtr *)polyHandle); + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + rc = (jint)GetCurrentScrap((ScrapRef *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + return rc; } +#endif /* NO_GetCurrentScrap */ + +#ifndef NO_GetDataBrowserCallbacks +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserCallbacks + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + DataBrowserCallbacks _arg1, *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetDataBrowserCallbacks\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_KillPoly(JNIEnv *env, jclass zz, jint polyHandle) { - KillPoly((PolyPtr *)polyHandle); + if (arg1) lparg1 = getDataBrowserCallbacksFields(env, arg1, &_arg1); + rc = (jint)GetDataBrowserCallbacks((ControlRef)arg0, (DataBrowserCallbacks *)lparg1); + if (arg1) setDataBrowserCallbacksFields(env, arg1, lparg1); + return rc; } +#endif /* NO_GetDataBrowserCallbacks */ -//---- BitMap & PixMap +#ifndef NO_GetDataBrowserTableViewColumnPosition +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserTableViewColumnPosition + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewPixMap(JNIEnv *env, jclass zz, - jshort width, jshort height, jshort rowbytes, - jshort pixelType, jshort pixelSize, jshort cmpSize, jshort cmpCount, jshort pixelFormat) { - - PixMapHandle pmh= NewPixMap(); - PixMap *pm= *pmh; - - pm->baseAddr= NULL; - pm->rowBytes= rowbytes | 0x8000; // mark as PixMap - pm->bounds.top= 0; - pm->bounds.left= 0; - pm->bounds.bottom= height; - pm->bounds.right= width; - pm->pmVersion= baseAddr32; // 32 Bit clean - pm->packType= 0; - pm->packSize= 0; - pm->hRes= 0x00480000; - pm->vRes= 0x00480000; - pm->pixelType= pixelType; - pm->pixelSize= pixelSize; - pm->cmpCount= cmpCount; - pm->cmpSize= cmpSize; - pm->pixelFormat= pixelFormat; - pm->pmTable= NULL; - pm->pmExt= NULL; - - return (jint) pmh; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getRowBytes(JNIEnv *env, jclass zz, jint pHandle) { - BitMap **bmh= (BitMap**) pHandle; - return (jint) (*bmh)->rowBytes; -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_setRowBytes(JNIEnv *env, jclass zz, - jint pHandle, jshort rowBytes) { - BitMap **bmh= (BitMap**) pHandle; - (*bmh)->rowBytes= rowBytes; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getBaseAddr(JNIEnv *env, jclass zz, jint pHandle) { - /* - BitMap **bmh= (BitMap**) pHandle; - return (jint) (*bmh)->baseAddr; - */ - return (jint) GetPixBaseAddr((PixMapHandle)pHandle); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getColorTableSize(JNIEnv *env, jclass zz, - jint pixMapHandle) { - PixMapHandle srch= (PixMapHandle) pixMapHandle; - PixMap *src= *srch; - if (src->pmTable != NULL) { - ColorTable *ct= *src->pmTable; - return ct->ctSize + 1; - } - return -1; -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_getColorTable(JNIEnv *env, jclass zz, - jint pixMapHandle, jshortArray colorspec) { - PixMapHandle srch= (PixMapHandle) pixMapHandle; - PixMap *src= *srch; - int n= (*env)->GetArrayLength(env, colorspec) / 4; - if (src->pmTable != NULL) { - ColorTable *ct= *src->pmTable; - jshort *sa= (*env)->GetShortArrayElements(env, colorspec, 0); - memcpy(sa, ct->ctTable, n * sizeof(ColorSpec)); - (*env)->ReleaseShortArrayElements(env, colorspec, sa, 0); - } -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_setColorTable(JNIEnv *env, jclass zz, - jint pixMapHandle, jshortArray colorspec) { - - PixMapHandle ph= (PixMapHandle) pixMapHandle; - PixMap *pm= *ph; - ColorTable *ct; - jshort *sa; - int n= (*env)->GetArrayLength(env, colorspec) / 4; - - if (pm->pmTable != NULL) - DisposeHandle((Handle)pm->pmTable); - pm->pmTable= (ColorTable**) NewHandle(sizeof(ColorTable)+sizeof(ColorSpec)*(n-1)); - ct= *pm->pmTable; - ct->ctSize= (n-1); - ct->ctFlags= 0; - ct->ctSeed= GetCTSeed(); - - sa= (*env)->GetShortArrayElements(env, colorspec, 0); - memcpy(ct->ctTable, sa, n * sizeof(ColorSpec)); - (*env)->ReleaseShortArrayElements(env, colorspec, sa, 0); + DEBUG_CALL("GetDataBrowserTableViewColumnPosition\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetDataBrowserTableViewColumnPosition((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1, (DataBrowserTableViewColumnIndex *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_setBaseAddr(JNIEnv *env, jclass zz, - jint bitMapHandle, jint ptr) { - BitMap **bmh= (BitMap**) bitMapHandle; - (*bmh)->baseAddr= (void*) ptr; +#endif /* NO_GetDataBrowserTableViewColumnPosition */ + +#ifndef NO_GetDataBrowserTableViewNamedColumnWidth +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserTableViewNamedColumnWidth + (JNIEnv *env, jclass that, jint arg0, jint arg1, jshortArray arg2) +{ + jshort *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetDataBrowserTableViewNamedColumnWidth\n") + + if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL); + rc = (jint)GetDataBrowserTableViewNamedColumnWidth((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1, (UInt16 *)lparg2); + if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetDataBrowserTableViewNamedColumnWidth */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposePixMap(JNIEnv *env, jclass zz, jint pixMapHandle) { - PixMapHandle ph= (PixMapHandle) pixMapHandle; - PixMap *pm= *ph; - - if (pm->baseAddr != NULL) { - DisposePtr(pm->baseAddr); - pm->baseAddr= NULL; - } - - if ((pm->rowBytes & 0x8000) != 0) { // Pixmap - DisposePixMap(ph); - } else { // Bitmap - fprintf(stderr, "OS.DisposePixMap: warning: pixmap is bitmap\n"); - } +#ifndef NO_GetDataBrowserItemCount +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItemCount + (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jint arg3, jintArray arg4) +{ + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("GetDataBrowserItemCount\n") + + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)GetDataBrowserItemCount((ControlRef)arg0, (DataBrowserItemID)arg1, (Boolean)arg2, (DataBrowserItemState)arg3, (UInt32 *)lparg4); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_GetDataBrowserItemCount */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_duplicatePixMap(JNIEnv *env, jclass zz, jint srcPixmap) { +#ifndef NO_GetDataBrowserItemDataButtonValue +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItemDataButtonValue + (JNIEnv *env, jclass that, jint arg0, jshortArray arg1) +{ + jshort *lparg1=NULL; + jint rc; - PixMapHandle srch= (PixMapHandle) srcPixmap; - PixMapHandle dsth= NewPixMap(); - - PixMap *src= *srch; - PixMap *dst= *dsth; - - *dst= *src; - dst->pmExt= NULL; - - if (src->baseAddr != NULL) { - Size dataSize= GetPtrSize(src->baseAddr); - //fprintf(stderr, "duplicatePixMap: data %ld\n", dataSize); - dst->baseAddr= NewPtr(dataSize); - memcpy(dst->baseAddr, src->baseAddr, dataSize); - } - - if ((dst->rowBytes & 0x8000) != 0) { // pixmap - if (src->pmTable != NULL) { - ColorTable *ct; - Size dataSize= GetHandleSize((Handle)src->pmTable); - //fprintf(stderr, "duplicatePixMap: ctab %ld\n", dataSize); - dst->pmTable= (ColorTable**) NewHandle(dataSize); - ct= *dst->pmTable; - memcpy(ct, *src->pmTable, dataSize); - //fprintf(stderr, "duplicatePixMap: ctab size %d\n", ct->ctSize); - } - } - - return (jint) dsth; -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPixBounds(JNIEnv *env, jclass zz, jint pHandle, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - GetPixBounds((PixMapHandle) pHandle, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_setPixBounds(JNIEnv *env, jclass zz, - jint pHandle, jshort top, jshort left, jshort bottom, jshort right) { - BitMap **bmh= (BitMap**) pHandle; - BitMap *bm= *bmh; - bm->bounds.top= top; - bm->bounds.left= left; - bm->bounds.bottom= bottom; - bm->bounds.right= right; -} - -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPixDepth(JNIEnv *env, jclass zz, jint pHandle) { - return GetPixDepth((PixMapHandle) pHandle); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getPixHRes(JNIEnv *env, jclass zz, jint pHandle) { - PixMapHandle pmh= (PixMapHandle) pHandle; - return (jint) (*pmh)->hRes; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getPixVRes(JNIEnv *env, jclass zz, jint pHandle) { - PixMapHandle pmh= (PixMapHandle) pHandle; - return (jint) (*pmh)->vRes; -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyBits(JNIEnv *env, jclass zz, - jint srcBits, jint dstBits, jshortArray srcRect, jshortArray dstRect, jshort mode, jint maskRgn) { - jshort *sa= (*env)->GetShortArrayElements(env, srcRect, 0); - jshort *sb= (*env)->GetShortArrayElements(env, dstRect, 0); - CopyBits((BitMap*)srcBits, (BitMap*)dstBits, (Rect*)sa, (Rect*)sb, mode, (RgnHandle) maskRgn); - (*env)->ReleaseShortArrayElements(env, srcRect, sa, 0); - (*env)->ReleaseShortArrayElements(env, dstRect, sb, 0); -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyMask(JNIEnv *env, jclass zz, - jint srcBits, jint maskBits, jint dstBits, jshortArray srcRect, jshortArray maskRect, jshortArray dstRect) { - jshort *sa= (*env)->GetShortArrayElements(env, srcRect, 0); - jshort *sb= (*env)->GetShortArrayElements(env, maskRect, 0); - jshort *sc= (*env)->GetShortArrayElements(env, dstRect, 0); - CopyMask((BitMap*)srcBits, (BitMap*)maskBits, (BitMap*)dstBits, (Rect*)sa, (Rect*)sb, (Rect*)sc); - (*env)->ReleaseShortArrayElements(env, srcRect, sa, 0); - (*env)->ReleaseShortArrayElements(env, maskRect, sb, 0); - (*env)->ReleaseShortArrayElements(env, dstRect, sc, 0); -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyDeepMask(JNIEnv *env, jclass zz, jint srcBits, - jint maskBits, jint dstBits, jshortArray srcRect, jshortArray maskRect, jshortArray dstRect, jshort mode, jint maskRgn) { - jshort *sa= (*env)->GetShortArrayElements(env, srcRect, 0); - jshort *sb= (*env)->GetShortArrayElements(env, maskRect, 0); - jshort *sc= (*env)->GetShortArrayElements(env, dstRect, 0); - CopyDeepMask((BitMap*)srcBits, (BitMap*)maskBits, (BitMap*)dstBits, (Rect*) sa, (Rect*) sb, (Rect*) sc, mode, (RgnHandle) maskRgn); - (*env)->ReleaseShortArrayElements(env, srcRect, sa, 0); - (*env)->ReleaseShortArrayElements(env, maskRect, sb, 0); - (*env)->ReleaseShortArrayElements(env, dstRect, sc, 0); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortBitMapForCopyBits(JNIEnv *env, jclass zz, jint grafPort) { - return (jint) GetPortBitMapForCopyBits((CGrafPtr)grafPort); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewCIcon(JNIEnv *env, jclass zz, - jint pixMapHandle, jint maskHandle) { - CIcon *icon; - CIconHandle cih; - PixMap *ph= NULL; - BitMap *mh= NULL; - int pixmapRowbytes, pixmapWidth, pixmapHeight, pixmapSize; - int maskRowbytes, maskHeight, maskSize; - Size ctsize; - int size; - - if (pixMapHandle == 0) - return 0; - ph= *((PixMap**) pixMapHandle); - if (ph == NULL) - return 0; - - // calculate the CIcon size - - pixmapRowbytes= ph->rowBytes & 0x3fff; - pixmapHeight= ph->bounds.bottom - ph->bounds.top; - pixmapWidth= ph->bounds.right - ph->bounds.left; - pixmapSize= pixmapRowbytes * pixmapHeight; - - mh= *((BitMap**) maskHandle); - if (mh == NULL) - return 0; - - maskRowbytes= mh->rowBytes & 0x3fff; - maskHeight= mh->bounds.bottom - mh->bounds.top; - maskSize= maskRowbytes * maskHeight; - - // allocate the CIcon - cih= (CIconHandle) NewHandleClear(sizeof(CIcon) + maskSize); - if (cih == NULL) - return 0; - icon= *cih; - if (icon == NULL) - return 0; - - // copy the pixmap - memcpy(&icon->iconPMap, ph, sizeof(PixMap)); - icon->iconPMap.baseAddr= 0; // this is documented nowhere! - - // allocate the handle for the pixmap's data - icon->iconData= NewHandle(pixmapSize); - if (icon->iconData == 0) - return 0; - - // copy the pixmap's data - memcpy(*icon->iconData, ph->baseAddr, pixmapSize); - - // copy ctable (if any) - if (ph->pmTable != NULL) { - ctsize= GetHandleSize((Handle)ph->pmTable); - if (ctsize > 0) { - Handle h= NewHandle(ctsize); - memcpy(*h, *ph->pmTable, ctsize); - icon->iconPMap.pmTable= (ColorTable**) h; - } - } + DEBUG_CALL("GetDataBrowserItemDataButtonValue\n") - memcpy(&icon->iconMask, mh, sizeof(BitMap)); - // copy mask data to end of CIcon - memcpy(&icon->iconMaskData, icon->iconMask.baseAddr, maskSize); - icon->iconMask.baseAddr= 0; - - return (jint) cih; + if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); + rc = (jint)GetDataBrowserItemDataButtonValue((ControlRef)arg0, (UInt16 *)lparg1); + if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetDataBrowserItemDataButtonValue */ + +#ifndef NO_GetDataBrowserItemPartBounds +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItemPartBounds + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4) +{ + Rect _arg4, *lparg4=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getCIconIconData(JNIEnv *env, jclass zz, jint cIconHandle) { - CIcon *icon= *((CIconHandle) cIconHandle); - return (jint) icon->iconData; + DEBUG_CALL("GetDataBrowserItemPartBounds\n") + + if (arg4) lparg4 = getRectFields(env, arg4, &_arg4); + rc = (jint)GetDataBrowserItemPartBounds((ControlRef)arg0, (DataBrowserItemID)arg1, (DataBrowserPropertyID)arg2, (DataBrowserPropertyPart)arg3, (Rect *)lparg4); + if (arg4) setRectFields(env, arg4, lparg4); + return rc; } +#endif /* NO_GetDataBrowserItemPartBounds */ + +#ifndef NO_GetDataBrowserItems +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItems + (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jint arg3, jint arg4) +{ + DEBUG_CALL("GetDataBrowserItems\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getCIconColorTable(JNIEnv *env, jclass zz, jint cIconHandle) { - CIcon *icon= *((CIconHandle) cIconHandle); - return (jint) icon->iconPMap.pmTable; + return (jint)GetDataBrowserItems((ControlRef)arg0, (DataBrowserItemID)arg1, (Boolean)arg2, (DataBrowserItemState)arg3, (Handle)arg4); } +#endif /* NO_GetDataBrowserItems */ -//---- GWorlds & GDevices +#ifndef NO_GetDataBrowserItemState +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserItemState + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewGWorldFromPtr(JNIEnv *env, jclass zz, - jintArray offscreenGWorld, jint pixMapHandle) { - - PixMapHandle pm= (PixMapHandle) pixMapHandle; - jint *sa= (*env)->GetIntArrayElements(env, offscreenGWorld, 0); - - jint status= (jint) RC(NewGWorldFromPtr( - (GWorldPtr*) sa, - (*pm)->pixelFormat, - &((*pm)->bounds), - (*pm)->pmTable, - (GDHandle) NULL, - (GWorldFlags) 0, - (*pm)->baseAddr, - (*pm)->rowBytes & 0x3FFF)); + DEBUG_CALL("GetDataBrowserItemState\n") - (*env)->ReleaseIntArrayElements(env, offscreenGWorld, sa, 0); - return status; + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetDataBrowserItemState((ControlRef)arg0, (DataBrowserItemID)arg1, (DataBrowserItemState *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetDataBrowserItemState */ + +#ifndef NO_GetDataBrowserListViewHeaderBtnHeight +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserListViewHeaderBtnHeight + (JNIEnv *env, jclass that, jint arg0, jshortArray arg1) +{ + jshort *lparg1=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeGWorld(JNIEnv *env, jclass zz, jint offscreenGWorld) { - DisposeGWorld((GWorldPtr)offscreenGWorld); + DEBUG_CALL("GetDataBrowserListViewHeaderBtnHeight\n") + + if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); + rc = (jint)GetDataBrowserListViewHeaderBtnHeight((ControlRef)arg0, (UInt16 *)lparg1); + if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetDataBrowserListViewHeaderBtnHeight */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetGWorld(JNIEnv *env, jclass zz, jint portHandle, jint gdHandle) { - SetGWorld((CGrafPtr)portHandle, (GDHandle)gdHandle); +#ifndef NO_GetDataBrowserListViewHeaderDesc +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserListViewHeaderDesc + (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2) +{ + DataBrowserListViewHeaderDesc _arg2, *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetDataBrowserListViewHeaderDesc\n") + + if (arg2) lparg2 = getDataBrowserListViewHeaderDescFields(env, arg2, &_arg2); + rc = (jint)GetDataBrowserListViewHeaderDesc((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1, (DataBrowserListViewHeaderDesc *)lparg2); + if (arg2) setDataBrowserListViewHeaderDescFields(env, arg2, lparg2); + return rc; } +#endif + +#ifndef NO_GetDataBrowserTableViewItemID +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserTableViewItemID + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetDataBrowserTableViewItemID\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetGWorld(JNIEnv *env, jclass zz, jintArray portHandle, jintArray gdHandle) { - jint *sa= (*env)->GetIntArrayElements(env, portHandle, 0); - jint *sb= (*env)->GetIntArrayElements(env, gdHandle, 0); - GetGWorld((CGrafPtr*)sa, (GDHandle*)sb); - (*env)->ReleaseIntArrayElements(env, portHandle, sa, 0); - (*env)->ReleaseIntArrayElements(env, gdHandle, sb, 0); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetDataBrowserTableViewItemID((ControlRef)arg0, (DataBrowserTableViewRowIndex)arg1, (DataBrowserItemID *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetDataBrowserTableViewItemID */ + +#ifndef NO_GetDataBrowserTableViewItemRow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserTableViewItemRow + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetDataBrowserTableViewItemRow\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetGDevice(JNIEnv *env, jclass zz) { - return (jint) GetGDevice(); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetDataBrowserTableViewItemRow((ControlRef)arg0, (DataBrowserTableViewRowIndex)arg1, (DataBrowserItemID *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetDataBrowserTableViewItemRow */ + +#ifndef NO_GetDataBrowserTableViewRowHeight +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserTableViewRowHeight + (JNIEnv *env, jclass that, jint arg0, jshortArray arg1) +{ + jshort *lparg1=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMainDevice(JNIEnv *env, jclass zz) { - return (jint) GetMainDevice(); + DEBUG_CALL("GetDataBrowserTableViewRowHeight\n") + + if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); + rc = (jint)GetDataBrowserTableViewRowHeight((ControlRef)arg0, (UInt16 *)lparg1); + if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetDataBrowserTableViewRowHeight */ + +#ifndef NO_GetDataBrowserScrollBarInset +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserScrollBarInset + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_getgdPMap(JNIEnv *env, jclass zz, jint gdHandle) { - GDHandle h= (GDHandle) gdHandle; - return (jint) (*h)->gdPMap; + DEBUG_CALL("GetDataBrowserScrollBarInset\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + rc = (jint) GetDataBrowserScrollBarInset((ControlRef)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_GetDataBrowserScrollBarInset */ + +#ifndef NO_GetDataBrowserScrollPosition +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserScrollPosition + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jint rc; -//---- Window Manager + DEBUG_CALL("GetDataBrowserScrollPosition\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateNewWindow(JNIEnv *env, jclass zz, - jint windowClass, jint windowAttributes, jshortArray bounds, jintArray wHandle) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - jint *sb= (*env)->GetIntArrayElements(env, wHandle, 0); - jint status= (jint) RC(CreateNewWindow((WindowClass)windowClass, (WindowAttributes)windowAttributes, (const Rect*)sa, (WindowRef*)sb)); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); - (*env)->ReleaseIntArrayElements(env, wHandle, sb, 0); - return status; + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetDataBrowserScrollPosition((ControlRef)arg0, (UInt32 *)lparg1, (UInt32 *)lparg2); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetDataBrowserScrollPosition */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowPort(JNIEnv *env, jclass zz, jint wHandle) { - return (jint) GetWindowPort((WindowRef) wHandle); +#ifndef NO_GetDataBrowserSelectionAnchor +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDataBrowserSelectionAnchor + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetDataBrowserSelectionAnchor\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetDataBrowserSelectionAnchor((ControlRef)arg0, (UInt32 *)lparg1, (UInt32 *)lparg2); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetDataBrowserSelectionAnchor */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_BeginUpdate(JNIEnv *env, jclass zz, jint wHandle) { - BeginUpdate((WindowRef)wHandle); +#ifndef NO_GetDblTime +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDblTime + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetDblTime\n") + + return (jint)GetDblTime(); } +#endif /* NO_GetDblTime */ + +#ifndef NO_GetDefFontSize +JNIEXPORT jshort JNICALL OS_NATIVE(GetDefFontSize) + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetDefFontSize\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GlobalToLocal(JNIEnv *env, jclass zz, jshortArray point) { - jshort *sa= (*env)->GetShortArrayElements(env, point, 0); - GlobalToLocal((Point*)sa); - (*env)->ReleaseShortArrayElements(env, point, sa, 0); + return (jshort)GetDefFontSize(); } +#endif + +#ifndef NO_GetEventClass +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventClass + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetEventClass\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_LocalToGlobal(JNIEnv *env, jclass zz, jshortArray point) { - jshort *sa= (*env)->GetShortArrayElements(env, point, 0); - LocalToGlobal((Point*)sa); - (*env)->ReleaseShortArrayElements(env, point, sa, 0); + return (jint)GetEventClass((EventRef)arg0); } +#endif /* NO_GetEventClass */ + +#ifndef NO_GetEventDispatcherTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventDispatcherTarget + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetEventDispatcherTarget\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDGlobalToLocalPoint(JNIEnv *env, jclass zz, - jint port, jshortArray point) { - jshort *sa= (*env)->GetShortArrayElements(env, point, 0); - QDGlobalToLocalPoint((CGrafPtr)port, (Point*)sa); - (*env)->ReleaseShortArrayElements(env, point, sa, 0); + return (jint)GetEventDispatcherTarget(); } +#endif /* NO_GetEventDispatcherTarget */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDLocalToGlobalPoint(JNIEnv *env, jclass zz, - jint port, jshortArray point) { - jshort *sa= (*env)->GetShortArrayElements(env, point, 0); - QDLocalToGlobalPoint((CGrafPtr)port, (Point*)sa); - (*env)->ReleaseShortArrayElements(env, point, sa, 0); +#ifndef NO_GetEventKind +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventKind + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetEventKind\n") + + return (jint)GetEventKind((EventRef)arg0); } +#endif /* NO_GetEventKind */ + +#ifndef NO_GetEventParameter__III_3II_3I_3B +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3I_3B + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jbyteArray arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + jbyte *lparg6=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EndUpdate(JNIEnv *env, jclass zz, jint wHandle) { - EndUpdate((WindowRef)wHandle); + DEBUG_CALL("GetEventParameter__III_3II_3I_3B\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0); + return rc; +} +#endif /* NO_GetEventParameter__III_3II_3I_3B */ + +#ifndef NO_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_HICommand_2 +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_HICommand_2 + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jobject arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + HICommand _arg6, *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_HICommand_2\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = getHICommandFields(env, arg6, &_arg6); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) setHICommandFields(env, arg6, lparg6); + return rc; +} +#endif /* NO_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_HICommand_2 */ + +#ifndef NO_GetEventParameter__III_3II_3I_3I +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3I_3I + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jintArray arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + jint *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3I_3I\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0); + return rc; +} +#endif /* NO_GetEventParameter__III_3II_3I_3I */ + +#ifndef NO_GetEventParameter__III_3II_3I_3C +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3I_3C + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jcharArray arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + jchar *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3I_3C\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = (*env)->GetCharArrayElements(env, arg6, NULL); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) (*env)->ReleaseCharArrayElements(env, arg6, lparg6, 0); + return rc; } +#endif /* NO_GetEventParameter__III_3II_3I_3C */ + +#ifndef NO_GetEventParameter__III_3II_3I_3S +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3I_3S + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jshortArray arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + jshort *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3I_3S\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = (*env)->GetShortArrayElements(env, arg6, NULL); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) (*env)->ReleaseShortArrayElements(env, arg6, lparg6, 0); + return rc; +} +#endif /* NO_GetEventParameter__III_3II_3I_3S */ + +#ifndef NO_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_CGPoint_2 +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_CGPoint_2 + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jobject arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + CGPoint _arg6, *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_CGPoint_2\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = getCGPointFields(env, arg6, &_arg6); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) setCGPointFields(env, arg6, lparg6); + return rc; +} +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawControls(JNIEnv *env, jclass zz, jint wHandle) { - DrawControls((WindowRef)wHandle); +#ifndef NO_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_Point_2 +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_Point_2 + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jobject arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + Point _arg6, *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_Point_2\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = getPointFields(env, arg6, &_arg6); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) setPointFields(env, arg6, lparg6); + return rc; } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_UpdateControls(JNIEnv *env, jclass zz, jint wHandle, jint rgnHandle) { - UpdateControls((WindowRef)wHandle, (RgnHandle)rgnHandle); +#ifndef NO_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_RGBColor_2 +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_RGBColor_2 + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jobject arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + RGBColor _arg6, *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_RGBColor_2\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = getRGBColorFields(env, arg6, &_arg6); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) setRGBColorFields(env, arg6, lparg6); + return rc; } +#endif -/* -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawGrowIcon(JNIEnv *env, jclass zz, jint wHandle) { - DrawGrowIcon((WindowRef)wHandle); +#ifndef NO_GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_Rect_2 +JNIEXPORT jint JNICALL OS_NATIVE(GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_Rect_2) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5, jobject arg6) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + Rect _arg6, *lparg6=NULL; + jint rc; + + DEBUG_CALL("GetEventParameter__III_3II_3ILorg_eclipse_swt_internal_carbon_Rect_2\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg6) lparg6 = getRectFields(env, arg6, &_arg6); + rc = (jint)GetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (EventParamType *)lparg3, (UInt32)arg4, (UInt32 *)lparg5, (void *)lparg6); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg6) setRectFields(env, arg6, lparg6); + return rc; } -*/ +#endif + +#ifndef NO_GetEventTime +JNIEXPORT jdouble JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventTime + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetEventTime\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrontWindow(JNIEnv *env, jclass class) { - return (jint) FrontWindow(); + return (jdouble)GetEventTime((EventRef)arg0); } +#endif /* NO_GetEventTime */ + +#ifndef NO_GetFontInfo +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetFontInfo + (JNIEnv *env, jclass that, jshortArray arg0) +{ + jshort *lparg0=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FrontNonFloatingWindow(JNIEnv *env, jclass class) { - return (jint) FrontNonFloatingWindow(); + DEBUG_CALL("GetFontInfo\n") + + if (arg0) lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL); + GetFontInfo((FontInfo *)lparg0); + if (arg0) (*env)->ReleaseShortArrayElements(env, arg0, lparg0, 0); } +#endif /* NO_GetFontInfo */ + +#ifndef NO_GetGDevice +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetGDevice + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetGDevice\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SelectWindow(JNIEnv *env, jclass zz, jint wHandle) { - SelectWindow((WindowRef)wHandle); + return (jint)GetGDevice(); } +#endif /* NO_GetGDevice */ + +#ifndef NO_GetGWorld +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetGWorld + (JNIEnv *env, jclass that, jintArray arg0, jintArray arg1) +{ + jint *lparg0=NULL; + jint *lparg1=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ActivateWindow(JNIEnv *env, jclass zz, - jint wHandle, jboolean activate) { - ActivateWindow((WindowRef)wHandle, activate); + DEBUG_CALL("GetGWorld\n") + + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + GetGWorld((CGrafPtr *)lparg0, (GDHandle *)lparg1); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); } +#endif /* NO_GetGWorld */ + +#ifndef NO_GetGlobalMouse +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetGlobalMouse + (JNIEnv *env, jclass that, jobject arg0) +{ + Point _arg0, *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_BringToFront(JNIEnv *env, jclass zz, jint wHandle) { - BringToFront((WindowRef)wHandle); + DEBUG_CALL("GetGlobalMouse\n") + + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + GetGlobalMouse((Point *)lparg0); + if (arg0) setPointFields(env, arg0, lparg0); } +#endif /* NO_GetGlobalMouse */ + +#ifndef NO_GetIconRef +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetIconRef + (JNIEnv *env, jclass that, jshort arg0, jint arg1, jint arg2, jintArray arg3) +{ + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("GetIconRef\n") -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_FindWindow(JNIEnv *env, jclass zz, jshortArray where, jintArray warr) { - jint *body= NULL; - jshort part= 0; - if (warr != 0) - body= (*env)->GetIntArrayElements(env, warr, 0); - part= FindWindow(point(env, where), (WindowRef*)body); - if (body != NULL) - (*env)->ReleaseIntArrayElements(env, warr, body, 0); - return part; + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)GetIconRef((SInt16)arg0, (OSType)arg1, (OSType)arg2, (IconRef *)lparg3); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif -/* -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_ResizeWindow(JNIEnv *env, jclass zz, jint wHandle, - jshortArray startPt, jshortArray sizeConstraints, jshortArray newContentRect) { - jboolean b; - jshort *sa= NULL; - if (newContentRect != NULL) - sa= (*env)->GetShortArrayElements(env, newContentRect, 0); - b= ResizeWindow((WindowRef) wHandle, point(env, startPt), NULL, (Rect*) sa); - if (sa != NULL) - (*env)->ReleaseShortArrayElements(env, newContentRect, sa, 0); - return b; -} -*/ -/* -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DragWindow(JNIEnv *env, jclass zz, jint wHandle, - jshortArray startPt, jshortArray boundsRect) { - DragWindow((WindowRef)wHandle, point(env, startPt), NULL); +#ifndef NO_GetHandleSize +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetHandleSize + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetHandleSize\n") + + return (jint)GetHandleSize((Handle)arg0); } -*/ -/* -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowPortBounds(JNIEnv *env, jclass zz, jint wHandle, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - GetWindowPortBounds((WindowRef)wHandle, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); +#endif /* NO_GetHandleSize */ + +#ifndef NO_GetIndMenuItemWithCommandID +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetIndMenuItemWithCommandID + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jshortArray arg4) +{ + jint *lparg3=NULL; + jshort *lparg4=NULL; + jint rc; + + DEBUG_CALL("GetIndMenuItemWithCommandID\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg4) lparg4 = (*env)->GetShortArrayElements(env, arg4, NULL); + rc = (jint)GetIndMenuItemWithCommandID((MenuRef)arg0, (MenuCommand)arg1, (UInt32)arg2, (MenuRef *)lparg3, (MenuItemIndex *)lparg4); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg4) (*env)->ReleaseShortArrayElements(env, arg4, lparg4, 0); + return rc; } -*/ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowBounds(JNIEnv *env, jclass zz, jint wHandle, jshort region, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - GetWindowBounds((WindowRef)wHandle, region, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); +#endif /* NO_GetIndMenuItemWithCommandID */ + +#ifndef NO_GetIndexedSubControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetIndexedSubControl + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetIndexedSubControl\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetIndexedSubControl((ControlRef)arg0, (UInt16)arg1, (ControlRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetIndexedSubControl */ + +#ifndef NO_GetKeyboardFocus +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetKeyboardFocus + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetKeyboardFocus\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowBounds(JNIEnv *env, jclass zz, jint wHandle, jshort region, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - SetWindowBounds((WindowRef)wHandle, region, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)GetKeyboardFocus((WindowRef)arg0, (ControlRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetKeyboardFocus */ + +#ifndef NO_GetLastUserEventTime +JNIEXPORT jdouble JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetLastUserEventTime + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetLastUserEventTime\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsValidWindowPtr(JNIEnv *env, jclass zz, jint port) { - return (jboolean) IsValidWindowPtr((void*)port); + return (jdouble)GetLastUserEventTime(); } +#endif /* NO_GetLastUserEventTime */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWRefCon(JNIEnv *env, jclass zz, jint wHandle) { - return (jint) GetWRefCon((WindowRef)wHandle); +#ifndef NO_GetMainDevice +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMainDevice + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetMainDevice\n") + + return (jint)GetMainDevice(); } +#endif /* NO_GetMainDevice */ + +#ifndef NO_GetMainEventQueue +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMainEventQueue + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetMainEventQueue\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyWindowTitleAsCFString(JNIEnv *env, jclass zz, - jint wHandle, jintArray sHandle) { - jint *sa= (*env)->GetIntArrayElements(env, sHandle, 0); - jint status= (jint) RC(CopyWindowTitleAsCFString((WindowRef)wHandle, (CFStringRef*) sa)); - (*env)->ReleaseIntArrayElements(env, sHandle, sa, 0); - return status; + return (jint)GetMainEventQueue(); } +#endif /* NO_GetMainEventQueue */ + +#ifndef NO_GetMenuCommandMark +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuCommandMark + (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2) +{ + jchar *lparg2=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowTitleWithCFString(JNIEnv *env, jclass zz, jint wHandle, jint sHandle) { - return RC(SetWindowTitleWithCFString((WindowRef)wHandle, (CFStringRef)sHandle)); + DEBUG_CALL("GetMenuCommandMark\n") + + if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL); + rc = (jint)GetMenuCommandMark((MenuRef)arg0, (MenuCommand)arg1, (UniChar *)lparg2); + if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0); + return rc; } - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SizeWindow(JNIEnv *env, jclass zz, jint wHandle, jshort w, jshort h, jboolean update) { - SizeWindow((WindowRef)wHandle, w, h, update); +#endif /* NO_GetMenuCommandMark */ + +#ifndef NO_GetMenuEventTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuEventTarget + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetMenuEventTarget\n") + + return (jint)GetMenuEventTarget((MenuRef)arg0); } +#endif /* NO_GetMenuEventTarget */ + +#ifndef NO_GetMenuFont +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuFont + (JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jshortArray arg2) +{ + jshort *lparg1=NULL; + jshort *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetMenuFont\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_MoveWindow(JNIEnv *env, jclass zz, jint wHandle, jshort w, jshort h, jboolean toFront) { - MoveWindow((WindowRef)wHandle, w, h, toFront); + if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); + if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL); + rc = (jint)GetMenuFont((MenuRef)arg0, (SInt16 *)lparg1, (UInt16 *)lparg2); + if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0); + if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetMenuFont */ + +#ifndef NO_GetMenuID +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuID + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetMenuID\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ScrollWindowRect(JNIEnv *env, jclass zz, jint wHandle, - jshortArray rect, jshort dx, jshort dy, jint options, jint exposureRgn) { - jshort *sa= (*env)->GetShortArrayElements(env, rect, 0); - ScrollWindowRect((WindowRef)wHandle, (Rect*)sa, dx, dy, options, (RgnHandle) exposureRgn); - (*env)->ReleaseShortArrayElements(env, rect, sa, 0); + return (jshort)GetMenuID((MenuRef)arg0); } +#endif /* NO_GetMenuID */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWRefCon(JNIEnv *env, jclass zz, jint wHandle, jint data) { - SetWRefCon((WindowRef)wHandle, data); +#ifndef NO_GetMenuItemCommandID +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuItemCommandID + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetMenuItemCommandID\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetMenuItemCommandID((MenuRef)arg0, (SInt16)arg1, (MenuCommand *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetMenuItemCommandID */ -/* -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_TrackGoAway(JNIEnv *env, jclass zz, jint wHandle, jshortArray startPt) { - return TrackGoAway((WindowRef)wHandle, point(env, startPt)); +#ifndef NO_GetMenuItemHierarchicalMenu +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuItemHierarchicalMenu + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetMenuItemHierarchicalMenu\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetMenuItemHierarchicalMenu((MenuRef)arg0, (SInt16)arg1, (MenuRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } -*/ -/* -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_TrackBox(JNIEnv *env, jclass zz, jint wHandle, jshortArray startPt, jshort part) { - return TrackBox((WindowRef)wHandle, point(env, startPt), part); +#endif /* NO_GetMenuItemHierarchicalMenu */ + +#ifndef NO_GetMenuItemRefCon +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuItemRefCon + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetMenuItemRefCon\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetMenuItemRefCon((MenuRef)arg0, (SInt16)arg1, (UInt32 *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } -*/ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeWindow(JNIEnv *env, jclass class, jint wHandle) { - DisposeWindow((WindowRef)wHandle); +#endif /* NO_GetMenuItemRefCon */ + +#ifndef NO_GetMenuTrackingData +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuTrackingData + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + MenuTrackingData _arg1, *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetMenuTrackingData\n") + + if (arg1) lparg1 = getMenuTrackingDataFields(env, arg1, &_arg1); + rc = (jint)GetMenuTrackingData((MenuRef)arg0, lparg1); + if (arg1) setMenuTrackingDataFields(env, arg1, lparg1); + return rc; } -/* -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ZoomWindow(JNIEnv *env, jclass zz, jint wHandle, jshort part, jboolean toFront) { - ZoomWindow((WindowRef)wHandle, part, toFront); +#endif + +#ifndef NO_GetMouse +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMouse + (JNIEnv *env, jclass that, jobject arg0) +{ + Point _arg0, *lparg0=NULL; + + DEBUG_CALL("GetMouse\n") + + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + GetMouse((Point *)lparg0); + if (arg0) setPointFields(env, arg0, lparg0); } -*/ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvalWindowRect(JNIEnv *env, jclass zz, jint wHandle, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - InvalWindowRect((WindowRef)wHandle, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); +#endif /* NO_GetMouse */ + +#ifndef NO_GetPixBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPixBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("GetPixBounds\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + GetPixBounds((PixMapHandle)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_GetPixBounds */ + +#ifndef NO_GetPixDepth +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPixDepth + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetPixDepth\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvalWindowRgn(JNIEnv *env, jclass zz, jint wHandle, jint rgnHandle) { - InvalWindowRgn((WindowRef)wHandle, (RgnHandle)rgnHandle); + return (jshort)GetPixDepth((PixMapHandle)arg0); } +#endif /* NO_GetPixDepth */ + +#ifndef NO_GetPort +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPort + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + + DEBUG_CALL("GetPort\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ShowWindow(JNIEnv *env, jclass zz, jint wHandle) { - ShowWindow((WindowRef) wHandle); + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + GetPort((GrafPtr *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); } +#endif /* NO_GetPort */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_HideWindow(JNIEnv *env, jclass zz, jint wHandle) { - HideWindow((WindowRef) wHandle); +#ifndef NO_GetPortBitMapForCopyBits +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortBitMapForCopyBits + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetPortBitMapForCopyBits\n") + + return (jint)GetPortBitMapForCopyBits((CGrafPtr)arg0); } +#endif /* NO_GetPortBitMapForCopyBits */ + +#ifndef NO_GetPortBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("GetPortBounds\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsWindowVisible(JNIEnv *env, jclass zz, jint wHandle) { - return IsWindowVisible((WindowRef) wHandle); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + GetPortBounds((CGrafPtr)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_GetPortBounds */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowDefaultButton(JNIEnv *env, jclass zz, - jint wHandle, jint cHandle) { - return RC(SetWindowDefaultButton((WindowRef) wHandle, (ControlRef) cHandle)); +#ifndef NO_GetPortClipRegion +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortClipRegion + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("GetPortClipRegion\n") + + GetPortClipRegion((CGrafPtr)arg0, (RgnHandle)arg1); } +#endif /* NO_GetPortClipRegion */ + +#ifndef NO_GetPortVisibleRegion +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPortVisibleRegion + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("GetPortVisibleRegion\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowDefaultButton(JNIEnv *env, jclass zz, - jint wHandle, jintArray cHandle) { - jint *sa= (*env)->GetIntArrayElements(env, cHandle, 0); - int status= RC(GetWindowDefaultButton((WindowRef) wHandle, (ControlRef*) sa)); - (*env)->ReleaseIntArrayElements(env, cHandle, sa, 0); - return status; + return (jint)GetPortVisibleRegion((CGrafPtr)arg0, (RgnHandle)arg1); } +#endif /* NO_GetPortVisibleRegion */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowModality(JNIEnv *env, jclass zz, - jint wHandle, jintArray windowModality, jintArray parentWindowHandle) { - jint *sa= (*env)->GetIntArrayElements(env, windowModality, 0); - jint *sb= NULL; - jint status= 0; - if (parentWindowHandle != 0) - sb= (*env)->GetIntArrayElements(env, parentWindowHandle, 0); - status= (jint) RC(GetWindowModality((WindowRef) wHandle, (WindowModality*) sa, (WindowRef*) sb)); - (*env)->ReleaseIntArrayElements(env, windowModality, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, parentWindowHandle, sb, 0); - return status; +#ifndef NO_GetPtrSize +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPtrSize + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetPtrSize\n") + + return (jint)GetPtrSize((Ptr)arg0); } +#endif /* NO_GetPtrSize */ + +#ifndef NO_GetRegionBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetRegionBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("GetRegionBounds\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowModality(JNIEnv *env, jclass zz, - jint wHandle, jint modalityKind, jint parentWindow) { - return (jint) RC(SetWindowModality((WindowRef) wHandle, (WindowModality) modalityKind, (WindowRef) parentWindow)); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + GetRegionBounds((RgnHandle)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_GetRegionBounds */ -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsWindowActive(JNIEnv *env, jclass zz, jint wHandle) { - return (jboolean) IsWindowActive((WindowRef) wHandle); +#ifndef NO_GetRootControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetRootControl + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetRootControl\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)GetRootControl((WindowRef)arg0, (ControlRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetRootControl */ -//---- Menu Manager - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InitContextualMenus(JNIEnv *env, jclass zz) { - return (jint) RC(InitContextualMenus()); +#ifndef NO_GetScrapFlavorCount +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorCount + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetScrapFlavorCount\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)GetScrapFlavorCount((ScrapRef)arg0, (UInt32 *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetScrapFlavorCount */ + +#ifndef NO_GetScrapFlavorData +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorData + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jbyteArray arg3) +{ + jint *lparg2=NULL; + jbyte *lparg3=NULL; + jint rc; + + DEBUG_CALL("GetScrapFlavorData\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateNewMenu(JNIEnv *env, jclass zz, - jint menuId, jint menuAttributes, jintArray menuRef) { - jint *sa= (*env)->GetIntArrayElements(env, menuRef, 0); - jint status= (jint) RC(CreateNewMenu((MenuID)menuId, (MenuAttributes)menuAttributes, (MenuRef*)sa)); - (*env)->ReleaseIntArrayElements(env, menuRef, sa, 0); - return status; + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL); + rc = (jint)GetScrapFlavorData((ScrapRef)arg0, (ScrapFlavorType)arg1, (Size *)lparg2, (void *)lparg3); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_GetScrapFlavorData */ + +#ifndef NO_GetScrapFlavorInfoList +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorInfoList + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetScrapFlavorInfoList\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_MenuSelect(JNIEnv *env, jclass zz, jshortArray where) { - return MenuSelect(point(env, where)); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetScrapFlavorInfoList((ScrapRef)arg0, (UInt32 *)lparg1, (ScrapFlavorInfo *)lparg2); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetScrapFlavorInfoList */ + +#ifndef NO_GetScrapFlavorSize +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorSize + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetScrapFlavorSize\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_HiliteMenu(JNIEnv *env, jclass zz, jshort menuID) { - HiliteMenu(menuID); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetScrapFlavorSize((ScrapRef)arg0, (ScrapFlavorType)arg1, (Size *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetScrapFlavorSize */ + +#ifndef NO_GetSuperControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetSuperControl + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetSuperControl\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvalMenuBar(JNIEnv *env, jclass zz) { - InvalMenuBar(); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)GetSuperControl((ControlRef)arg0, (ControlRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetSuperControl */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DrawMenuBar(JNIEnv *env, jclass zz) { - DrawMenuBar(); +#ifndef NO_GetThemeBrushAsColor +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeBrushAsColor + (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jboolean arg2, jobject arg3) +{ + RGBColor _arg3, *lparg3=NULL; + jint rc; + + DEBUG_CALL("GetThemeBrushAsColor\n") + + if (arg3) lparg3 = getRGBColorFields(env, arg3, &_arg3); + rc = (jint)GetThemeBrushAsColor(arg0, arg1, arg2, (RGBColor*)lparg3); + if (arg3) setRGBColorFields(env, arg3, lparg3); + return rc; } +#endif + +#ifndef NO_GetThemeDrawingState +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeDrawingState + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + jint rc; + + DEBUG_CALL("GetThemeDrawingState\n") -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_CountMenuItems(JNIEnv *env, jclass zz, jint mHandle) { - return CountMenuItems((MenuRef)mHandle); + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + rc = (jint)GetThemeDrawingState((ThemeDrawingState *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + return rc; +} +#endif /* NO_GetThemeDrawingState */ + +#ifndef NO_GetThemeFont +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeFont + (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jbyteArray arg2, jshortArray arg3, jbyteArray arg4) +{ + jbyte *lparg2=NULL; + jshort *lparg3=NULL; + jbyte *lparg4=NULL; + jint rc; + + DEBUG_CALL("GetThemeFont\n") + + if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL); + if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL); + rc = (jint)GetThemeFont((ThemeFontID)arg0, (ScriptCode)arg1, (char *)lparg2, (SInt16 *)lparg3, (Style *)lparg4); + if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0); + if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_GetThemeFont */ + +#ifndef NO_GetThemeMetric +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeMetric + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("GetThemeTextDimensions\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DeleteMenuItems(JNIEnv *env, jclass zz, - jint mHandle, jshort firstItem, jint numItems) { - return RC(DeleteMenuItems((MenuRef)mHandle, firstItem, numItems)); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)GetThemeMetric((ThemeMetric)arg0, (SInt32 *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetThemeMetric */ + +#ifndef NO_GetThemeTextColor +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeTextColor + (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jboolean arg2, jobject arg3) +{ + RGBColor _arg3, *lparg3=NULL; + jint rc; + + DEBUG_CALL("GetThemeTextColor\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeMenu(JNIEnv *env, jclass zz, jint mHandle) { - DisposeMenu((MenuRef) mHandle); + if (arg3) lparg3 = getRGBColorFields(env, arg3, &_arg3); + rc = (jint)GetThemeTextColor(arg0, arg1, arg2, (RGBColor *)lparg3); + if (arg3) setRGBColorFields(env, arg3, lparg3); + return rc; } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InsertMenu(JNIEnv *env, jclass zz, jint mHandle, jshort index) { - InsertMenu((MenuRef) mHandle, index); +#ifndef NO_GetThemeTextDimensions +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeTextDimensions + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jboolean arg3, jobject arg4, jshortArray arg5) +{ + Point _arg4, *lparg4=NULL; + jshort *lparg5=NULL; + jint rc; + + DEBUG_CALL("GetThemeTextDimensions\n") + + if (arg4) lparg4 = getPointFields(env, arg4, &_arg4); + if (arg5) lparg5 = (*env)->GetShortArrayElements(env, arg5, NULL); + rc = (jint)GetThemeTextDimensions((CFStringRef)arg0, (ThemeFontID)arg1, (ThemeDrawState)arg2, (Boolean)arg3, (Point *)lparg4, (SInt16 *)lparg5); + if (arg4) setPointFields(env, arg4, lparg4); + if (arg5) (*env)->ReleaseShortArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif + +#ifndef NO_GetUserFocusEventTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetUserFocusEventTarget + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("GetUserFocusEventTarget\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DeleteMenu(JNIEnv *env, jclass zz, jshort menuId) { - DeleteMenu(menuId); + return (jint)GetUserFocusEventTarget(); } +#endif /* NO_GetUserFocusEventTarget */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClearMenuBar(JNIEnv *env, jclass zz) { - ClearMenuBar(); +#ifndef NO_GetWRefCon +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWRefCon + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetWRefCon\n") + + return (jint)GetWRefCon((WindowRef)arg0); } +#endif /* NO_GetWRefCon */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuItemRefCon(JNIEnv *env, jclass zz, jint mHandle, - jshort index, jintArray refCon) { - jint *sa= (*env)->GetIntArrayElements(env, refCon, 0); - int status= RC(GetMenuItemRefCon((MenuRef) mHandle, index, sa)); - (*env)->ReleaseIntArrayElements(env, refCon, sa, 0); - return status; +#ifndef NO_GetWindowBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowBounds + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jobject arg2) +{ + Rect _arg2, *lparg2=NULL; + + DEBUG_CALL("GetWindowBounds\n") + + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + GetWindowBounds((WindowRef)arg0, (WindowRegionCode)arg1, (Rect *)lparg2); + if (arg2) setRectFields(env, arg2, lparg2); } +#endif /* NO_GetWindowBounds */ + +#ifndef NO_GetWindowDefaultButton +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowDefaultButton + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemRefCon(JNIEnv *env, jclass zz, jint mHandle, - jshort index, jint refCon) { - return RC(SetMenuItemRefCon((MenuRef) mHandle, index, refCon)); + DEBUG_CALL("GetWindowDefaultButton\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)GetWindowDefaultButton((WindowRef)arg0, (ControlRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_GetWindowDefaultButton */ + +#ifndef NO_GetWindowEventTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowEventTarget + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetWindowEventTarget\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemTextWithCFString(JNIEnv *env, jclass zz, jint mHandle, - jshort index, jint sHandle) { - return RC(SetMenuItemTextWithCFString((MenuRef) mHandle, index, (CFStringRef) sHandle)); + return (jint)GetWindowEventTarget((WindowRef)arg0); } +#endif /* NO_GetWindowEventTarget */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CopyMenuItemTextAsCFString(JNIEnv *env, jclass zz, - jint mHandle, jshort index, jintArray sHandle) { - - jint *sa= (*env)->GetIntArrayElements(env, sHandle, 0); - jint status= (jint) RC(CopyMenuItemTextAsCFString((MenuRef) mHandle, index, (CFStringRef*) sa)); - (*env)->ReleaseIntArrayElements(env, sHandle, sa, 0); - return status; +#ifndef NO_GetWindowFromPort +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowFromPort + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetWindowFromPort\n") + + return (jint)GetWindowFromPort((CGrafPtr)arg0); } +#endif /* NO_GetWindowFromPort */ + +#ifndef NO_GetWindowGroupOfClass +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowGroupOfClass + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetWindowGroupOfClass\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemCommandKey(JNIEnv *env, jclass zz, - jint mHandle, jshort index, jboolean virtual, jchar key) { - return RC(SetMenuItemCommandKey((MenuRef) mHandle, index, virtual, key)); + return (jint)GetWindowGroupOfClass((WindowClass)arg0); } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemModifiers(JNIEnv *env, jclass zz, - jint mHandle, jshort index, jbyte modifiers) { - return RC(SetMenuItemModifiers((MenuRef) mHandle, index, modifiers)); +#ifndef NO_GetWindowModality +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowModality + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("GetWindowModality\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)GetWindowModality((WindowRef)arg0, (WindowModality *)lparg1, (WindowRef *)lparg2); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_GetWindowModality */ + +#ifndef NO_GetWindowPort +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowPort + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("GetWindowPort\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemKeyGlyph(JNIEnv *env, jclass zz, - jint mHandle, jshort index, jshort glyph) { - return RC(SetMenuItemKeyGlyph((MenuRef) mHandle, index, glyph)); + return (jint)GetWindowPort((WindowRef)arg0); } +#endif /* NO_GetWindowPort */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvalidateMenuItems(JNIEnv *env, jclass zz, - jint mHandle, jshort index, jint numItems) { - return RC(InvalidateMenuItems((MenuRef) mHandle, index, numItems)); +#ifndef NO_GetWindowStructureWidths +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWindowStructureWidths + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("GetWindowStructureWidths\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + GetWindowStructureWidths((WindowRef)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_GetWindowStructureWidths */ + +#ifndef NO_HandleControlSetCursor +JNIEXPORT jint JNICALL OS_NATIVE(HandleControlSetCursor) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jbooleanArray arg3) +{ + Point _arg1, *lparg1=NULL; + jboolean *lparg3=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InsertMenuItemTextWithCFString(JNIEnv *env, jclass zz, - jint mHandle, jint sHandle, jshort index, jint attributes, jint commandID) { - return RC(InsertMenuItemTextWithCFString((MenuRef) mHandle, (CFStringRef) sHandle, index, attributes, commandID)); + DEBUG_CALL("HandleControlSetCursor\n") + + if (arg1) lparg1 = getPointFields(env, arg1, &_arg1); + if (arg3) lparg3 = (*env)->GetBooleanArrayElements(env, arg3, NULL); + rc = (jint)HandleControlSetCursor((ControlRef)arg0, *(Point *)lparg1, (EventModifiers)arg2, (Boolean *)lparg3); + if (arg1) setPointFields(env, arg1, lparg1); + if (arg3) (*env)->ReleaseBooleanArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AppendMenuItemTextWithCFString(JNIEnv *env, jclass zz, - jint mHandle, jint sHandle, jint attributes, jint commandID, jshortArray outItemIndex) { - - jint status; - jshort *sa= NULL; - if (outItemIndex != 0) - (*env)->GetShortArrayElements(env, outItemIndex, 0); - status= (jint) RC(AppendMenuItemTextWithCFString((MenuRef) mHandle, (CFStringRef) sHandle, attributes, commandID, (MenuItemIndex*) sa)); - if (sa != NULL) - (*env)->ReleaseShortArrayElements(env, outItemIndex, sa, 0); - return status; +#ifndef NO_HIComboBoxAppendTextItem +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxAppendTextItem + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("HIComboBoxAppendTextItem\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)HIComboBoxAppendTextItem((HIViewRef)arg0, (CFStringRef)arg1, (CFIndex *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_HIComboBoxAppendTextItem */ + +#ifndef NO_HIComboBoxCopyTextItemAtIndex +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxCopyTextItemAtIndex + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("HIComboBoxCopyTextItemAtIndex\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EnableMenuCommand(JNIEnv *env, jclass zz, jint mHandle, jint commandId) { - EnableMenuCommand((MenuRef) mHandle, commandId); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)HIComboBoxCopyTextItemAtIndex((HIViewRef)arg0, (CFIndex)arg1, (CFStringRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; +} +#endif /* NO_HIComboBoxCopyTextItemAtIndex */ + +#ifndef NO_HIComboBoxCreate +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxCreate + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jobject arg2, jint arg3, jint arg4, jintArray arg5) +{ + CGRect _arg0, *lparg0=NULL; + ControlFontStyleRec _arg2, *lparg2=NULL; + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("HIComboBoxCreate\n") + + if (arg0) lparg0 = getCGRectFields(env, arg0, &_arg0); + if (arg2) lparg2 = getControlFontStyleRecFields(env, arg2, &_arg2); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)HIComboBoxCreate((const HIRect *)lparg0, (CFStringRef)arg1, (const ControlFontStyleRec *)lparg2, (CFArrayRef)arg3, (OptionBits)arg4, (HIViewRef *)lparg5); + if (arg0) setCGRectFields(env, arg0, lparg0); + if (arg2) setControlFontStyleRecFields(env, arg2, lparg2); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_HIComboBoxCreate */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisableMenuCommand(JNIEnv *env, jclass zz, jint mHandle, jint commandId) { - DisableMenuCommand((MenuRef) mHandle, commandId); +#ifndef NO_HIComboBoxGetItemCount +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxGetItemCount + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIComboBoxGetItemCount\n") + + return (jint)HIComboBoxGetItemCount((HIViewRef)arg0); } +#endif /* NO_HIComboBoxGetItemCount */ + +#ifndef NO_HIComboBoxInsertTextItemAtIndex +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxInsertTextItemAtIndex + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("HIComboBoxInsertTextItemAtIndex\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsMenuCommandEnabled(JNIEnv *env, jclass zz, jint mHandle, jint commandId) { - return (jboolean) IsMenuCommandEnabled((MenuRef) mHandle, commandId); + return (jint)HIComboBoxInsertTextItemAtIndex((HIViewRef)arg0, (CFIndex)arg1, (CFStringRef)arg2); } +#endif /* NO_HIComboBoxInsertTextItemAtIndex */ + +#ifndef NO_HIComboBoxRemoveItemAtIndex +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxRemoveItemAtIndex + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("HIComboBoxRemoveItemAtIndex\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetIndMenuItemWithCommandID(JNIEnv *env, jclass zz, jint mHandle, - jint commandId, jint index, jintArray outMenu, jshortArray outIndex) { - jint status; - jint *sa= NULL; - jshort *sb= NULL; - if (outMenu != NULL) - sa= (*env)->GetIntArrayElements(env, outMenu, 0); - if (outIndex != NULL) - sb= (*env)->GetShortArrayElements(env, outIndex, 0); - status= (jint) RC(GetIndMenuItemWithCommandID((MenuRef) mHandle, commandId, index, (MenuRef*)sa, sb)); - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, outMenu, sa, 0); - if (sb != NULL) - (*env)->ReleaseShortArrayElements(env, outIndex, sb, 0); - return status; + return (jint)HIComboBoxRemoveItemAtIndex((HIViewRef)arg0, (CFIndex)arg1); } +#endif /* NO_HIComboBoxRemoveItemAtIndex */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DeleteMenuItem(JNIEnv *env, jclass zz, jint mHandle, jshort index) { - DeleteMenuItem((MenuRef) mHandle, index); +#ifndef NO_HIObjectCopyClassID +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIObjectCopyClassID + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIObjectCopyClassID\n") + + return (jint)HIObjectCopyClassID((HIObjectRef)arg0); } +#endif /* NO_HIObjectCopyClassID */ + +#ifndef NO_HIObjectCreate +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIObjectCreate + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("HIObjectCreate\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuItemCommandID(JNIEnv *env, jclass zz, jint mHandle, jshort index, - jintArray commandId) { - jint *sa= (*env)->GetIntArrayElements(env, commandId, 0); - jint status= (jint) RC(GetMenuItemCommandID((MenuRef) mHandle, index, (MenuCommand*)sa)); - (*env)->ReleaseIntArrayElements(env, commandId, sa, 0); - return status; + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)HIObjectCreate((CFStringRef)arg0, (EventRef)arg1, (HIObjectRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_HIObjectCreate */ + +#ifndef NO_HIObjectRegisterSubclass +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIObjectRegisterSubclass + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5, jint arg6, jintArray arg7) +{ + jint *lparg5=NULL; + jint *lparg7=NULL; + jint rc; -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuID(JNIEnv *env, jclass zz, jint mHandle) { - return (jshort) GetMenuID((MenuRef) mHandle); + DEBUG_CALL("HIObjectRegisterSubclass\n") + + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL); + rc = (jint)HIObjectRegisterSubclass((CFStringRef)arg0, (CFStringRef)arg1, (OptionBits)arg2, (EventHandlerUPP)arg3, (UInt32)arg4, (const EventTypeSpec *)lparg5, (void *)arg6, (HIObjectClassRef *)lparg7); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0); + return rc; } +#endif /* NO_HIObjectRegisterSubclass */ + +#ifndef NO_HIViewAddSubview +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewAddSubview + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("HIViewAddSubview\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuHandle(JNIEnv *env, jclass zz, jshort menuId) { - return (jint) GetMenuHandle(menuId); + return (jint)HIViewAddSubview((HIViewRef)arg0, (HIViewRef)arg1); } +#endif /* NO_HIViewAddSubview */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PopUpMenuSelect(JNIEnv *env, jclass zz, jint mHandle, - jshort x, jshort y, jshort index) { - return PopUpMenuSelect((MenuRef) mHandle, x, y, index); +#ifndef NO_HIViewClick +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewClick + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("HIViewClick\n") + + return (jint)HIViewClick((HIViewRef)arg0, (EventRef)arg1); } +#endif /* NO_HIViewClick */ + +#ifndef NO_HIViewConvertPoint +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewConvertPoint + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + CGPoint _arg0, *lparg0=NULL; + jint rc; + + DEBUG_CALL("HIViewConvertPoint\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetRootMenu(JNIEnv *env, jclass zz, jint mHandle) { - return (jint) RC(SetRootMenu((MenuRef) mHandle)); + if (arg0) lparg0 = getCGPointFields(env, arg0, &_arg0); + rc = (jint)HIViewConvertPoint((HIPoint *)lparg0, (HIViewRef)arg1, (HIViewRef)arg2); + if (arg0) setCGPointFields(env, arg0, lparg0); + return rc; } +#endif /* NO_HIViewConvertPoint */ + +#ifndef NO_HIViewFindByID +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewFindByID + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("HIViewFindByID\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RetainMenu(JNIEnv *env, jclass zz, jint mHandle) { - return (jint) RC(RetainMenu((MenuRef) mHandle)); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)HIViewFindByID((HIViewRef)arg0, *(HIViewID *)arg1, (HIViewRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_HIViewFindByID */ + +#ifndef NO_HIViewGetFirstSubview +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetFirstSubview + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIViewGetFirstSubview\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ReleaseMenu(JNIEnv *env, jclass zz, jint mHandle) { - return (jint) RC(ReleaseMenu((MenuRef) mHandle)); + return (jint)HIViewGetFirstSubview((HIViewRef)arg0); } +#endif + +#ifndef NO_HIViewGetFrame +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetFrame + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + CGRect _arg1, *lparg1=NULL; + jint rc; + + DEBUG_CALL("HIViewGetFrame\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuTitleWithCFString(JNIEnv *env, jclass zz, jint mHandle, jint sHandle) { - return (jint) RC(SetMenuTitleWithCFString((MenuRef) mHandle, (CFStringRef) sHandle)); + if (arg1) lparg1 = getCGRectFields(env, arg1, &_arg1); + rc = (jint)HIViewGetFrame((HIViewRef)arg0, (HIRect *)lparg1); + if (arg1) setCGRectFields(env, arg1, lparg1); + return rc; } +#endif /* NO_HIViewGetFrame */ + +#ifndef NO_HIViewGetLastSubview +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetLastSubview + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIViewGetLastSubview\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuItemHierarchicalMenu(JNIEnv *env, jclass zz, jint mHandle, - jshort index, jintArray outHierMenuHandle) { - jint *sa= (*env)->GetIntArrayElements(env, outHierMenuHandle, 0); - jint status= (jint) RC(GetMenuItemHierarchicalMenu((MenuRef) mHandle, index, (MenuRef*)sa)); - (*env)->ReleaseIntArrayElements(env, outHierMenuHandle, sa, 0); - return status; + return (jint)HIViewGetLastSubview((HIViewRef)arg0); } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemHierarchicalMenu(JNIEnv *env, jclass zz, jint mHandle, - jshort index, jint hierMenuHandle) { - return (jint) RC(SetMenuItemHierarchicalMenu((MenuRef) mHandle, index, (MenuRef) hierMenuHandle)); +#ifndef NO_HIViewGetNextView +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetNextView + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIViewGetNextView\n") + + return (jint)HIViewGetNextView((HIViewRef)arg0); } +#endif + +#ifndef NO_HIViewGetRoot +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetRoot + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIViewGetRoot\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InsertMenuItem(JNIEnv *env, jclass zz, jint mHandle, - jbyteArray text, jshort index) { - jbyte *sa= (*env)->GetByteArrayElements(env, text, 0); - InsertMenuItem((MenuRef) mHandle, (ConstStr255Param) sa, index); - (*env)->ReleaseByteArrayElements(env, text, sa, 0); + return (jint)HIViewGetRoot((WindowRef)arg0); } +#endif /* NO_HIViewGetRoot */ + +#ifndef NO_HIViewGetSizeConstraints +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetSizeConstraints + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jobject arg2) +{ + CGRect _arg1, *lparg1=NULL; + CGRect _arg2, *lparg2=NULL; + jint rc; + + DEBUG_CALL("HIViewGetSizeConstraints\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_AppendMenu(JNIEnv *env, jclass zz, jint mHandle, jbyteArray text) { - jbyte *sa= (*env)->GetByteArrayElements(env, text, 0); - AppendMenu((MenuRef) mHandle, (ConstStr255Param) sa); - (*env)->ReleaseByteArrayElements(env, text, sa, 0); + if (arg1) lparg1 = getCGRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = getCGRectFields(env, arg2, &_arg2); + rc = (jint)HIViewGetSizeConstraints((HIViewRef)arg0, (HISize *)lparg1, (HISize *)lparg2); + if (arg1) setCGRectFields(env, arg1, lparg1); + if (arg2) setCGRectFields(env, arg2, lparg2); + return rc; } +#endif + +#ifndef NO_HIViewGetSubviewHit +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetSubviewHit + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jboolean arg2, jintArray arg3) +{ + CGPoint _arg1, *lparg1=NULL; + jint *lparg3=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ChangeMenuItemAttributes(JNIEnv *env, jclass zz, jint mHandle, - jshort index, jint setAttributes, jint clearAttributes) { - return RC(ChangeMenuItemAttributes((MenuRef) mHandle, index, setAttributes, clearAttributes)); + DEBUG_CALL("HIViewGetSubviewHit\n") + + if (arg1) lparg1 = getCGPointFields(env, arg1, &_arg1); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)HIViewGetSubviewHit((HIViewRef)arg0, (CGPoint *)lparg1, (Boolean)arg2, (HIViewRef *)lparg3); + if (arg1) setCGPointFields(env, arg1, lparg1); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_HIViewGetSubviewHit */ + +#ifndef NO_HIViewGetViewForMouseEvent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetViewForMouseEvent + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2) +{ + jint *lparg2=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CheckMenuItem(JNIEnv *env, jclass zz, jint mHandle, - jshort index, jboolean checked) { - CheckMenuItem((MenuRef) mHandle, index, checked); + DEBUG_CALL("HIViewGetViewForMouseEvent\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)HIViewGetViewForMouseEvent((HIViewRef)arg0, (EventRef)arg1, (HIViewRef *)lparg2); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_HIViewGetViewForMouseEvent */ + +#ifndef NO_HIViewIsVisible +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewIsVisible + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIViewIsVisible\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuCommandMark(JNIEnv *env, jclass zz, jint mHandle, - jint commandId, jshortArray markCharacter) { - jchar *sa= (*env)->GetCharArrayElements(env, markCharacter, 0); - jint status= (jint) RC(GetMenuCommandMark((MenuRef) mHandle, commandId, (UniChar*) sa)); - (*env)->ReleaseCharArrayElements(env, markCharacter, sa, 0); - return status; + return (jboolean) HIViewIsVisible((HIViewRef)arg0); } +#endif /* NO_HIViewIsVisible */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuCommandMark(JNIEnv *env, jclass zz, jint mHandle, - jint commandId, jchar markCharacter) { - return (jint) RC(SetMenuCommandMark((MenuRef) mHandle, commandId, (UniChar) markCharacter)); +#ifndef NO_HIViewRemoveFromSuperview +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewRemoveFromSuperview + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HIViewRemoveFromSuperview\n") + + return (jint)HIViewRemoveFromSuperview((HIViewRef)arg0); } +#endif /* NO_HIViewRemoveFromSuperview */ + +#ifndef NO_HIViewSetBoundsOrigin +JNIEXPORT jint JNICALL OS_NATIVE(HIViewSetBoundsOrigin) + (JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2) +{ + DEBUG_CALL("HIViewSetBoundsOrigin\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsValidMenu(JNIEnv *env, jclass zz, jint mHandle) { - return (jboolean) IsValidMenu((MenuRef) mHandle); + return (jint)HIViewSetBoundsOrigin((HIViewRef)arg0, (float)arg1, (float)arg2); } +#endif + +#ifndef NO_HIViewSetDrawingEnabled +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetDrawingEnabled + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("HIViewSetDrawingEnabled\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuID(JNIEnv *env, jclass zz, jint mHandle, jshort id) { - SetMenuID((MenuRef) mHandle, id); + return (jint)HIViewSetDrawingEnabled((HIViewRef)arg0, (Boolean)arg1); } +#endif /* NO_HIViewSetDrawingEnabled */ + +#ifndef NO_HIViewSetFrame +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetFrame + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + CGRect _arg1, *lparg1=NULL; + jint rc; -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsMenuItemEnabled(JNIEnv *env, jclass zz, jint mHandle, jshort index) { - return (jboolean) IsMenuItemEnabled((MenuRef) mHandle, index); + DEBUG_CALL("HIViewSetFrame\n") + + if (arg1) lparg1 = getCGRectFields(env, arg1, &_arg1); + rc = (jint)HIViewSetFrame((HIViewRef)arg0, (const HIRect *)lparg1); + if (arg1) setCGRectFields(env, arg1, lparg1); + return rc; } +#endif /* NO_HIViewSetFrame */ + +#ifndef NO_HIViewSetNeedsDisplay +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetNeedsDisplay + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("HIViewSetNeedsDisplay\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisableMenuItem(JNIEnv *env, jclass zz, jint mHandle, jshort index) { - DisableMenuItem((MenuRef) mHandle, index); + return (jint)HIViewSetNeedsDisplay((HIViewRef)arg0, (Boolean)arg1); } +#endif /* NO_HIViewSetNeedsDisplay */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_EnableMenuItem(JNIEnv *env, jclass zz, jint mHandle, jshort index) { - EnableMenuItem((MenuRef) mHandle, index); +#ifndef NO_HIViewSetNeedsDisplayInRegion +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetNeedsDisplayInRegion + (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2) +{ + DEBUG_CALL("HIViewSetNeedsDisplayInRegion\n") + + return (jint)HIViewSetNeedsDisplayInRegion((HIViewRef)arg0, (RgnHandle)arg1, (Boolean)arg2); } +#endif /* NO_HIViewSetNeedsDisplayInRegion */ + +#ifndef NO_HIViewSetVisible +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetVisible + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("HIViewSetVisible\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuFont(JNIEnv *env, jclass zz, - jint mHandle, jshortArray fontID, jshortArray size) { - jshort *sa= (*env)->GetShortArrayElements(env, fontID, 0); - jshort *sb= (*env)->GetShortArrayElements(env, size, 0); - jint status= (jint) RC(GetMenuFont((MenuRef) mHandle, (SInt16*) sa, (UInt16*) sb)); - (*env)->ReleaseShortArrayElements(env, fontID, sa, 0); - (*env)->ReleaseShortArrayElements(env, size, sb, 0); - return status; + return (jint)HIViewSetVisible((HIViewRef)arg0, (Boolean)arg1); } +#endif /* NO_HIViewSetVisible */ + +#ifndef NO_HIViewSetZOrder +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetZOrder + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("HIViewSetZOrder\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuFont(JNIEnv *env, jclass zz, - jint mHandle, jshort fontID, jshort size) { - return (jint) RC(SetMenuFont((MenuRef) mHandle, (SInt16) fontID, (UInt16) size)); + return (jint)HIViewSetZOrder((HIViewRef)arg0, (HIViewZOrderOp)arg1, (HIViewRef)arg2); } +#endif /* NO_HIViewSetZOrder */ + +#ifndef NO_HIViewSimulateClick +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSimulateClick + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jshortArray arg3) +{ + jshort *lparg3=NULL; + jint rc; + + DEBUG_CALL("HIViewSimulateClick\n") -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetMenuWidth(JNIEnv *env, jclass zz, jint mHandle) { - return (jshort) GetMenuWidth((MenuRef) mHandle); + if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL); + rc = (jint)HIViewSimulateClick((HIViewRef)arg0, (HIViewPartCode)arg1, (UInt32)arg2, (ControlPartCode *)lparg3); + if (arg3) (*env)->ReleaseShortArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_HIViewSimulateClick */ + +#ifndef NO_HandleControlClick +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_HandleControlClick + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3) +{ + Point _arg1, *lparg1=NULL; + jshort rc; + + DEBUG_CALL("HandleControlClick\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CalcMenuSize(JNIEnv *env, jclass zz, jint mHandle) { - CalcMenuSize((MenuRef) mHandle); + if (arg1) lparg1 = getPointFields(env, arg1, &_arg1); + rc = (jshort)HandleControlClick((ControlRef)arg0, (Point)*lparg1, (EventModifiers)arg2, (ControlActionUPP)arg3); + if (arg1) setPointFields(env, arg1, lparg1); + return rc; } +#endif /* NO_HandleControlClick */ + +#ifndef NO_HiWord +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_HiWord + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HiWord\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemIconHandle(JNIEnv *env, jclass zz, - jint mHandle, jshort index, jbyte type, jint icon) { - return RC(SetMenuItemIconHandle((MenuRef) mHandle, (SInt16)index, (UInt8)type, (Handle)icon)); + return (jshort)HiWord(arg0); } +#endif /* NO_HiWord */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemCommandID(JNIEnv *env, jclass zz, - jint mHandle, jshort index, jint commandID) { - return RC(SetMenuItemCommandID((MenuRef) mHandle, (SInt16)index, (MenuCommand)commandID)); +#ifndef NO_HideWindow +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_HideWindow + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HideWindow\n") + + HideWindow((WindowRef)arg0); } +#endif /* NO_HideWindow */ -//---- Control Manager +#ifndef NO_HiliteMenu +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_HiliteMenu + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("HiliteMenu\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlAction(JNIEnv *env, jclass zz, jint cHandle, jint actionProc) { - SetControlAction((ControlRef)cHandle, (ControlActionUPP) actionProc); + HiliteMenu((MenuID)arg0); } +#endif /* NO_HiliteMenu */ -/* not for primetime use */ -/* -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_setControlToolTipText(JNIEnv *env, jclass zz, - jint cHandle, jshortArray bounds, jint sHandle) { - - HMHelpContentRec help; - jint status; - Rect *r= (Rect*) (*env)->GetShortArrayElements(env, bounds, 0); - - HMSetHelpTagsDisplayed(true); - - help.version= 0; - help.absHotRect.left= r->left; - help.absHotRect.top= r->top; - help.absHotRect.right= r->right; - help.absHotRect.bottom= r->bottom; - help.tagSide= kHMDefaultSide; - help.content[0].contentType= kHMCFStringContent; - help.content[0].u.tagCFString= (CFStringRef) sHandle; - help.content[1].contentType= kHMNoContent; - help.content[1].u.tagCFString= 0; - - status= RC(HMSetControlHelpContent((ControlRef) cHandle, &help)); +#ifndef NO_HLock +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_HLock + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HLock\n") + + HLock((Handle)arg0); +} +#endif /* NO_HLock */ + +#ifndef NO_HMGetTagDelay +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HMGetTagDelay + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + jint rc; + + DEBUG_CALL("HMGetTagDelay\n") - (*env)->ReleaseShortArrayElements(env, bounds, (jshort*) r, 0); + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + rc = (jint)HMGetTagDelay((Duration *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + return rc; +} +#endif /* NO_HMGetTagDelay */ + +#ifndef NO_HMHideTag +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HMHideTag + (JNIEnv *env, jclass that, jintArray arg0) +{ + + DEBUG_CALL("HMHideTag\n") - return status; + return (jint)HMHideTag(); } -*/ +#endif /* NO_HMHideTag */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewControl(JNIEnv *env, jclass zz, - jint wHandle, jboolean visible, jshort initialValue, jshort minValue, jshort maxValue, jshort procID) { - return (jint) NewControl((WindowRef) wHandle, &NULL_RECT, "", visible, initialValue, minValue, maxValue, procID, 0); +#ifndef NO_HMSetTagDelay +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HMSetTagDelay + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HMSetTagDelay\n") + + return (jint) HMSetTagDelay((Duration)arg0); } +#endif /* NO_HMSetTagDelay */ + +#ifndef NO_HMInstallControlContentCallback +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HMInstallControlContentCallback + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("HMInstallControlContentCallback\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeControl(JNIEnv *env, jclass zz, jint cHandle) { - DisposeControl((ControlRef) cHandle); + return (jint) HMInstallControlContentCallback((ControlRef)arg0, (HMControlContentUPP)arg1); } +#endif /* NO_HMInstallControlContentCallback */ + +#ifndef NO_HUnlock +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_HUnlock + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("HUnlock\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateUserPaneControl(JNIEnv *env, jclass zz, - jint wHandle, jshortArray bounds, jint features, jintArray cHandle) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - jint *sb= (*env)->GetIntArrayElements(env, cHandle, 0); - jint status= (jint) RC(CreateUserPaneControl((WindowRef) wHandle, (const Rect*) sa, features, (ControlRef*) sb)); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); - (*env)->ReleaseIntArrayElements(env, cHandle, sb, 0); - return status; + HUnlock((Handle)arg0); } +#endif /* NO_HUnlock */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetRootControl(JNIEnv *env, jclass zz, jint wHandle, jintArray cHandle) { - jint *sa= (*env)->GetIntArrayElements(env, cHandle, 0); - jint status= (jint) RC(GetRootControl((WindowRef) wHandle, (ControlRef*)sa)); - (*env)->ReleaseIntArrayElements(env, cHandle, sa, 0); - return status; +#ifndef NO_InitContextualMenus +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InitContextualMenus + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("InitContextualMenus\n") + + return (jint)InitContextualMenus(); } +#endif /* NO_InitContextualMenus */ + +#ifndef NO_InitCursor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InitCursor + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("InitCursor\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateRootControl(JNIEnv *env, jclass zz, jint wHandle, jintArray cHandle) { - jint *sa= (*env)->GetIntArrayElements(env, cHandle, 0); - jint status= (jint) RC(CreateRootControl((WindowRef) wHandle, (ControlRef*)sa)); - (*env)->ReleaseIntArrayElements(env, cHandle, sa, 0); - return status; + InitCursor(); } +#endif /* NO_InitCursor */ + +#ifndef NO_InitDataBrowserCallbacks +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InitDataBrowserCallbacks + (JNIEnv *env, jclass that, jobject arg0) +{ + DataBrowserCallbacks _arg0={0}, *lparg0=NULL; + jint rc; + + DEBUG_CALL("InitDataBrowserCallbacks\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_EmbedControl(JNIEnv *env, jclass zz, jint cHandle, jint parentHandle) { - return (jint) RC(EmbedControl((ControlRef) cHandle, (ControlRef) parentHandle)); + if (arg0) lparg0 = getDataBrowserCallbacksFields(env, arg0, &_arg0); + rc = (jint)InitDataBrowserCallbacks((DataBrowserCallbacks *)lparg0); + if (arg0) setDataBrowserCallbacksFields(env, arg0, lparg0); + return rc; } +#endif /* NO_InitDataBrowserCallbacks */ + +#ifndef NO_InitDataBrowserCustomCallbacks +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InitDataBrowserCustomCallbacks + (JNIEnv *env, jclass that, jobject arg0) +{ + DataBrowserCustomCallbacks _arg0, *lparg0=NULL; + jint rc; + + DEBUG_CALL("InitDataBrowserCustomCallbacks\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlOwner(JNIEnv *env, jclass zz, jint cHandle) { - return (jint) GetControlOwner((ControlRef) cHandle); + if (arg0) lparg0 = getDataBrowserCustomCallbacksFields(env, arg0, &_arg0); + rc = (jint)InitDataBrowserCustomCallbacks(lparg0); + if (arg0) setDataBrowserCustomCallbacksFields(env, arg0, lparg0); + return rc; } +#endif + +#ifndef NO_InsertMenu +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InsertMenu + (JNIEnv *env, jclass that, jint arg0, jshort arg1) +{ + DEBUG_CALL("InsertMenu\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FindControlUnderMouse(JNIEnv *env, jclass zz, jshortArray where, - jint wHandle, jshortArray cHandle) { - jshort *sa= (*env)->GetShortArrayElements(env, cHandle, 0); - ControlRef c= FindControlUnderMouse(point(env, where), (WindowRef) wHandle, sa); - (*env)->ReleaseShortArrayElements(env, cHandle, sa, 0); - return (jint) c; + InsertMenu((MenuRef)arg0, (MenuID)arg1); } +#endif /* NO_InsertMenu */ -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_TestControl(JNIEnv *env, jclass zz, - jint cHandle, jshortArray where) { - return (jshort) TestControl((ControlRef)cHandle, point(env, where)); +#ifndef NO_InsertMenuItemTextWithCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InsertMenuItemTextWithCFString + (JNIEnv *env, jclass that, jint arg0, jint arg1, jshort arg2, jint arg3, jint arg4) +{ + DEBUG_CALL("InsertMenuItemTextWithCFString\n") + + return (jint)InsertMenuItemTextWithCFString((MenuRef)arg0, (CFStringRef)arg1, (MenuItemIndex)arg2, (MenuItemAttributes)arg3, (MenuCommand)arg4); } +#endif /* NO_InsertMenuItemTextWithCFString */ + +#ifndef NO_InstallEventHandler +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InstallEventHandler + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jintArray arg5) +{ + jint *lparg3=NULL; + jint *lparg5=NULL; + jint rc; -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_HandleControlClick(JNIEnv *env, jclass zz, jint cHandle, - jshortArray where, jint modifiers, jint action) { - return HandleControlClick((ControlRef)cHandle, point(env, where), modifiers, (ControlActionUPP) action); + DEBUG_CALL("InstallEventHandler\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)InstallEventHandler((EventTargetRef)arg0, (EventHandlerUPP)arg1, (UInt32)arg2, (const EventTypeSpec *)lparg3, (void *)arg4, (EventHandlerRef *)lparg5); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_InstallEventHandler */ + +#ifndef NO_InstallEventLoopTimer +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InstallEventLoopTimer + (JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jint arg3, jint arg4, jintArray arg5) +{ + jint *lparg5=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_MoveControl(JNIEnv *env, jclass zz, jint cHandle, jshort x, jshort y) { - MoveControl((ControlRef) cHandle, x, y); + DEBUG_CALL("InstallEventLoopTimer\n") + + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)InstallEventLoopTimer((EventLoopRef)arg0, (EventTimerInterval)arg1, (EventTimerInterval)arg2, (EventLoopTimerUPP)arg3, (void *)arg4, (EventLoopTimerRef *)lparg5); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_InstallEventLoopTimer */ + +#ifndef NO_InvalWindowRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvalWindowRect + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SizeControl(JNIEnv *env, jclass zz, jint cHandle, jshort w, jshort h) { - SizeControl((ControlRef) cHandle, w, h); + DEBUG_CALL("InvalWindowRect\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + InvalWindowRect((WindowRef)arg0, (const Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_InvalWindowRect */ + +#ifndef NO_InvalWindowRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvalWindowRgn + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("InvalWindowRgn\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ShowControl(JNIEnv *env, jclass zz, jint cHandle) { - ShowControl((ControlRef) cHandle); + InvalWindowRgn((WindowRef)arg0, (RgnHandle)arg1); } +#endif /* NO_InvalWindowRgn */ + +#ifndef NO_InvertRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvertRect + (JNIEnv *env, jclass that, jobject arg0) +{ + Rect _arg0, *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_HideControl(JNIEnv *env, jclass zz, jint cHandle) { - HideControl((ControlRef) cHandle); + DEBUG_CALL("InvertRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + InvertRect((const Rect *)lparg0); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_InvertRect */ + +#ifndef NO_InvertRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvertRgn + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("InvertRgn\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsControlVisible(JNIEnv *env, jclass zz, jint cHandle) { - return (jboolean) IsControlVisible((ControlRef) cHandle); + InvertRgn((RgnHandle)arg0); } +#endif /* NO_InvertRgn */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlVisibility(JNIEnv *env, jclass zz, jint cHandle, - jboolean isVisible, jboolean doDraw) { - return (jint) RC(SetControlVisibility((ControlRef)cHandle, isVisible, doDraw)); +#ifndef NO_IsControlActive +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsControlActive + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsControlActive\n") + + return (jboolean)IsControlActive((ControlRef)arg0); } +#endif /* NO_IsControlActive */ + +#ifndef NO_IsControlEnabled +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsControlEnabled + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsControlEnabled\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsControlActive(JNIEnv *env, jclass zz, jint cHandle) { - return (jboolean) IsControlActive((ControlRef) cHandle); + return (jboolean)IsControlEnabled((ControlRef)arg0); } +#endif /* NO_IsControlEnabled */ + +#ifndef NO_IsControlVisible +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsControlVisible + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsControlVisible\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlBounds(JNIEnv *env, jclass zz, jint cHandle, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - Rect *r= (Rect*) sa; - if (r->bottom - r->top < 0 || r->right - r->left < 0) { - //fprintf(stdout, "-*-*-*-*-*_*-*_* SetControlBounds: %d %d %d %d\n", r->left, r->top, r->right-r->left, r->bottom-r->top); - } else - SetControlBounds((ControlRef)cHandle, r); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + return (jboolean)IsControlVisible((ControlRef)arg0); } +#endif /* NO_IsControlVisible */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlBounds(JNIEnv *env, jclass zz, jint cHandle, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - GetControlBounds((ControlRef)cHandle, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); +#ifndef NO_IsDataBrowserItemSelected +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsDataBrowserItemSelected + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("IsDataBrowserItemSelected\n") + + return (jboolean)IsDataBrowserItemSelected((ControlRef)arg0, (DataBrowserItemID)arg1); } +#endif /* NO_IsDataBrowserItemSelected */ + +#ifndef NO_IsMenuCommandEnabled +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsMenuCommandEnabled + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("IsMenuCommandEnabled\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlRegion(JNIEnv *env, jclass zz, - jint cHandle, jshort part, jint region) { - return (jint) RC(GetControlRegion((ControlRef)cHandle, (ControlPartCode) part, (RgnHandle) region)); + return (jboolean)IsMenuCommandEnabled((MenuRef)arg0, (MenuCommand)arg1); } +#endif /* NO_IsMenuCommandEnabled */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CountSubControls(JNIEnv *env, jclass zz, jint cHandle, jshortArray count) { - jshort *sa= (*env)->GetShortArrayElements(env, count, 0); - jint status= (jint) RC(CountSubControls((ControlRef)cHandle, sa)); - (*env)->ReleaseShortArrayElements(env, count, sa, 0); - return status; +#ifndef NO_IsMenuItemEnabled +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsMenuItemEnabled + (JNIEnv *env, jclass that, jint arg0, jshort arg1) +{ + DEBUG_CALL("IsMenuItemEnabled\n") + + return (jboolean)IsMenuItemEnabled((MenuRef)arg0, (MenuItemIndex)arg1); } +#endif /* NO_IsMenuItemEnabled */ + +#ifndef NO_IsValidControlHandle +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsValidControlHandle + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsValidControlHandle\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetIndexedSubControl(JNIEnv *env, jclass zz, - jint cHandle, jshort index, jintArray outCHandle) { - jint *sa= (*env)->GetIntArrayElements(env, outCHandle, 0); - jint status= (jint) RC(GetIndexedSubControl((ControlRef) cHandle, index, (ControlRef*) sa)); - (*env)->ReleaseIntArrayElements(env, outCHandle, sa, 0); - return status; + return (jboolean)IsValidControlHandle((ControlRef)arg0); } +#endif /* NO_IsValidControlHandle */ + +#ifndef NO_IsValidMenu +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsValidMenu + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsValidMenu\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetSuperControl(JNIEnv *env, jclass zz, jint cHandle, jintArray parentHandle) { - jint *sa= (*env)->GetIntArrayElements(env, parentHandle, 0); - jint status= (jint) RC(GetSuperControl((ControlRef)cHandle, (ControlRef*) sa)); - (*env)->ReleaseIntArrayElements(env, parentHandle, sa, 0); - return status; + return (jboolean)IsValidMenu((MenuRef)arg0); } +#endif /* NO_IsValidMenu */ -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsValidControlHandle(JNIEnv *env, jclass zz, jint cHandle) { - return (jboolean) IsValidControlHandle((ControlRef)cHandle); +#ifndef NO_IsValidWindowPtr +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsValidWindowPtr + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsValidWindowPtr\n") + + return (jboolean)IsValidWindowPtr((WindowRef)arg0); } +#endif /* NO_IsValidWindowPtr */ + +#ifndef NO_IsWindowActive +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsWindowActive + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsWindowActive\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlReference(JNIEnv *env, jclass zz, jint cHandle, jint data) { - SetControlReference((ControlRef)cHandle, data); + return (jboolean)IsWindowActive((WindowRef)arg0); } +#endif /* NO_IsWindowActive */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlReference(JNIEnv *env, jclass zz, jint cHandle) { - return (jint) GetControlReference((ControlRef)cHandle); +#ifndef NO_IsWindowCollapsed +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsWindowCollapsed + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsWindowCollapsed\n") + + return (jboolean)IsWindowCollapsed((WindowRef)arg0); } +#endif /* NO_IsWindowCollapsed */ + +#ifndef NO_IsWindowVisible +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsWindowVisible + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("IsWindowVisible\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlTitleAsCFString(JNIEnv *env, jclass zz, - jint cHandle, jintArray sHandle) { - jint *sa= (*env)->GetIntArrayElements(env, sHandle, 0); - jint status= (jint) RC(CopyControlTitleAsCFString((ControlRef)cHandle, (CFStringRef*) sa)); - (*env)->ReleaseIntArrayElements(env, sHandle, sa, 0); - return status; + return (jboolean)IsWindowVisible((WindowRef)arg0); } +#endif /* NO_IsWindowVisible */ + +#ifndef NO_KillPoly +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_KillPoly + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("KillPoly\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlTitleWithCFString(JNIEnv *env, jclass zz, jint cHandle, jint sHandle) { - return (jint) RC(SetControlTitleWithCFString((ControlRef)cHandle, (CFStringRef) sHandle)); + KillPoly((PolyHandle)arg0); } +#endif /* NO_KillPoly */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_EnableControl(JNIEnv *env, jclass zz, jint cHandle) { - return (jint) RC(EnableControl((ControlRef)cHandle)); +#ifndef NO_LineTo +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_LineTo + (JNIEnv *env, jclass that, jshort arg0, jshort arg1) +{ + DEBUG_CALL("LineTo\n") + + LineTo((short)arg0, (short)arg1); } +#endif /* NO_LineTo */ + +#ifndef NO_LoWord +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_LoWord + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("LoWord\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisableControl(JNIEnv *env, jclass zz, jint cHandle) { - return (jint) RC(DisableControl((ControlRef)cHandle)); + return (jshort)LoWord(arg0); } +#endif /* NO_LoWord */ + +#ifndef NO_LockPortBits +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_LockPortBits + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("LockPortBits\n") -JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_IsControlEnabled(JNIEnv *env, jclass zz, jint cHandle) { - return (jboolean) IsControlEnabled((ControlRef)cHandle); + return (jint)LockPortBits((GrafPtr)arg0); } +#endif /* NO_LockPortBits */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControl32BitMaximum(JNIEnv *env, jclass zz, jint cHandle) { - return GetControl32BitMaximum((ControlRef)cHandle); +#ifndef NO_MenuSelect +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_MenuSelect + (JNIEnv *env, jclass that, jobject arg0) +{ + Point _arg0, *lparg0=NULL; + jint rc; + + DEBUG_CALL("MenuSelect\n") + + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + rc = (jint)MenuSelect((Point)*lparg0); + if (arg0) setPointFields(env, arg0, lparg0); + return rc; } +#endif /* NO_MenuSelect */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControl32BitMaximum(JNIEnv *env, jclass zz, jint cHandle, jint max) { - SetControl32BitMaximum((ControlRef)cHandle, max); +#ifndef NO_MoveControl +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_MoveControl + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2) +{ + DEBUG_CALL("MoveControl\n") + + MoveControl((ControlRef)arg0, (SInt16)arg1, (SInt16)arg2); } +#endif /* NO_MoveControl */ + +#ifndef NO_MoveTo +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_MoveTo + (JNIEnv *env, jclass that, jshort arg0, jshort arg1) +{ + DEBUG_CALL("MoveTo\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControl32BitMinimum(JNIEnv *env, jclass zz, jint cHandle) { - return GetControl32BitMinimum((ControlRef)cHandle); + MoveTo((short)arg0, (short)arg1); } +#endif /* NO_MoveTo */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlMinimum(JNIEnv *env, jclass zz, jint cHandle, jshort min) { - SetControlMinimum((ControlRef)cHandle, min); +#ifndef NO_MoveWindow +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_MoveWindow + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2, jboolean arg3) +{ + DEBUG_CALL("MoveWindow\n") + + MoveWindow((WindowRef)arg0, (short)arg1, (short)arg2, (Boolean)arg3); } +#endif /* NO_MoveWindow */ + +#ifndef NO_NavCreateChooseFolderDialog +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavCreateChooseFolderDialog + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jintArray arg4) +{ + NavDialogCreationOptions _arg0, *lparg0=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("NavCreateChooseFolderDialog\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControl32BitMinimum(JNIEnv *env, jclass zz, jint cHandle, jint min) { - SetControl32BitMinimum((ControlRef)cHandle, min); + if (arg0) lparg0 = getNavDialogCreationOptionsFields(env, arg0, &_arg0); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)NavCreateChooseFolderDialog((const NavDialogCreationOptions *)lparg0, (NavEventUPP)arg1, (NavObjectFilterUPP)arg2, (void *)arg3, (NavDialogRef *)lparg4); + if (arg0) setNavDialogCreationOptionsFields(env, arg0, lparg0); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_NavCreateChooseFolderDialog */ + +#ifndef NO_NavCreateGetFileDialog +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavCreateGetFileDialog + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jintArray arg6) +{ + NavDialogCreationOptions _arg0, *lparg0=NULL; + jint *lparg6=NULL; + jint rc; + + DEBUG_CALL("NavCreateGetFileDialog\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControl32BitValue(JNIEnv *env, jclass zz, jint cHandle) { - return GetControl32BitValue((ControlRef)cHandle); + if (arg0) lparg0 = getNavDialogCreationOptionsFields(env, arg0, &_arg0); + if (arg6) lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL); + rc = (jint)NavCreateGetFileDialog((const NavDialogCreationOptions *)lparg0, (NavTypeListHandle)arg1, (NavEventUPP)arg2, (NavPreviewUPP)arg3, (NavObjectFilterUPP)arg4, (void *)arg5, (NavDialogRef *)lparg6); + if (arg0) setNavDialogCreationOptionsFields(env, arg0, lparg0); + if (arg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0); + return rc; } +#endif /* NO_NavCreateGetFileDialog */ + +#ifndef NO_NavCreatePutFileDialog +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavCreatePutFileDialog + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5) +{ + NavDialogCreationOptions _arg0, *lparg0=NULL; + jint *lparg5=NULL; + jint rc; + + DEBUG_CALL("NavCreatePutFileDialog\n") -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlValue(JNIEnv *env, jclass zz, jint cHandle) { - return GetControlValue((ControlRef)cHandle); + if (arg0) lparg0 = getNavDialogCreationOptionsFields(env, arg0, &_arg0); + if (arg5) lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL); + rc = (jint)NavCreatePutFileDialog((const NavDialogCreationOptions *)lparg0, (OSType)arg1, (OSType)arg2, (NavEventUPP)arg3, (void *)arg4, (NavDialogRef *)lparg5); + if (arg0) setNavDialogCreationOptionsFields(env, arg0, lparg0); + if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); + return rc; } +#endif /* NO_NavCreatePutFileDialog */ + +#ifndef NO_NavDialogDispose +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogDispose + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NavDialogDispose\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControl32BitValue(JNIEnv *env, jclass zz, jint cHandle, jint value) { - SetControl32BitValue((ControlRef)cHandle, value); + NavDialogDispose((NavDialogRef)arg0); } +#endif /* NO_NavDialogDispose */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlViewSize(JNIEnv *env, jclass zz, jint cHandle) { - return (jint) GetControlViewSize((ControlRef)cHandle); +#ifndef NO_NavDialogGetReply +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogGetReply + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + NavReplyRecord _arg1, *lparg1=NULL; + jint rc; + + DEBUG_CALL("NavDialogGetReply\n") + + if (arg1) lparg1 = getNavReplyRecordFields(env, arg1, &_arg1); + rc = (jint)NavDialogGetReply((NavDialogRef)arg0, (NavReplyRecord *)lparg1); + if (arg1) setNavReplyRecordFields(env, arg1, lparg1); + return rc; } +#endif /* NO_NavDialogGetReply */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlViewSize(JNIEnv *env, jclass zz, jint cHandle, jint viewSize) { - SetControlViewSize((ControlRef)cHandle, viewSize); +#ifndef NO_NavDialogGetSaveFileName +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogGetSaveFileName + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NavDialogGetSaveFileName\n") + + return (jint)NavDialogGetSaveFileName((NavDialogRef)arg0); } +#endif /* NO_NavDialogGetSaveFileName */ -/* -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_IdleControls(JNIEnv *env, jclass zz, jint wHandle) { - IdleControls((WindowRef)wHandle); -} -*/ - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetBestControlRect(JNIEnv *env, jclass zz, jint cHandle, - jshortArray rect, jshortArray base) { - jshort *sa= (*env)->GetShortArrayElements(env, rect, 0); - jshort *sb= (*env)->GetShortArrayElements(env, base, 0); - jint status= (jint) RC(GetBestControlRect((ControlRef)cHandle, (Rect*) sa, (short*) sb)); - (*env)->ReleaseShortArrayElements(env, rect, sa, 0); - (*env)->ReleaseShortArrayElements(env, base, sb, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlKind(JNIEnv *env, jclass zz, jint cHandle, jintArray kind) { - jint *sa= (*env)->GetIntArrayElements(env, kind, 0); - jint status= (jint) RC(GetControlKind((ControlRef)cHandle, (ControlKind*) sa)); - (*env)->ReleaseIntArrayElements(env, kind, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlData__ISI_3I(JNIEnv *env, jclass zz, jint cHandle, - jshort partCode, jint tag, jintArray data) { - Size outSize; - jint *sa= (*env)->GetIntArrayElements(env, data, 0); - jsize length= (*env)->GetArrayLength(env, data); - OSErr error= RC(GetControlData((ControlRef) cHandle, partCode, tag, sizeof(int)*length, sa, &outSize)); - (*env)->ReleaseIntArrayElements(env, data, sa, 0); - return error; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlData__ISI_3S(JNIEnv *env, jclass zz, jint cHandle, - jshort partCode, jint tag, jshortArray data) { - Size outSize; - jshort *sa= (*env)->GetShortArrayElements(env, data, 0); - jsize length= (*env)->GetArrayLength(env, data); - OSErr error= RC(GetControlData((ControlRef) cHandle, partCode, tag, sizeof(short)*length, sa, &outSize)); - (*env)->ReleaseShortArrayElements(env, data, sa, 0); - return error; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__ISII(JNIEnv *env, jclass zz, - jint cHandle, jshort partCode, jint tag, jint data) { - return RC(SetControlData((ControlRef) cHandle, partCode, tag, sizeof(int), (Ptr) &data)); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__ISI_3S(JNIEnv *env, jclass zz, - jint cHandle, jshort partCode, jint tag, jshortArray data) { - jshort *sa= (*env)->GetShortArrayElements(env, data, 0); - jsize length= (*env)->GetArrayLength(env, data); - jint status= (jint) RC(SetControlData((ControlRef) cHandle, partCode, tag, sizeof(short)*length, (Ptr) sa)); - (*env)->ReleaseShortArrayElements(env, data, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetBevelButtonContentInfo(JNIEnv *env, jclass zz, - jint cHandle, jshort controlContentType, jint controlContent) { - - ControlButtonContentInfo info; - - info.contentType= (ControlContentType) controlContentType; - info.u.cIconHandle= (CIconHandle) controlContent; - - return RC(SetBevelButtonContentInfo((ControlRef) cHandle, &info)); +#ifndef NO_NavDialogGetUserAction +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogGetUserAction + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NavDialogGetUserAction\n") + + return (jint)NavDialogGetUserAction((NavDialogRef)arg0); } +#endif /* NO_NavDialogGetUserAction */ + +#ifndef NO_NavDialogRun +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogRun + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NavDialogRun\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlFontStyle(JNIEnv *env, jclass zz, - jint cHandle, jshort font, jshort size, jshort style) { - ControlFontStyleRec fontRec; - fontRec.flags= kControlUseFontMask | kControlUseSizeMask | kControlUseFaceMask; - fontRec.font= font; - fontRec.size= size; - fontRec.style= style; - return (jint) RC(SetControlFontStyle((ControlRef) cHandle, &fontRec)); + return (jint)NavDialogRun((NavDialogRef)arg0); } +#endif /* NO_NavDialogRun */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetUpControlBackground(JNIEnv *env, jclass zz, - jint cHandle, jshort depth, jboolean isColorDevice) { - return (jint) RC(SetUpControlBackground((ControlRef) cHandle, depth, isColorDevice)); +#ifndef NO_NavDialogSetSaveFileName +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogSetSaveFileName + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("NavDialogSetSaveFileName\n") + + return (jint)NavDialogSetSaveFileName((NavDialogRef)arg0, (CFStringRef)arg1); } +#endif /* NO_NavDialogSetSaveFileName */ + +#ifndef NO_NavGetDefaultDialogCreationOptions +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavGetDefaultDialogCreationOptions + (JNIEnv *env, jclass that, jobject arg0) +{ + NavDialogCreationOptions _arg0, *lparg0=NULL; + jint rc; -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_HandleControlKey(JNIEnv *env, jclass zz, - jint cHandle, jshort inKeyCode, jchar inCharCode, jint modifiers) { - return (ControlPartCode) HandleControlKey((ControlRef)cHandle, (SInt16)inKeyCode, (SInt16)inCharCode, (EventModifiers) modifiers); + DEBUG_CALL("NavGetDefaultDialogCreationOptions\n") + + if (arg0) lparg0 = getNavDialogCreationOptionsFields(env, arg0, &_arg0); + rc = (jint)NavGetDefaultDialogCreationOptions((NavDialogCreationOptions *)lparg0); + if (arg0) setNavDialogCreationOptionsFields(env, arg0, lparg0); + return rc; } +#endif /* NO_NavGetDefaultDialogCreationOptions */ -//---- standard dialogs +#ifndef NO_NewControl +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jbyteArray arg2, jboolean arg3, jshort arg4, jshort arg5, jshort arg6, jshort arg7, jint arg8) +{ + Rect _arg1, *lparg1=NULL; + jbyte *lparg2=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PickColor(JNIEnv *env, jclass zz, - jshortArray rgb, jshortArray where, jbyteArray title, jbooleanArray success) { + DEBUG_CALL("NewControl\n") - jint status; - ColorPickerInfo info; + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL); + rc = (jint)NewControl((WindowRef)arg0, (const Rect *)lparg1, (ConstStr255Param)lparg2, (Boolean)arg3, (SInt16)arg4, (SInt16)arg5, (SInt16)arg6, (SInt16)arg7, (SInt32)arg8); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0); + return rc; +} +#endif /* NO_NewControl */ - jshort *sa= (*env)->GetShortArrayElements(env, rgb, 0); - jshort *sb= (*env)->GetShortArrayElements(env, where, 0); - jbyte *sc= (*env)->GetByteArrayElements(env, title, 0); - jboolean *sd= (*env)->GetBooleanArrayElements(env, success, 0); - - info.theColor.profile= NULL; - info.theColor.color.rgb.red= sa[0]; - info.theColor.color.rgb.green= sa[1]; - info.theColor.color.rgb.blue= sa[2]; - info.dstProfile= NULL; - info.flags= kColorPickerDialogIsMoveable | kColorPickerDialogIsModal; - info.placeWhere= kAtSpecifiedOrigin; - info.dialogOrigin.v= sb[0]; - info.dialogOrigin.h= sb[1]; - info.pickerType= 0; - info.eventProc= NULL; - info.colorProc= NULL; - info.colorProcData= 0; - memcpy(info.prompt, sc, (size_t) sc[0]); - info.mInfo.editMenuID= 0; - info.mInfo.cutItem= 0; - info.mInfo.copyItem= 0; - info.mInfo.pasteItem= 0; - info.mInfo.clearItem= 0; - info.mInfo.undoItem= 0; - - status= (jint) RC(PickColor(&info)); - - sd[0]= info.newColorChosen; - - if (info.newColorChosen) { - sa[0]= info.theColor.color.rgb.red; - sa[1]= info.theColor.color.rgb.green; - sa[2]= info.theColor.color.rgb.blue; - } - - (*env)->ReleaseShortArrayElements(env, rgb, sa, 0); - (*env)->ReleaseShortArrayElements(env, where, sb, 0); - (*env)->ReleaseByteArrayElements(env, title, sc, 0); - (*env)->ReleaseBooleanArrayElements(env, success, sd, 0); +#ifndef NO_NewGWorldFromPtr +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewGWorldFromPtr + (JNIEnv *env, jclass that, jintArray arg0, jint arg1, jobject arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7) +{ + jint *lparg0=NULL; + Rect _arg2, *lparg2=NULL; + jint rc; + + DEBUG_CALL("NewGWorldFromPtr\n") - return status; + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + rc = (jint)NewGWorldFromPtr((GWorldPtr *)lparg0, (unsigned long)arg1, (const Rect *)lparg2, (CTabHandle)arg3, (GDHandle)arg4, (GWorldFlags)arg5, (Ptr)arg6, (long)arg7); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + if (arg2) setRectFields(env, arg2, lparg2); + return rc; } +#endif /* NO_NewGWorldFromPtr */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavCreateGetFileDialog(JNIEnv *env, jclass zz, - jint optionFlags, jint windowTitle, jint whandle, jintArray dialogHandle) { - - NavDialogCreationOptions options; - jint status; - jint *sa= (*env)->GetIntArrayElements(env, dialogHandle, 0); - - NavGetDefaultDialogCreationOptions(&options); - options.optionFlags |= optionFlags; - options.parentWindow= (WindowRef) whandle; - - status= RC(NavCreateGetFileDialog(&options, NULL, NULL, NULL, NULL, NULL, (NavDialogRef*)sa)); - - (*env)->ReleaseIntArrayElements(env, dialogHandle, sa, 0); - - return status; +#ifndef NO_NewHandle +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewHandle + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NewHandle\n") + + return (jint)NewHandle((Size)arg0); } +#endif /* NO_NewHandle */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavCreatePutFileDialog(JNIEnv *env, jclass zz, - jint fileCreator, jint windowTitle, jint whandle, jintArray dialogHandle, - jint optionFlags, jint fileType) { - - NavDialogCreationOptions options; - jint status; - jint *sa= (*env)->GetIntArrayElements(env, dialogHandle, 0); - - NavGetDefaultDialogCreationOptions(&options); - options.optionFlags |= optionFlags; - options.parentWindow= (WindowRef) whandle; - options.windowTitle= (CFStringRef) windowTitle; - - status= RC(NavCreatePutFileDialog(&options, fileType, fileCreator, NULL, NULL, (NavDialogRef*)sa)); - - (*env)->ReleaseIntArrayElements(env, dialogHandle, sa, 0); - - return status; +#ifndef NO_NewHandleClear +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewHandleClear + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NewHandleClear\n") + + return (jint)NewHandleClear((Size)arg0); } +#endif /* NO_NewHandleClear */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavCreateChooseFolderDialog(JNIEnv *env, jclass zz, - jint optionFlags, jint windowTitle, jint messageHandle, jint whandle, jintArray dialogHandle) { - - NavDialogCreationOptions options; - jint status; - jint *sa= (*env)->GetIntArrayElements(env, dialogHandle, 0); - - NavGetDefaultDialogCreationOptions(&options); - options.optionFlags |= optionFlags; - options.parentWindow= (WindowRef) whandle; - options.windowTitle= (CFStringRef) windowTitle; - options.message= (CFStringRef) messageHandle; - - status= RC(NavCreateChooseFolderDialog(&options, NULL, NULL, NULL, (NavDialogRef*)sa)); - - (*env)->ReleaseIntArrayElements(env, dialogHandle, sa, 0); - - return status; +#ifndef NO_NewPtr +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewPtr + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NewPtr\n") + + return (jint)NewPtr((Size)arg0); } +#endif /* NO_NewPtr */ + +#ifndef NO_NewPtrClear +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewPtrClear + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("NewPtrClear\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogSetSaveFileName(JNIEnv *env, jclass zz, - jint dialogHandle, jint fileName) { - return (jint) RC(NavDialogSetSaveFileName((NavDialogRef) dialogHandle, (CFStringRef) fileName)); + return (jint)NewPtrClear((Size)arg0); } +#endif /* NO_NewPtrClear */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogGetSaveFileName(JNIEnv *env, jclass zz, - jint dialogHandle) { - return (jint) NavDialogGetSaveFileName((NavDialogRef) dialogHandle); +#ifndef NO_NewRgn +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewRgn + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("NewRgn\n") + + return (jint)NewRgn(); } +#endif /* NO_NewRgn */ + +#ifndef NO_OffsetRect +JNIEXPORT void JNICALL OS_NATIVE(OffsetRect) + (JNIEnv *env, jclass that, jobject arg0, jshort arg1, jshort arg2) +{ + Rect _arg0, *lparg0=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogRun(JNIEnv *env, jclass zz, - jint dialogHandle) { - return (jint) RC(NavDialogRun((NavDialogRef) dialogHandle)); + DEBUG_CALL("OffsetRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + OffsetRect(lparg0, arg1, arg2); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif + +#ifndef NO_OffsetRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_OffsetRgn + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2) +{ + DEBUG_CALL("OffsetRgn\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogGetUserAction(JNIEnv *env, jclass zz, - jint dialogHandle) { - return (jint) RC(NavDialogGetUserAction((NavDialogRef) dialogHandle)); + OffsetRgn((RgnHandle)arg0, (short)arg1, (short)arg2); } +#endif /* NO_OffsetRgn */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogGetReply(JNIEnv *env, jclass zz, - jint dialogHandle, jintArray replyHandle) { - NavReplyRecord *reply= (NavReplyRecord*) malloc(sizeof(NavReplyRecord)); - jint *sa= (*env)->GetIntArrayElements(env, replyHandle, 0); - sa[0]= (jint) reply; - (*env)->ReleaseIntArrayElements(env, replyHandle, sa, 0); - return (jint) RC(NavDialogGetReply((NavDialogRef) dialogHandle, reply)); +#ifndef NO_OpenDataBrowserContainer +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_OpenDataBrowserContainer + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("OpenDataBrowserContainer\n") + + return (jint)OpenDataBrowserContainer((ControlRef)arg0, (DataBrowserItemID)arg1); } +#endif /* NO_OpenDataBrowserContainer */ + +#ifndef NO_OpenPoly +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_OpenPoly + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("OpenPoly\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogDisposeReply(JNIEnv *env, jclass zz, - jint replyHandle) { - free((NavReplyRecord*) replyHandle); + return (jint)OpenPoly(); } +#endif /* NO_OpenPoly */ + +#ifndef NO_PaintOval +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintOval + (JNIEnv *env, jclass that, jobject arg0) +{ + Rect _arg0, *lparg0=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavReplyRecordGetSelection(JNIEnv *env, jclass zz, - jint replyHandle) { - NavReplyRecord *reply= (NavReplyRecord*) replyHandle; - return (jint) &reply->selection; + DEBUG_CALL("PaintOval\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + PaintOval((const Rect *)lparg0); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_PaintOval */ + +#ifndef NO_PaintPoly +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintPoly + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("PaintPoly\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AECountItems(JNIEnv *env, jclass zz, - jint aeDescList, jintArray count) { - jint *sa= (*env)->GetIntArrayElements(env, count, 0); - int status= (jint) RC(AECountItems((const AEDescList*)aeDescList, (long*)sa)); - (*env)->ReleaseIntArrayElements(env, count, sa, 0); - return status; + PaintPoly((PolyHandle)arg0); } +#endif /* NO_PaintPoly */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AEGetNthPtr(JNIEnv *env, jclass zz, - jint aeDescList, jint index, jintArray sHandle) { - AEKeyword keyWord; - DescType returnedType; - FSRef fileSpec; - Size actualSize; - jint *sa= (*env)->GetIntArrayElements(env, sHandle, 0); - - jint status= RC(AEGetNthPtr((const AEDescList*)aeDescList, index, typeFSRef, &keyWord, &returnedType, - &fileSpec, sizeof(fileSpec), &actualSize)); +#ifndef NO_PaintRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintRect + (JNIEnv *env, jclass that, jobject arg0) +{ + Rect _arg0, *lparg0=NULL; - if (status == 0) { - CFURLRef url= CFURLCreateFromFSRef(kCFAllocatorDefault, &fileSpec); - sa[0]= (jint) CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); - } - - (*env)->ReleaseIntArrayElements(env, sHandle, sa, 0); - return status; + DEBUG_CALL("PaintRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + PaintRect((const Rect *)lparg0); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_PaintRect */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_NavDialogDispose(JNIEnv *env, jclass zz, - jint dialogHandle) { - NavDialogDispose((NavDialogRef) dialogHandle); +#ifndef NO_PaintRoundRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PaintRoundRect + (JNIEnv *env, jclass that, jobject arg0, jshort arg1, jshort arg2) +{ + Rect _arg0, *lparg0=NULL; + + DEBUG_CALL("PaintRoundRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + PaintRoundRect((const Rect *)lparg0, (short)arg1, (short)arg2); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_PaintRoundRect */ -// Strings +#ifndef NO_PenSize +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_PenSize + (JNIEnv *env, jclass that, jshort arg0, jshort arg1) +{ + DEBUG_CALL("PenSize\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringCreateWithCharacters(JNIEnv *env, jclass zz, jstring s) { - const jchar *buffer= (*env)->GetStringChars(env, s, NULL); - CFIndex length= (*env)->GetStringLength(env, s); - CFStringRef sref= CFStringCreateWithCharacters(NULL, (const UniChar*) buffer, length); - (*env)->ReleaseStringChars(env, s, buffer); - return (jint) sref; + PenSize((short)arg0, (short)arg1); } +#endif /* NO_PenSize */ + +#ifndef NO_PickColor +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PickColor + (JNIEnv *env, jclass that, jobject arg0) +{ + ColorPickerInfo _arg0, *lparg0=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFRelease(JNIEnv *env, jclass zz, jint sHandle) { - CFRelease((CFStringRef)sHandle); + DEBUG_CALL("PickColor\n") + + if (arg0) lparg0 = getColorPickerInfoFields(env, arg0, &_arg0); + rc = (jint)PickColor((ColorPickerInfo *)lparg0); + if (arg0) setColorPickerInfoFields(env, arg0, lparg0); + return rc; } +#endif /* NO_PickColor */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringGetLength(JNIEnv *env, jclass zz, jint sHandle) { - return (jint) CFStringGetLength((CFStringRef)sHandle); +#ifndef NO_PopUpMenuSelect +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PopUpMenuSelect + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2, jshort arg3) +{ + DEBUG_CALL("PopUpMenuSelect\n") + + return (jint)PopUpMenuSelect((MenuRef)arg0, (short)arg1, (short)arg2, (short)arg3); } +#endif /* NO_PopUpMenuSelect */ + +#ifndef NO_PostEvent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PostEvent + (JNIEnv *env, jclass that, jshort arg0, jint arg1) +{ + DEBUG_CALL("PostEvent\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFStringGetCharacters(JNIEnv *env, jclass zz, - jint sHandle, jint start, jint length, jcharArray buffer) { - jchar *sa= (*env)->GetCharArrayElements(env, buffer, 0); - CFStringGetCharacters((CFStringRef)sHandle, CFRangeMake(start, length), (UniChar*) sa); - (*env)->ReleaseShortArrayElements(env, buffer, sa, 0); + return (jint)PostEvent((EventKind)arg0, (UInt32)arg1); } +#endif /* NO_PostEvent */ -//---- Alerts +#ifndef NO_PostEventToQueue +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PostEventToQueue + (JNIEnv *env, jclass that, jint arg0, jint arg1, jshort arg2) +{ + DEBUG_CALL("PostEventToQueue\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateStandardAlert(JNIEnv *env, jclass zz, - jshort alertType, jint messageHandle, jint explanationHandle, jint param, jintArray dialogHandle) { - - jint *sa= (*env)->GetIntArrayElements(env, dialogHandle, 0); - jint status= RC(CreateStandardAlert((AlertType)alertType, (CFStringRef)messageHandle, (CFStringRef)explanationHandle, - (const AlertStdCFStringAlertParamRec*) param, (DialogRef*)sa)); - (*env)->ReleaseIntArrayElements(env, dialogHandle, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RunStandardAlert(JNIEnv *env, jclass zz, - jint alertHandle, jint filterProc, jshortArray itemHit) { - jshort *sa= (*env)->GetShortArrayElements(env, itemHit, 0); - jint status= (jint) RC(RunStandardAlert((DialogRef)alertHandle, (ModalFilterUPP)filterProc, (DialogItemIndex*)sa)); - (*env)->ReleaseShortArrayElements(env, itemHit, sa, 0); - return status; -} - -//---- MLTE Text - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNInitTextension(JNIEnv *env, jclass zz) { - return (jint) RC(TXNInitTextension(NULL, 0, 0)); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNNewObject(JNIEnv *env, jclass zz, - jint fileSpec, jint wHandle, jshortArray bounds, jint frameOptions, jint frameType, jint fileType, - jint permanentEncoding, jintArray txHandle, jintArray frameID, jint refcon) { - - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - jint *sb= (*env)->GetIntArrayElements(env, txHandle, 0); - jint *sc= (*env)->GetIntArrayElements(env, frameID, 0); - - jint status= (jint) RC(TXNNewObject((const FSSpec*)fileSpec, (WindowRef)wHandle, (Rect*)bounds, (TXNFrameOptions)frameOptions, - (TXNFrameType)frameType, (TXNFileType)fileType, (TXNPermanentTextEncodingType)permanentEncoding, - (TXNObject*)sb, (TXNFrameID*)sc, (TXNObjectRefcon)refcon)); - - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); - (*env)->ReleaseIntArrayElements(env, txHandle, sb, 0); - (*env)->ReleaseIntArrayElements(env, frameID, sc, 0); - - return status; + return (jint)PostEventToQueue((EventQueueRef)arg0, (EventRef)arg1, (EventPriority)arg2); } +#endif /* NO_PostEventToQueue */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNDeleteObject(JNIEnv *env, jclass zz, jint txHandle) { - TXNDeleteObject((TXNObject)txHandle); +#ifndef NO_PtInRect +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_PtInRect + (JNIEnv *env, jclass that, jobject arg0, jobject arg1) +{ + Point _arg0, *lparg0=NULL; + Rect _arg1, *lparg1=NULL; + jboolean rc; + + DEBUG_CALL("PtInRect\n") + + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + rc = (jboolean)PtInRect((Point)*lparg0, (const Rect *)lparg1); + if (arg0) setPointFields(env, arg0, lparg0); + if (arg1) setRectFields(env, arg1, lparg1); + return rc; } +#endif /* NO_PtInRect */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetFrameBounds(JNIEnv *env, jclass zz, - jint txHandle, jint top, jint left, jint bottom, jint right, jint frameID) { - TXNSetFrameBounds((TXNObject)txHandle, top, left, bottom, right, (TXNFrameID) frameID); +#ifndef NO_PtInRgn +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_PtInRgn + (JNIEnv *env, jclass that, jobject arg0, jint arg1) +{ + Point _arg0, *lparg0=NULL; + jboolean rc; + + DEBUG_CALL("PtInRgn\n") + + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + rc = (jboolean)PtInRgn((Point)*lparg0, (RgnHandle)arg1); + if (arg0) setPointFields(env, arg0, lparg0); + return rc; } +#endif /* NO_PtInRgn */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNDraw(JNIEnv *env, jclass zz, jint txHandle, jint gDevice) { - TXNDraw((TXNObject)txHandle, (GWorldPtr)gDevice); +#ifndef NO_PutScrapFlavor +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PutScrapFlavor + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4) +{ + jbyte *lparg4=NULL; + jint rc; + + DEBUG_CALL("PutScrapFlavor\n") + + if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL); + rc = (jint)PutScrapFlavor((ScrapRef)arg0, (ScrapFlavorType)arg1, (ScrapFlavorFlags)arg2, (Size)arg3, (const void *)lparg4); + if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_PutScrapFlavor */ + +#ifndef NO_QDBeginCGContext +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDBeginCGContext + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("QDBeginCGContext\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetData(JNIEnv *env, jclass zz, - jint txHandle, jint startOffset, jint endOffset, jintArray dataHandle) { - jint *sa= (*env)->GetIntArrayElements(env, dataHandle, 0); - jint status= (jint) RC(TXNGetData((TXNObject)txHandle, startOffset, endOffset, (Handle*)sa)); - (*env)->ReleaseIntArrayElements(env, dataHandle, sa, 0); - return status; + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)QDBeginCGContext((CGrafPtr)arg0, (CGContextRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_QDBeginCGContext */ + +#ifndef NO_QDEndCGContext +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDEndCGContext + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("QDEndCGContext\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewHandle(JNIEnv *env, jclass zz, jint size) { - return (jint) NewHandle(size); + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)QDEndCGContext((CGrafPtr)arg0, (CGContextRef *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; } +#endif /* NO_QDEndCGContext */ + +#ifndef NO_QDFlushPortBuffer +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDFlushPortBuffer + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("QDFlushPortBuffer\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewHandleClear(JNIEnv *env, jclass zz, jint size) { - return (jint) NewHandleClear(size); + QDFlushPortBuffer((CGrafPtr)arg0, (RgnHandle)arg1); } +#endif /* NO_QDFlushPortBuffer */ + +#ifndef NO_QDGlobalToLocalPoint +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDGlobalToLocalPoint + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Point _arg1, *lparg1=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeHandle(JNIEnv *env, jclass zz, jint handle) { - DisposeHandle((Handle)handle); + DEBUG_CALL("QDGlobalToLocalPoint\n") + + if (arg1) lparg1 = getPointFields(env, arg1, &_arg1); + QDGlobalToLocalPoint((CGrafPtr)arg0, (Point *)lparg1); + if (arg1) setPointFields(env, arg1, lparg1); } +#endif /* NO_QDGlobalToLocalPoint */ + +#ifndef NO_QDLocalToGlobalPoint +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDLocalToGlobalPoint + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Point _arg1, *lparg1=NULL; + + DEBUG_CALL("QDLocalToGlobalPoint\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetHandleSize(JNIEnv *env, jclass zz, jint handle) { - return GetHandleSize((Handle)handle); + if (arg1) lparg1 = getPointFields(env, arg1, &_arg1); + QDLocalToGlobalPoint((CGrafPtr)arg0, (Point *)lparg1); + if (arg1) setPointFields(env, arg1, lparg1); } +#endif /* NO_QDLocalToGlobalPoint */ + +#ifndef NO_QDSetPatternOrigin +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDSetPatternOrigin + (JNIEnv *env, jclass that, jobject arg0) +{ + Point _arg0, *lparg0=NULL; + + DEBUG_CALL("QDSetPatternOrigin\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DerefHandle(JNIEnv *env, jclass zz, jint handle) { - Handle h= (Handle) handle; - return (jint) *h; + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + QDSetPatternOrigin((Point)*lparg0); + if (arg0) setPointFields(env, arg0, lparg0); } +#endif /* NO_QDSetPatternOrigin */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewPtr(JNIEnv *env, jclass zz, jint size) { - return (jint) NewPtr(size); +#ifndef NO_QDSwapTextFlags +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDSwapTextFlags + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("QDSwapTextFlags\n") + + return (jint)QDSwapTextFlags((UInt32)arg0); } +#endif /* NO_QDSwapTextFlags */ + +#ifndef NO_RGBBackColor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_RGBBackColor + (JNIEnv *env, jclass that, jobject arg0) +{ + RGBColor _arg0, *lparg0=NULL; + + DEBUG_CALL("RGBBackColor\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewPtrClear(JNIEnv *env, jclass zz, jint size) { - return (jint) NewPtrClear(size); + if (arg0) lparg0 = getRGBColorFields(env, arg0, &_arg0); + RGBBackColor((const RGBColor *)lparg0); + if (arg0) setRGBColorFields(env, arg0, lparg0); } +#endif /* NO_RGBBackColor */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposePtr(JNIEnv *env, jclass zz, jint ptr) { - DisposePtr((void*)ptr); +#ifndef NO_RGBForeColor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_RGBForeColor + (JNIEnv *env, jclass that, jobject arg0) +{ + RGBColor _arg0, *lparg0=NULL; + + DEBUG_CALL("RGBForeColor\n") + + if (arg0) lparg0 = getRGBColorFields(env, arg0, &_arg0); + RGBForeColor((const RGBColor *)lparg0); + if (arg0) setRGBColorFields(env, arg0, lparg0); } +#endif /* NO_RGBForeColor */ + +#ifndef NO_ReceiveNextEvent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ReceiveNextEvent + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jdouble arg2, jboolean arg3, jintArray arg4) +{ + jint *lparg1=NULL; + jint *lparg4=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPtrSize(JNIEnv *env, jclass zz, jint ptr) { - return (jint) GetPtrSize((void*)ptr); + DEBUG_CALL("ReceiveNextEvent\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)ReceiveNextEvent((UInt32)arg0, (const EventTypeSpec *)lparg1, (EventTimeout)arg2, (Boolean)arg3, (EventRef *)lparg4); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_ReceiveNextEvent */ -/* -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_MemError(JNIEnv *env, jclass zz) { - return (jint) MemError(); +#ifndef NO_RectInRgn +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_RectInRgn + (JNIEnv *env, jclass that, jobject arg0, jint arg1) +{ + Rect _arg0, *lparg0=NULL; + jboolean rc; + + DEBUG_CALL("RectInRgn\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + rc = (jboolean)RectInRgn((const Rect *)lparg0, (RgnHandle)arg1); + if (arg0) setRectFields(env, arg0, lparg0); + return rc; } -*/ +#endif /* NO_RectInRgn */ + +#ifndef NO_RectRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_RectRgn + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("RectRgn\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_getHandleData__I_3C(JNIEnv *env, jclass zz, - jint hndl, jcharArray data) { - Handle handle= (Handle)hndl; - jchar *sa= (*env)->GetCharArrayElements(env, data, 0); - int length= (*env)->GetArrayLength(env, data); - memcpy(sa, *handle, length*sizeof(jchar)); - (*env)->ReleaseCharArrayElements(env, data, sa, 0); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + RectRgn((RgnHandle)arg0, (const Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_RectRgn */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_getHandleData__I_3I(JNIEnv *env, jclass zz, - jint hndl, jintArray data) { - Handle handle= (Handle)hndl; - jint *sa= (*env)->GetIntArrayElements(env, data, 0); - int length= (*env)->GetArrayLength(env, data); - memcpy(sa, *handle, length*sizeof(jint)); - (*env)->ReleaseIntArrayElements(env, data, sa, 0); +#ifndef NO_RegisterAppearanceClient +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RegisterAppearanceClient + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("RegisterAppearanceClient\n") + + return (jint)RegisterAppearanceClient(); } +#endif /* NO_RegisterAppearanceClient */ -// mem functions +#ifndef NO_ReleaseEvent +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ReleaseEvent + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("ReleaseEvent\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__III(JNIEnv *env, jclass zz, - jint dest, jint src, jint n) { - memcpy((void*)dest, (const void*)src, (size_t)n); + ReleaseEvent((EventRef)arg0); } +#endif /* NO_ReleaseEvent */ + +#ifndef NO_ReleaseMenu +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ReleaseMenu + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("ReleaseMenu\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__I_3BI(JNIEnv *env, jclass zz, - jint dest, jbyteArray src, jint n) { - jbyte *sa= (*env)->GetByteArrayElements(env, src, 0); - memcpy((void*)dest, (const void*)sa, (size_t)n); - (*env)->ReleaseByteArrayElements(env, src, sa, 0); + return (jint)ReleaseMenu((MenuRef)arg0); } +#endif /* NO_ReleaseMenu */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy___3BII(JNIEnv *env, jclass zz, - jbyteArray dest, jint src, jint n) { - jbyte *sa= (*env)->GetByteArrayElements(env, dest, 0); - memcpy((void*)sa, (const void*)src, (size_t)n); - (*env)->ReleaseByteArrayElements(env, dest, sa, 0); +#ifndef NO_ReleaseWindowGroup +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ReleaseWindowGroup + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("ReleaseWindowGroup\n") + + return (jint)ReleaseWindowGroup((WindowGroupRef)arg0); } +#endif + +#ifndef NO_RemoveControlProperty +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveControlProperty + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("RemoveControlProperty\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memset(JNIEnv *env, jclass zz, - jint dest, jint value, jint size) { - memset((void*)dest, (int)value, (size_t)size); + return (jint)RemoveControlProperty((ControlRef)arg0, arg1, arg2); } +#endif + +#ifndef NO_RemoveDataBrowserItems +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveDataBrowserItems + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4) +{ + jint *lparg3=NULL; + jint rc; -//////////////////////////// + DEBUG_CALL("RemoveDataBrowserItems\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetData(JNIEnv *env, jclass zz, - jint txHandle, jcharArray unicodeChars, jint startOffset, jint endOffset) { - jchar *sa= (*env)->GetCharArrayElements(env, unicodeChars, 0); - jsize length= (*env)->GetArrayLength(env, unicodeChars); - jint status= (jint) RC(TXNSetData((TXNObject)txHandle, kTXNUnicodeTextData, (void*) sa, length*sizeof(jchar), startOffset, endOffset)); - (*env)->ReleaseCharArrayElements(env, unicodeChars, sa, 0); - return status; + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)RemoveDataBrowserItems((ControlRef)arg0, (DataBrowserItemID)arg1, (UInt32)arg2, (const DataBrowserItemID *)lparg3, (DataBrowserPropertyID)arg4); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_RemoveDataBrowserItems */ + +#ifndef NO_RemoveDataBrowserTableViewColumn +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveDataBrowserTableViewColumn + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("RemoveDataBrowserTableViewColumn\n") + + return (jint)RemoveDataBrowserTableViewColumn((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1); -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetLineCount(JNIEnv *env, jclass zz, - jint txHandle, jintArray lineCount) { - jint *sa= (*env)->GetIntArrayElements(env, lineCount, 0); - jint status= (jint) RC(TXNGetLineCount((TXNObject)txHandle, (ItemCount*) sa)); - (*env)->ReleaseIntArrayElements(env, lineCount, sa, 0); - return status; } +#endif /* NO_RemoveDataBrowserTableViewColumn */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNDataSize(JNIEnv *env, jclass zz, jint txHandle) { - return (jint) TXNDataSize((TXNObject)txHandle); +#ifndef NO_RemoveEventHandler +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveEventHandler + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("RemoveEventHandler\n") + + return (jint)RemoveEventHandler((EventHandlerRef)arg0); } +#endif + +#ifndef NO_RemoveEventLoopTimer +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveEventLoopTimer + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("RemoveEventLoopTimer\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetSelection(JNIEnv *env, jclass zz, - jint txHandle, jintArray start, jintArray end) { - jint *sa= (*env)->GetIntArrayElements(env, start, 0); - jint *sb= (*env)->GetIntArrayElements(env, end, 0); - TXNGetSelection((TXNObject)txHandle, (TXNOffset*)sa, (TXNOffset*)sb); - (*env)->ReleaseIntArrayElements(env, start, sa, 0); - (*env)->ReleaseIntArrayElements(env, end, sb, 0); + return (jint)RemoveEventLoopTimer((EventLoopTimerRef)arg0); } +#endif /* NO_RemoveEventLoopTimer */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetSelection(JNIEnv *env, jclass zz, - jint txHandle, jint start, jint end) { - return (jint) RC(TXNSetSelection((TXNObject)txHandle, (TXNOffset)start, (TXNOffset)end)); +#ifndef NO_RepositionWindow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RepositionWindow + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("RepositionWindow\n") + + return (jint)RepositionWindow((WindowRef)arg0, (WindowRef)arg1, arg2); } +#endif + +#ifndef NO_RetainMenu +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RetainMenu + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("RetainMenu\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSelectAll(JNIEnv *env, jclass zz, jint txHandle) { - TXNSelectAll((TXNObject)txHandle); + return (jint)RetainMenu((MenuRef)arg0); } +#endif /* NO_RetainMenu */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNShowSelection(JNIEnv *env, jclass zz, - jint txHandle, jboolean showEnd) { - TXNShowSelection((TXNObject)txHandle, (Boolean)showEnd); +#ifndef NO_RevealDataBrowserItem +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RevealDataBrowserItem + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyte arg3) +{ + DEBUG_CALL("RevealDataBrowserItem\n") + + return (jint)RevealDataBrowserItem((ControlRef)arg0, (DataBrowserItemID)arg1, (DataBrowserPropertyID)arg2, (DataBrowserRevealOptions)arg3); } +#endif /* NO_RevealDataBrowserItem */ + +#ifndef NO_RunStandardAlert +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RunStandardAlert + (JNIEnv *env, jclass that, jint arg0, jint arg1, jshortArray arg2) +{ + jshort *lparg2=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNKeyDown(JNIEnv *env, jclass zz, - jint txHandle, jintArray eventData) { - EventRecord event; - copyEventData(env, &event, eventData); - TXNKeyDown((TXNObject)txHandle, &event); + DEBUG_CALL("RunStandardAlert\n") + + if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL); + rc = (jint)RunStandardAlert((DialogRef)arg0, (ModalFilterUPP)arg1, (DialogItemIndex *)lparg2); + if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0); + return rc; } +#endif /* NO_RunStandardAlert */ + +#ifndef NO_ScrollRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ScrollRect + (JNIEnv *env, jclass that, jobject arg0, jshort arg1, jshort arg2, jint arg3) +{ + Rect _arg0, *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNClick(JNIEnv *env, jclass zz, - jint txHandle, jintArray eventData) { - EventRecord event; - copyEventData(env, &event, eventData); - TXNClick((TXNObject)txHandle, &event); + DEBUG_CALL("ScrollRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + ScrollRect((const Rect *)lparg0, (short)arg1, (short)arg2, (RgnHandle)arg3); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif /* NO_ScrollRect */ + +#ifndef NO_SectRect +JNIEXPORT jboolean JNICALL OS_NATIVE(SectRect) + (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jobject arg2) +{ + Rect _arg0, *lparg0=NULL; + Rect _arg1, *lparg1=NULL; + Rect _arg2, *lparg2=NULL; + jboolean rc; + + DEBUG_CALL("SectRect\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNFocus(JNIEnv *env, jclass zz, - jint txHandle, jboolean becomingFocused) { - TXNFocus((TXNObject)txHandle, (Boolean)becomingFocused); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + rc = (jboolean)SectRect(lparg0, lparg1, lparg2); + if (arg0) setRectFields(env, arg0, lparg0); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) setRectFields(env, arg2, lparg2); + return rc; } +#endif + +#ifndef NO_SectRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SectRgn + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("SectRgn\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNCut(JNIEnv *env, jclass zz, jint txHandle) { - return (jint) RC(TXNCut((TXNObject)txHandle)); + SectRgn((RgnHandle)arg0, (RgnHandle)arg1, (RgnHandle)arg2); } +#endif /* NO_SectRgn */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNCopy(JNIEnv *env, jclass zz, jint txHandle) { - return (jint) RC(TXNCopy((TXNObject)txHandle)); +#ifndef NO_SelectWindow +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SelectWindow + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SelectWindow\n") + + SelectWindow((WindowRef)arg0); } +#endif /* NO_SelectWindow */ + +#ifndef NO_SendBehind +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SendBehind + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SendBehind\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNPaste(JNIEnv *env, jclass zz, jint txHandle) { - return (jint) RC(TXNPaste((TXNObject)txHandle)); + SendBehind((WindowRef)arg0, (WindowRef)arg1); } +#endif + +#ifndef NO_SendEventToEventTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SendEventToEventTarget + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SendEventToEventTarget\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetRectBounds(JNIEnv *env, jclass zz, - jint txHandle, jshortArray viewRect, jintArray destRect, jintArray textRect) { - jshort *sa= NULL; - jint *sb= NULL; - jint *sc= NULL; - jint status; - if (viewRect != NULL) - sa= (*env)->GetShortArrayElements(env, viewRect, 0); - if (destRect != NULL) - sb= (*env)->GetIntArrayElements(env, destRect, 0); - if (textRect != NULL) - sc= (*env)->GetIntArrayElements(env, textRect, 0); - status= (jint) RC(TXNGetRectBounds((TXNObject)txHandle, (Rect*)sa, (TXNLongRect*)sb, (TXNLongRect*)sc)); - if (sa != NULL) - (*env)->ReleaseShortArrayElements(env, viewRect, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, destRect, sb, 0); - if (sc != NULL) - (*env)->ReleaseIntArrayElements(env, textRect, sc, 0); - return status; + return (jint)SendEventToEventTarget((EventRef)arg0, (EventTargetRef)arg1); } +#endif /* NO_SendEventToEventTarget */ + +#ifndef NO_SetBevelButtonContentInfo +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetBevelButtonContentInfo + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + ControlButtonContentInfo _arg1, *lparg1=NULL; + jint rc; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetRectBounds(JNIEnv *env, jclass zz, - jint txHandle, jshortArray viewRect, jintArray destRect, jboolean update) { - jshort *sa= NULL; - jint *sb= NULL; - if (viewRect != NULL) - sa= (*env)->GetShortArrayElements(env, viewRect, 0); - if (destRect != NULL) - sb= (*env)->GetIntArrayElements(env, destRect, 0); - TXNSetRectBounds((TXNObject)txHandle, (Rect*)sa, (TXNLongRect*)sb, update); - if (sa != NULL) - (*env)->ReleaseShortArrayElements(env, viewRect, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, destRect, sb, 0); + DEBUG_CALL("SetBevelButtonContentInfo\n") + + if (arg1) lparg1 = getControlButtonContentInfoFields(env, arg1, &_arg1); + rc = (jint)SetBevelButtonContentInfo((ControlRef)arg0, (ControlButtonContentInfoPtr)lparg1); + if (arg1) setControlButtonContentInfoFields(env, arg1, lparg1); + return rc; } +#endif /* NO_SetBevelButtonContentInfo */ + +#ifndef NO_SetClip +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetClip + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SetClip\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNActivate(JNIEnv *env, jclass zz, - jint txHandle, jint frameID, jboolean scrollBarState) { - return (jint) RC(TXNActivate((TXNObject)txHandle, (TXNFrameID)frameID, (TXNScrollBarState)scrollBarState)); + SetClip((RgnHandle)arg0); } +#endif /* NO_SetClip */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNEchoMode(JNIEnv *env, jclass zz, - jint txHandle, jchar echoCharacter, jint encoding, jboolean on) { - return (jint) RC(TXNEchoMode((TXNObject)txHandle, echoCharacter, encoding, on)); +#ifndef NO_SetControl32BitMaximum +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControl32BitMaximum + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControl32BitMaximum\n") + + SetControl32BitMaximum((ControlRef)arg0, (SInt32)arg1); } +#endif /* NO_SetControl32BitMaximum */ + +#ifndef NO_SetControl32BitMinimum +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControl32BitMinimum + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControl32BitMinimum\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNOffsetToPoint(JNIEnv *env, jclass zz, - jint txHandle, jint offset, jshortArray location) { - jshort *sa= (*env)->GetShortArrayElements(env, location, 0); - jint status= (jint) RC(TXNOffsetToPoint((TXNObject)txHandle, offset, (Point*) sa)); - (*env)->ReleaseShortArrayElements(env, location, sa, 0); - return status; + SetControl32BitMinimum((ControlRef)arg0, (SInt32)arg1); } +#endif /* NO_SetControl32BitMinimum */ + +#ifndef NO_SetControl32BitValue +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControl32BitValue + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControl32BitValue\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNResizeFrame(JNIEnv *env, jclass zz, - jint txHandle, jint width, jint height, jint frameID) { - TXNResizeFrame((TXNObject)txHandle, width, height, frameID); + SetControl32BitValue((ControlRef)arg0, (SInt32)arg1); } +#endif /* NO_SetControl32BitValue */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetViewRect(JNIEnv *env, jclass zz, - jint txHandle, jshortArray viewRect) { - jshort *sa= (*env)->GetShortArrayElements(env, viewRect, 0); - TXNGetViewRect((TXNObject)txHandle, (Rect*) sa); - (*env)->ReleaseShortArrayElements(env, viewRect, sa, 0); +#ifndef NO_SetControlAction +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlAction + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControlAction\n") + + SetControlAction((ControlRef)arg0, (ControlActionUPP)arg1); } +#endif /* NO_SetControlAction */ + +#ifndef NO_SetControlBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetLineMetrics(JNIEnv *env, jclass zz, - jint txHandle, jint lineNumber, jintArray lineWidth, jintArray lineHeight) { - jint *sa= (*env)->GetIntArrayElements(env, lineWidth, 0); - jint *sb= (*env)->GetIntArrayElements(env, lineHeight, 0); - jint status= (jint) RC(TXNGetLineMetrics((TXNObject)txHandle, (UInt32)lineNumber, (Fixed*)sa, (Fixed*)sb)); - (*env)->ReleaseIntArrayElements(env, lineWidth, sa, 0); - (*env)->ReleaseIntArrayElements(env, lineHeight, sb, 0); - return status; + DEBUG_CALL("SetControlBounds\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + SetControlBounds((ControlRef)arg0, (const Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_SetControlBounds */ + +#ifndef NO_SetControlData__IIIILorg_eclipse_swt_internal_carbon_Rect_2 +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__IIIILorg_eclipse_swt_internal_carbon_Rect_2 + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4) +{ + Rect _arg4, *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetControlData__IIIILorg_eclipse_swt_internal_carbon_Rect_2\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNForceUpdate(JNIEnv *env, jclass zz, jint txHandle) { - TXNForceUpdate((TXNObject)txHandle); + if (arg4) lparg4 = getRectFields(env, arg4, &_arg4); + rc = (jint)SetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (const void *)lparg4); + if (arg4) setRectFields(env, arg4, lparg4); + return rc; } +#endif /* NO_SetControlData__IIIILorg_eclipse_swt_internal_carbon_Rect_2 */ -/* -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_setTXNWordWrap(JNIEnv *env, jclass zz, - jint txHandle, jboolean wrap) { - TXNControlTag controlTag[1]; - TXNControlData controlData[1]; - controlTag[0]= kTXNWordWrapStateTag; - controlData[0].uValue= wrap ? kTXNAutoWrap : kTXNNoAutoWrap; - TXNSetTXNObjectControls((TXNObject)txHandle, false, 1, controlTag, controlData); -} -*/ - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_setTXNMargins(JNIEnv *env, jclass zz, - jint txHandle, jshort margin) { - TXNControlTag controlTag[1]; - TXNControlData controlData[1]; - TXNMargins m; - m.topMargin= margin; - m.leftMargin= margin; - m.bottomMargin= margin; - m.rightMargin= margin; - controlTag[0]= kTXNMarginsTag; - controlData[0].marginsPtr= &m; - TXNSetTXNObjectControls((TXNObject)txHandle, false, 1, controlTag, controlData); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetTXNObjectControls(JNIEnv *env, jclass zz, - jint txHandle, jboolean clearAll, jint controlCount, jintArray controlTags, jintArray controlData) { - jint *sa= (*env)->GetIntArrayElements(env, controlTags, 0); - jint *sb= (*env)->GetIntArrayElements(env, controlData, 0); - jint status= RC(TXNSetTXNObjectControls((TXNObject)txHandle, (Boolean)clearAll, (ItemCount) controlCount, - (TXNControlTag*)sa, (TXNControlData*)sb)); - (*env)->ReleaseIntArrayElements(env, controlTags, sa, 0); - (*env)->ReleaseIntArrayElements(env, controlData, sb, 0); - return status; -} - -//---- Scrap - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentScrap(JNIEnv *env, jclass zz, jintArray scrapref) { - jint *sa= (*env)->GetIntArrayElements(env, scrapref, 0); - jint status= RC(GetCurrentScrap((ScrapRef*)sa)); - (*env)->ReleaseIntArrayElements(env, scrapref, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClearCurrentScrap(JNIEnv *env, jclass zz) { - return (jint) RC(ClearCurrentScrap()); -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorSize(JNIEnv *env, jclass zz, - jint scrapHandle, jint flavorType, jintArray sizeRef) { - jint *sa= (*env)->GetIntArrayElements(env, sizeRef, 0); - jint status= RC(GetScrapFlavorSize((ScrapRef)scrapHandle, (ScrapFlavorType) flavorType, (Size*)sa)); - (*env)->ReleaseIntArrayElements(env, sizeRef, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorData(JNIEnv *env, jclass zz, - jint scrapHandle, jint flavorType, jintArray sizeRef, jbyteArray data) { - jint status; - jint *sa= NULL; - jbyte *sb= NULL; - if (sizeRef != NULL) - sa= (*env)->GetIntArrayElements(env, sizeRef, 0); - if (data != NULL) - sb= (*env)->GetByteArrayElements(env, data, 0); - status= RC(GetScrapFlavorData((ScrapRef)scrapHandle, (ScrapFlavorType) flavorType, (Size*)sa, (void*)sb)); - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, sizeRef, sa, 0); - if (sb != NULL) - (*env)->ReleaseByteArrayElements(env, data, sb, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_PutScrapFlavor(JNIEnv *env, jclass zz, - jint scrapHandle, jint flavorType, jint flavorFlags, jbyteArray flavorData) { - jint status; - jbyte *sa= NULL; - int size= 0; - if (flavorData != NULL) { - size= (*env)->GetArrayLength(env, flavorData); - sa= (*env)->GetByteArrayElements(env, flavorData, 0); - } - status= RC(PutScrapFlavor((ScrapRef)scrapHandle, (ScrapFlavorType) flavorType, (ScrapFlavorFlags) flavorFlags, - size, (const void*)sa)); - if (sa != NULL) - (*env)->ReleaseByteArrayElements(env, flavorData, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorCount(JNIEnv *env, jclass zz, - jint scrapHandle, jintArray infoCount) { - jint *sa= (*env)->GetIntArrayElements(env, infoCount, 0); - jint status= RC(GetScrapFlavorCount((ScrapRef)scrapHandle, (UInt32*)sa)); - (*env)->ReleaseIntArrayElements(env, infoCount, sa, 0); - return status; -} - -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetScrapFlavorInfoList(JNIEnv *env, jclass zz, - jint scrapHandle, jintArray infoCount, jintArray info) { - jint status; - jint *sa= NULL; - jint *sb= NULL; - if (infoCount != NULL) - sa= (*env)->GetIntArrayElements(env, infoCount, 0); - if (info != NULL) - sb= (*env)->GetIntArrayElements(env, info, 0); - - status= RC(GetScrapFlavorInfoList((ScrapRef)scrapHandle, (UInt32*) sa, (ScrapFlavorInfo*) sb)); - if (sa != NULL) - (*env)->ReleaseIntArrayElements(env, infoCount, sa, 0); - if (sb != NULL) - (*env)->ReleaseIntArrayElements(env, info, sb, 0); - return status; -} - -//---- Misc ------------------------------------------ - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_Init(JNIEnv *env, jclass zz) { - // workaround for Register problem - Rect bounds= {}; - ControlRef ctl; - CreatePushButtonControl(NULL, &bounds, NULL, &ctl); - DisposeControl(ctl); -} - -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InitCursor(JNIEnv *env, jclass zz) { - InitCursor(); +#ifndef NO_SetControlData__IIII_3I +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__IIII_3I + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4) +{ + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetControlData__IIII_3I\n") + + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)SetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (const void *)lparg4); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_SetControlData__IIII_3I */ + +#ifndef NO_SetControlData__IIIII +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__IIIII + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4) +{ + DEBUG_CALL("SetControlData__IIIII\n") -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_HiWord(JNIEnv *env, jclass zz, jint i) { - return HiWord(i); + return (jint)SetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (const void *)arg4); } +#endif /* NO_SetControlData__IIIII */ -JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_LoWord(JNIEnv *env, jclass zz, jint i) { - return LoWord(i); +#ifndef NO_SetControlData__IIII_3S +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__IIII_3S + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jshortArray arg4) +{ + jshort *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetControlData__IIII_3S\n") + + if (arg4) lparg4 = (*env)->GetShortArrayElements(env, arg4, NULL); + rc = (jint)SetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (const void *)lparg4); + if (arg4) (*env)->ReleaseShortArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_SetControlData__IIII_3S */ -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SysBeep(JNIEnv *env, jclass zz, jshort duration) { - SysBeep((short)duration); +#ifndef NO_SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlTabInfoRecV1_2 +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlTabInfoRecV1_2 + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4) +{ + ControlTabInfoRecV1 _arg4, *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlTabInfoRecV1_2\n") + + if (arg4) lparg4 = getControlTabInfoRecV1Fields(env, arg4, &_arg4); + rc = (jint)SetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (const void *)lparg4); + if (arg4) setControlTabInfoRecV1Fields(env, arg4, lparg4); + return rc; } +#endif /* NO_SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlTabInfoRecV1_2 */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDblTime(JNIEnv *env, jclass zz) { - return GetDblTime(); +#ifndef NO_SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlButtonContentInfo_2 +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlButtonContentInfo_2 + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4) +{ + ControlButtonContentInfo _arg4, *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlButtonContentInfo_2\n") + + if (arg4) lparg4 = getControlButtonContentInfoFields(env, arg4, &_arg4); + rc = (jint)SetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (const void *)lparg4); + if (arg4) setControlButtonContentInfoFields(env, arg4, lparg4); + return rc; } +#endif /* NO_SetControlData__IIIILorg_eclipse_swt_internal_carbon_ControlButtonContentInfo_2 */ + +#ifndef NO_SetControlData__IIII_3B +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlData__IIII_3B + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4) +{ + jbyte *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetControlData__IIII_3B\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCaretTime(JNIEnv *env, jclass zz) { - return GetCaretTime(); + if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL); + rc = (jint)SetControlData((ControlRef)arg0, (ControlPartCode)arg1, (ResType)arg2, (Size)arg3, (const void *)lparg4); + if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_SetControlData__IIII_3B */ + +#ifndef NO_SetControlFontStyle +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlFontStyle + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + ControlFontStyleRec _arg1, *lparg1=NULL; + jint rc; + + DEBUG_CALL("SetControlFontStyle\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetAvailableWindowPositioningBounds(JNIEnv *env, - jclass zz, jint gHandle, jshortArray bounds) { - jshort *sa= (*env)->GetShortArrayElements(env, bounds, 0); - jint rc= RC(GetAvailableWindowPositioningBounds((GDHandle) gHandle, (Rect*)sa)); - (*env)->ReleaseShortArrayElements(env, bounds, sa, 0); + if (arg1) lparg1 = getControlFontStyleRecFields(env, arg1, &_arg1); + rc = (jint)SetControlFontStyle((ControlRef)arg0, (const ControlFontStyleRec *)lparg1); + if (arg1) setControlFontStyleRecFields(env, arg1, lparg1); return rc; } +#endif /* NO_SetControlFontStyle */ + +#ifndef NO_SetControlPopupMenuHandle +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlPopupMenuHandle + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControlPopupMenuHandle\n") + + SetControlPopupMenuHandle((ControlRef)arg0, (MenuRef)arg1); +} +#endif /* NO_SetControlPopupMenuHandle */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetIconRef(JNIEnv *env, jclass zz, - jshort vRefNum, jint creator, jint iconType, jintArray iconRef) { - jint *sa= (*env)->GetIntArrayElements(env, iconRef, 0); - jint rc= RC(GetIconRef(vRefNum, (OSType)creator, (OSType)iconType, (IconRef*)sa)); - (*env)->ReleaseIntArrayElements(env, iconRef, sa, 0); +#ifndef NO_SetControlProperty +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlProperty + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4) +{ + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetControlProperty\n") + + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)SetControlProperty((ControlRef)arg0, arg1, arg2, arg3, (const void *)lparg4); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetCurrentProcess(JNIEnv *env, jclass zz, - jintArray psn) { - jint *sa= (*env)->GetIntArrayElements(env, psn, 0); - jint status= (jint) GetCurrentProcess((ProcessSerialNumberPtr)sa); - (*env)->ReleaseIntArrayElements(env, psn, sa, 0); - return status; +#ifndef NO_SetControlReference +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlReference + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControlReference\n") + + SetControlReference((ControlRef)arg0, (SInt32)arg1); } +#endif /* NO_SetControlReference */ + +#ifndef NO_SetControlTitleWithCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlTitleWithCFString + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControlTitleWithCFString\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetFrontProcess(JNIEnv *env, jclass zz, - jintArray psn) { - jint *sa= (*env)->GetIntArrayElements(env, psn, 0); - jint status= (jint) SetFrontProcess((ProcessSerialNumberPtr)sa); - (*env)->ReleaseIntArrayElements(env, psn, sa, 0); - return status; + return (jint)SetControlTitleWithCFString((ControlRef)arg0, (CFStringRef)arg1); } +#endif /* NO_SetControlTitleWithCFString */ -//---- utilities +#ifndef NO_SetControlViewSize +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetControlViewSize + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetControlViewSize\n") -static Point point(JNIEnv *env, jshortArray a) { - Point p; - jshort *sa= (*env)->GetShortArrayElements(env, a, 0); - p.v= sa[0]; - p.h= sa[1]; - (*env)->ReleaseShortArrayElements(env, a, sa, 0); - return p; + SetControlViewSize((ControlRef)arg0, (SInt32)arg1); } +#endif /* NO_SetControlViewSize */ -static void copyEvent(JNIEnv *env, jintArray eData, EventRecord *event) { - if (eData != NULL) { - jint *sa= (*env)->GetIntArrayElements(env, eData, 0); - sa[0]= (int) event->what; - sa[1]= (int) event->message; - sa[2]= (int) event->when; - sa[3]= (int) event->where.v; - sa[4]= (int) event->where.h; - sa[5]= (int) event->modifiers; - (*env)->ReleaseIntArrayElements(env, eData, sa, 0); - } +#ifndef NO_SetCursor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetCursor + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SetCursor\n") + + SetCursor((const Cursor *)arg0); } +#endif /* NO_SetCursor */ + +#ifndef NO_SetDataBrowserCallbacks +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserCallbacks + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + DataBrowserCallbacks _arg1={0}, *lparg1=NULL; + jint rc; + + DEBUG_CALL("SetDataBrowserCallbacks\n") -static void copyEventData(JNIEnv *env, EventRecord *event, jintArray eData) { - if (eData != NULL) { - jint *sa= (*env)->GetIntArrayElements(env, eData, 0); - event->what= (short) sa[0]; - event->message= sa[1]; - event->when= sa[2]; - event->where.v= (short) sa[3]; - event->where.h= (short) sa[4]; - event->modifiers= sa[5]; - (*env)->ReleaseIntArrayElements(env, eData, sa, 0); - } + if (arg1) lparg1 = getDataBrowserCallbacksFields(env, arg1, &_arg1); + rc = (jint)SetDataBrowserCallbacks((ControlRef)arg0, (const DataBrowserCallbacks *)lparg1); + if (arg1) setDataBrowserCallbacksFields(env, arg1, lparg1); + return rc; } +#endif /* NO_SetDataBrowserCallbacks */ -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Jaguar -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#ifndef NO_SetDataBrowserCustomCallbacks +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserCustomCallbacks + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + DataBrowserCustomCallbacks _arg1={0}, *lparg1=NULL; + jint rc; -//// HIObject + DEBUG_CALL("SetDataBrowserCustomCallbacks\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIObjectRegisterSubclass(JNIEnv *env, jclass zz, - jint inClassID, - jint inBaseClassID, - jint inOptions, - jint inConstructProc, - jintArray inEventList, - jint inConstructData, - jintArray outClassRef) { - - jint *sa= (*env)->GetIntArrayElements(env, inEventList, 0); - jsize length= (*env)->GetArrayLength(env, inEventList); - - jint *sb= (*env)->GetIntArrayElements(env, outClassRef, 0); - jint status; - - status= RC(HIObjectRegisterSubclass( - (CFStringRef) inClassID, - (CFStringRef) inBaseClassID, - (OptionBits) inOptions, - (EventHandlerUPP) inConstructProc, - (UInt32) (length/2), - (const EventTypeSpec*) sa, - NULL, // (void*) inConstructData, - (HIObjectClassRef*) sb)); - - (*env)->ReleaseIntArrayElements(env, inEventList, sa, 0); - (*env)->ReleaseIntArrayElements(env, outClassRef, sb, 0); + if (arg1) lparg1 = getDataBrowserCustomCallbacksFields(env, arg1, &_arg1); + rc = (jint)SetDataBrowserCustomCallbacks((ControlRef)arg0, (const DataBrowserCustomCallbacks *)lparg1); + if (arg1) setDataBrowserCustomCallbacksFields(env, arg1, lparg1); + return rc; +} +#endif /* NO_SetDataBrowserCustomCallbacks */ + +#ifndef NO_SetDataBrowserTableViewNamedColumnWidth +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserTableViewNamedColumnWidth + (JNIEnv *env, jclass that, jint arg0, jint arg1, jshort arg2) +{ + DEBUG_CALL("SetDataBrowserTableViewNamedColumnWidth\n") - return status; + return (jint)SetDataBrowserTableViewNamedColumnWidth((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1, (UInt16)arg2); } +#endif /* NO_SetDataBrowserTableViewNamedColumnWidth */ + +#ifndef NO_SetDataBrowserHasScrollBars +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserHasScrollBars + (JNIEnv *env, jclass that, jint arg0, jboolean arg1, jboolean arg2) +{ + DEBUG_CALL("SetDataBrowserHasScrollBars\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIObjectCreate(JNIEnv *env, jclass zz, - jint inClassID, jint inConstructData, jintArray outObject) { - jint *sa= (*env)->GetIntArrayElements(env, outObject, 0); - jint status= RC(HIObjectCreate((CFStringRef)inClassID, (EventRef) inConstructData, (HIObjectRef*)sa)); - (*env)->ReleaseIntArrayElements(env, outObject, sa, 0); - return status; + return (jint)SetDataBrowserHasScrollBars((ControlRef)arg0, (Boolean)arg1, (Boolean)arg2); } +#endif /* NO_SetDataBrowserHasScrollBars */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIObjectCopyClassID(JNIEnv *env, jclass zz, - jint inObject) { - return(jint) HIObjectCopyClassID((HIObjectRef)inObject); +#ifndef NO_SetDataBrowserItemDataBooleanValue +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataBooleanValue + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("SetDataBrowserItemDataBooleanValue\n") + + return (jint)SetDataBrowserItemDataBooleanValue((DataBrowserItemDataRef)arg0, (Boolean)arg1); } +#endif /* NO_SetDataBrowserItemDataBooleanValue */ +#ifndef NO_SetDataBrowserItemDataButtonValue +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataButtonValue + (JNIEnv *env, jclass that, jint arg0, jshort arg1) +{ + DEBUG_CALL("SetDataBrowserItemDataButtonValue\n") -//// HIView + return (jint)SetDataBrowserItemDataButtonValue((DataBrowserItemDataRef)arg0, (ThemeButtonValue)arg1); +} +#endif /* NO_SetDataBrowserItemDataButtonValue */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewAddSubview(JNIEnv *env, jclass zz, - jint inParent, jint inNewChild) { - return RC(HIViewAddSubview((HIViewRef)inParent, (HIViewRef) inNewChild)); +#ifndef NO_SetDataBrowserItemDataIcon +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataIcon + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetDataBrowserItemDataIcon\n") + + return (jint)SetDataBrowserItemDataIcon((DataBrowserItemDataRef)arg0, (IconRef)arg1); } +#endif /* NO_SetDataBrowserItemDataIcon */ + +#ifndef NO_SetDataBrowserItemDataItemID +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataItemID + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetDataBrowserItemDataItemID\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewRemoveFromSuperview(JNIEnv *env, jclass zz, - jint inView) { - return RC(HIViewRemoveFromSuperview((HIViewRef) inView)); + return (jint)SetDataBrowserItemDataItemID((DataBrowserItemDataRef)arg0, (DataBrowserItemID)arg1); } +#endif /* NO_SetDataBrowserItemDataItemID */ + +#ifndef NO_SetDataBrowserItemDataText +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserItemDataText + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetDataBrowserItemDataText\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetDrawingEnabled(JNIEnv *env, jclass zz, - jint inView, jboolean inEnabled) { - return RC(HIViewSetDrawingEnabled((HIViewRef)inView, (Boolean) inEnabled)); + return (jint)SetDataBrowserItemDataText((DataBrowserItemDataRef)arg0, (CFStringRef)arg1); } +#endif /* NO_SetDataBrowserItemDataText */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSimulateClick(JNIEnv *env, jclass zz, - jint inView, jshort inPartToClick, jint inModifiers, jshortArray outPartClicked) { - jshort *sa= (*env)->GetShortArrayElements(env, outPartClicked, 0); - jint status= RC(HIViewSimulateClick((HIViewRef)inView, (HIViewPartCode)inPartToClick, (UInt32)inModifiers, (ControlPartCode*) sa)); - (*env)->ReleaseShortArrayElements(env, outPartClicked, sa, 0); - return status; +#ifndef NO_SetDataBrowserListViewDisclosureColumn +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserListViewDisclosureColumn + (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2) +{ + DEBUG_CALL("SetDataBrowserListViewDisclosureColumn\n") + + return (jint)SetDataBrowserListViewDisclosureColumn((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1, (Boolean)arg2); } +#endif /* NO_SetDataBrowserListViewDisclosureColumn */ + +#ifndef NO_SetDataBrowserListViewHeaderBtnHeight +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserListViewHeaderBtnHeight + (JNIEnv *env, jclass that, jint arg0, jshort arg1) +{ + DEBUG_CALL("SetDataBrowserListViewHeaderBtnHeight\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetZOrder(JNIEnv *env, jclass zz, - jint inView, jint inOp, jint inOther) { - return RC(HIViewSetZOrder((HIViewRef)inView, (HIViewZOrderOp) inOp, (HIViewRef)inOther)); + return (jint)SetDataBrowserListViewHeaderBtnHeight((ControlRef)arg0, (UInt16)arg1); } +#endif /* NO_SetDataBrowserListViewHeaderBtnHeight */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetFrame(JNIEnv *env, jclass zz, - jint inView, jint x, jint y, jint width, jint height) { - HIRect r; - r.origin.x= x; - r.origin.y= y; - r.size.width= width; - r.size.height= height; - return RC(HIViewSetFrame((HIViewRef)inView, (const HIRect*) &r)); + +#ifndef NO_SetDataBrowserListViewHeaderDesc +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserListViewHeaderDesc + (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2) +{ + DataBrowserListViewHeaderDesc _arg2, *lparg2=NULL; + jint rc; + + DEBUG_CALL("SetDataBrowserListViewHeaderDesc\n") + + if (arg2) lparg2 = getDataBrowserListViewHeaderDescFields(env, arg2, &_arg2); + rc = (jint)SetDataBrowserListViewHeaderDesc((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1, (DataBrowserListViewHeaderDesc *)lparg2); + if (arg2) setDataBrowserListViewHeaderDescFields(env, arg2, lparg2); + return rc; } +#endif -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetFrame(JNIEnv *env, jclass zz, - jint inView, jfloatArray outHIRect) { - HIRect r; - jint status= RC(HIViewGetFrame((HIViewRef)inView, (HIRect*) &r)); - jfloat *sa= (*env)->GetFloatArrayElements(env, outHIRect, 0); - sa[0]= r.origin.x; - sa[1]= r.origin.y; - sa[2]= r.size.width; - sa[3]= r.size.height; - (*env)->ReleaseFloatArrayElements(env, outHIRect, sa, 0); - return status; +#ifndef NO_SetDataBrowserScrollPosition +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserScrollPosition + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("SetDataBrowserScrollPosition\n") + + return (jint)SetDataBrowserScrollPosition((ControlRef)arg0, (UInt32)arg1, (UInt32)arg2); +} +#endif /* NO_SetDataBrowserScrollPosition */ + +#ifndef NO_SetDataBrowserSelectedItems +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserSelectedItems + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3) +{ + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("SetDataBrowserSelectedItems\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)SetDataBrowserSelectedItems((ControlRef)arg0, (UInt32)arg1, (const DataBrowserItemID *)lparg2, (DataBrowserSetOption)arg3); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; +} +#endif /* NO_SetDataBrowserSelectedItems */ + +#ifndef NO_SetDataBrowserSelectionFlags +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserSelectionFlags + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetDataBrowserSelectionFlags\n") + + return (jint)SetDataBrowserSelectionFlags((ControlRef)arg0, (DataBrowserSelectionFlags)arg1); +} +#endif /* NO_SetDataBrowserSelectionFlags */ + +#ifndef NO_SetDataBrowserTableViewColumnPosition +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserTableViewColumnPosition + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + + DEBUG_CALL("SetDataBrowserTableViewColumnPosition\n") + + return (jint)SetDataBrowserTableViewColumnPosition((ControlRef)arg0, (DataBrowserTableViewColumnID)arg1, (DataBrowserTableViewColumnIndex)arg2); + +} +#endif /* NO_SetDataBrowserTableViewColumnPosition */ + +#ifndef NO_SetDataBrowserTableViewItemRow +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserTableViewItemRow + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + + DEBUG_CALL("SetDataBrowserTableViewItemRow\n") + + return (jint)SetDataBrowserTableViewItemRow((ControlRef)arg0, (DataBrowserItemID)arg1, (DataBrowserTableViewRowIndex)arg2); + +} +#endif /* NO_SetDataBrowserTableViewItemRow */ + +#ifndef NO_SetDataBrowserTableViewHiliteStyle +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserTableViewHiliteStyle + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetDataBrowserTableViewHiliteStyle\n") + + return (jint)SetDataBrowserTableViewHiliteStyle((ControlRef)arg0, (DataBrowserTableViewHiliteStyle)arg1); +} +#endif + +#ifndef NO_SetDataBrowserTarget +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDataBrowserTarget + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetDataBrowserTarget\n") + + return (jint)SetDataBrowserTarget((ControlRef)arg0, (DataBrowserItemID)arg1); +} +#endif /* NO_SetDataBrowserTarget */ + +#ifndef NO_SetEventLoopTimerNextFireTime +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetEventLoopTimerNextFireTime + (JNIEnv *env, jclass that, jint arg0, jdouble arg1) +{ + DEBUG_CALL("SetEventLoopTimerNextFireTime\n") + + return (jint)SetEventLoopTimerNextFireTime((EventLoopTimerRef)arg0, (EventTimerInterval)arg1); +} +#endif /* NO_SetEventLoopTimerNextFireTime */ + +#ifndef NO_SetEventParameter +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetEventParameter + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4) +{ + jchar *lparg4=NULL; + jint rc; + + DEBUG_CALL("SetEventParameter\n") + + if (arg4) lparg4 = (*env)->GetCharArrayElements(env, arg4, NULL); + rc = (jint)SetEventParameter((EventRef)arg0, (EventParamName)arg1, (EventParamType)arg2, (UInt32)arg3, (const void *)lparg4); + if (arg4) (*env)->ReleaseCharArrayElements(env, arg4, lparg4, 0); + return rc; +} +#endif /* NO_SetEventParameter */ + +#ifndef NO_SetFontInfoForSelection +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetFontInfoForSelection + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3) +{ + DEBUG_CALL("SetFontInfoForSelection\n") + + return (jint)SetFontInfoForSelection((OSType)arg0, (UInt32)arg1, (void *)arg2, (HIObjectRef)arg3); +} +#endif + +#ifndef NO_SetFrontProcess +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetFrontProcess + (JNIEnv *env, jclass that, jintArray arg0) +{ + jint *lparg0=NULL; + jint rc; + + DEBUG_CALL("SetFrontProcess\n") + + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + rc = (jint)SetFrontProcess((const ProcessSerialNumber *)lparg0); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); + return rc; +} +#endif /* NO_SetFrontProcess */ + +#ifndef NO_SetGWorld +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetGWorld + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetGWorld\n") + + SetGWorld((CGrafPtr)arg0, (GDHandle)arg1); +} +#endif /* NO_SetGWorld */ + +#ifndef NO_SetKeyboardFocus +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetKeyboardFocus + (JNIEnv *env, jclass that, jint arg0, jint arg1, jshort arg2) +{ + DEBUG_CALL("SetKeyboardFocus\n") + + return (jint)SetKeyboardFocus((WindowRef)arg0, (ControlRef)arg1, (ControlFocusPart)arg2); +} +#endif /* NO_SetKeyboardFocus */ + +#ifndef NO_SetMenuCommandMark +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuCommandMark + (JNIEnv *env, jclass that, jint arg0, jint arg1, jchar arg2) +{ + DEBUG_CALL("SetMenuCommandMark\n") + + return (jint)SetMenuCommandMark((MenuRef)arg0, (MenuCommand)arg1, (UniChar)arg2); +} +#endif /* NO_SetMenuCommandMark */ + +#ifndef NO_SetMenuFont +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuFont + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2) +{ + DEBUG_CALL("SetMenuFont\n") + + return (jint)SetMenuFont((MenuRef)arg0, (SInt16)arg1, (UInt16)arg2); +} +#endif /* NO_SetMenuFont */ + +#ifndef NO_SetMenuItemCommandKey +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemCommandKey + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jboolean arg2, jchar arg3) +{ + DEBUG_CALL("SetMenuItemCommandKey\n") + + return (jint)SetMenuItemCommandKey((MenuRef)arg0, (MenuItemIndex)arg1, (Boolean)arg2, (UInt16)arg3); +} +#endif /* NO_SetMenuItemCommandKey */ + +#ifndef NO_SetMenuItemHierarchicalMenu +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemHierarchicalMenu + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2) +{ + DEBUG_CALL("SetMenuItemHierarchicalMenu\n") + + return (jint)SetMenuItemHierarchicalMenu((MenuRef)arg0, (MenuItemIndex)arg1, (MenuRef)arg2); +} +#endif /* NO_SetMenuItemHierarchicalMenu */ + +#ifndef NO_SetMenuItemIconHandle +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemIconHandle + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jbyte arg2, jint arg3) +{ + DEBUG_CALL("SetMenuItemIconHandle\n") + + return (jint)SetMenuItemIconHandle((MenuRef)arg0, (SInt16)arg1, (UInt8)arg2, (Handle)arg3); +} +#endif /* NO_SetMenuItemIconHandle */ + +#ifndef NO_SetMenuItemKeyGlyph +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemKeyGlyph + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2) +{ + DEBUG_CALL("SetMenuItemKeyGlyph\n") + + return (jint)SetMenuItemKeyGlyph((MenuRef)arg0, (SInt16)arg1, (SInt16)arg2); +} +#endif /* NO_SetMenuItemKeyGlyph */ + +#ifndef NO_SetMenuItemModifiers +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemModifiers + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jbyte arg2) +{ + DEBUG_CALL("SetMenuItemModifiers\n") + + return (jint)SetMenuItemModifiers((MenuRef)arg0, (SInt16)arg1, (UInt8)arg2); +} +#endif /* NO_SetMenuItemModifiers */ + +#ifndef NO_SetMenuItemRefCon +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemRefCon + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2) +{ + DEBUG_CALL("SetMenuItemRefCon\n") + + return (jint)SetMenuItemRefCon((MenuRef)arg0, (SInt16)arg1, (UInt32)arg2); +} +#endif /* NO_SetMenuItemRefCon */ + +#ifndef NO_SetMenuItemTextWithCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuItemTextWithCFString + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2) +{ + DEBUG_CALL("SetMenuItemTextWithCFString\n") + + return (jint)SetMenuItemTextWithCFString((MenuRef)arg0, (MenuItemIndex)arg1, (CFStringRef)arg2); +} +#endif /* NO_SetMenuItemTextWithCFString */ + +#ifndef NO_SetMenuTitleWithCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetMenuTitleWithCFString + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetMenuTitleWithCFString\n") + + return (jint)SetMenuTitleWithCFString((MenuRef)arg0, (CFStringRef)arg1); +} +#endif /* NO_SetMenuTitleWithCFString */ + +#ifndef NO_SetOrigin +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetOrigin + (JNIEnv *env, jclass that, jshort arg0, jshort arg1) +{ + DEBUG_CALL("SetOrigin\n") + + SetOrigin((short)arg0, (short)arg1); +} +#endif /* NO_SetOrigin */ + +#ifndef NO_SetPort +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetPort + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SetPort\n") + + SetPort((GrafPtr)arg0); +} +#endif /* NO_SetPort */ + +#ifndef NO_SetPortBounds +JNIEXPORT void JNICALL OS_NATIVE(SetPortBounds) + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("SetPortBounds\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + SetPortBounds((CGrafPtr)arg0, (const Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); +} +#endif + +#ifndef NO_SetPortWindowPort +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetPortWindowPort + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SetPortWindowPort\n") + + SetPortWindowPort((WindowRef)arg0); +} +#endif /* NO_SetPortWindowPort */ + +#ifndef NO_SetPt +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetPt + (JNIEnv *env, jclass that, jobject arg0, jshort arg1, jshort arg2) +{ + Point _arg0, *lparg0=NULL; + + DEBUG_CALL("SetPt\n") + + if (arg0) lparg0 = getPointFields(env, arg0, &_arg0); + SetPt((Point *)lparg0, (short)arg1, (short)arg2); + if (arg0) setPointFields(env, arg0, lparg0); +} +#endif /* NO_SetPt */ + +#ifndef NO_SetRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetRect + (JNIEnv *env, jclass that, jobject arg0, jshort arg1, jshort arg2, jshort arg3, jshort arg4) +{ + Rect _arg0, *lparg0=NULL; + + DEBUG_CALL("SetRect\n") + + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + SetRect((Rect *)lparg0, (short)arg1, (short)arg2, (short)arg3, (short)arg4); + if (arg0) setRectFields(env, arg0, lparg0); +} +#endif /* NO_SetRect */ + +#ifndef NO_SetRectRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetRectRgn + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2, jshort arg3, jshort arg4) +{ + DEBUG_CALL("SetRectRgn\n") + + SetRectRgn((RgnHandle)arg0, (short)arg1, (short)arg2, (short)arg3, (short)arg4); +} +#endif /* NO_SetRectRgn */ + +#ifndef NO_SetRootMenu +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetRootMenu + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SetRootMenu\n") + + return (jint)SetRootMenu((MenuRef)arg0); +} +#endif /* NO_SetRootMenu */ + +#ifndef NO_SetThemeBackground +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeBackground + (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jboolean arg2) +{ + DEBUG_CALL("SetThemeBackground\n") + + return (jint)SetThemeBackground((ThemeBrush)arg0, (SInt16)arg1, (Boolean)arg2); +} +#endif /* NO_SetThemeBackground */ + +#ifndef NO_SetThemeCursor +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeCursor + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("SetThemeCursor\n") + + return (jint)SetThemeCursor((ThemeCursor)arg0); +} +#endif /* NO_SetThemeCursor */ + +#ifndef NO_SetThemeDrawingState +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeDrawingState + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("SetThemeDrawingState\n") + + return (jint)SetThemeDrawingState((ThemeDrawingState)arg0, (Boolean)arg1); +} +#endif /* NO_SetThemeDrawingState */ + +#ifndef NO_SetThemeWindowBackground +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetThemeWindowBackground + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jboolean arg2) +{ + DEBUG_CALL("SetThemeWindowBackground\n") + + return (jint)SetThemeWindowBackground((WindowRef)arg0, (ThemeBrush)arg1, (Boolean)arg2); +} +#endif /* NO_SetThemeWindowBackground */ + +#ifndef NO_SetUpControlBackground +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetUpControlBackground + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jboolean arg2) +{ + DEBUG_CALL("SetUpControlBackground\n") + + return (jint)SetUpControlBackground((ControlRef)arg0, (SInt16)arg1, (Boolean)arg2); +} +#endif /* NO_SetUpControlBackground */ + +#ifndef NO_SetWRefCon +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWRefCon + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetWRefCon\n") + + SetWRefCon((WindowRef)arg0, (long)arg1); +} +#endif /* NO_SetWRefCon */ + +#ifndef NO_SetWindowActivationScope +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowActivationScope + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetWindowActivationScope\n") + + return (jint)SetWindowActivationScope((WindowRef)arg0, (WindowActivationScope)arg1); +} +#endif /* NO_SetWindowActivationScope */ + +#ifndef NO_SetWindowBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowBounds + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jobject arg2) +{ + Rect _arg2, *lparg2=NULL; + + DEBUG_CALL("SetWindowBounds\n") + + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + SetWindowBounds((WindowRef)arg0, (WindowRegionCode)arg1, (Rect *)lparg2); + if (arg2) setRectFields(env, arg2, lparg2); +} +#endif /* NO_SetWindowBounds */ + +#ifndef NO_SetWindowDefaultButton +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowDefaultButton + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetWindowDefaultButton\n") + + return (jint)SetWindowDefaultButton((WindowRef)arg0, (ControlRef)arg1); +} +#endif /* NO_SetWindowDefaultButton */ + +#ifndef NO_SetWindowGroup +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowGroup + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetWindowGroup\n") + + return (jint)SetWindowGroup((WindowRef)arg0, (WindowGroupRef)arg1); +} +#endif + +#ifndef NO_SetWindowGroupOwner +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowGroupOwner + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetWindowGroupOwner\n") + + return (jint)SetWindowGroupOwner((WindowGroupRef)arg0, (WindowRef)arg1); +} +#endif + +#ifndef NO_SetWindowGroupParent +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowGroupParent + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetWindowGroupParent\n") + + return (jint)SetWindowGroupParent((WindowGroupRef)arg0, (WindowGroupRef)arg1); +} +#endif + +#ifndef NO_SetWindowModality +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowModality + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("SetWindowModality\n") + + return (jint)SetWindowModality((WindowRef)arg0, (WindowModality)arg1, (WindowRef)arg2); +} +#endif /* NO_SetWindowModality */ + +#ifndef NO_SetWindowTitleWithCFString +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetWindowTitleWithCFString + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SetWindowTitleWithCFString\n") + + return (jint)SetWindowTitleWithCFString((WindowRef)arg0, (CFStringRef)arg1); +} +#endif /* NO_SetWindowTitleWithCFString */ + +#ifndef NO_ShowWindow +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_ShowWindow + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("ShowWindow\n") + + ShowWindow((WindowRef)arg0); +} +#endif /* NO_ShowWindow */ + +#ifndef NO_SizeControl +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SizeControl + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2) +{ + DEBUG_CALL("SizeControl\n") + + SizeControl((ControlRef)arg0, (SInt16)arg1, (SInt16)arg2); +} +#endif /* NO_SizeControl */ + +#ifndef NO_SizeWindow +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SizeWindow + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2, jboolean arg3) +{ + DEBUG_CALL("SizeWindow\n") + + SizeWindow((WindowRef)arg0, (short)arg1, (short)arg2, (Boolean)arg3); +} +#endif /* NO_SizeWindow */ + +#ifndef NO_StillDown +JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_StillDown + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("StillDown\n") + + return (jboolean)StillDown(); +} +#endif /* NO_StillDown */ + +#ifndef NO_SyncCGContextOriginWithPort +JNIEXPORT jint JNICALL OS_NATIVE(SyncCGContextOriginWithPort) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("SyncCGContextOriginWithPort\n") + + return (jint)SyncCGContextOriginWithPort((CGContextRef)arg0, (CGrafPtr)arg1); +} +#endif + +#ifndef NO_SysBeep +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SysBeep + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("SysBeep\n") + + SysBeep((short)arg0); } +#endif /* NO_SysBeep */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewClick(JNIEnv *env, jclass zz, - jint inView, jint inEvent) { - return RC(HIViewClick((HIViewRef)inView, (EventRef) inEvent)); +#ifndef NO_TXNActivate +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNActivate + (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2) +{ + DEBUG_CALL("TXNActivate\n") + + return (jint)TXNActivate((TXNObject)arg0, (TXNFrameID)arg1, (TXNScrollBarState)arg2); +} +#endif /* NO_TXNActivate */ + +#ifndef NO_TXNAdjustCursor +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNAdjustCursor + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("TXNActivate\n") + + TXNAdjustCursor((TXNObject)arg0, (RgnHandle)arg1); +} +#endif /* NO_TXNAdjustCursor */ + +#ifndef NO_TXNClick +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNClick + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + EventRecord _arg1, *lparg1=NULL; + + DEBUG_CALL("TXNClick\n") + + if (arg1) lparg1 = getEventRecordFields(env, arg1, &_arg1); + TXNClick((TXNObject)arg0, (const EventRecord *)lparg1); + if (arg1) setEventRecordFields(env, arg1, lparg1); +} +#endif /* NO_TXNClick */ + +#ifndef NO_TXNCopy +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNCopy + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("TXNCopy\n") + + return (jint)TXNCopy((TXNObject)arg0); +} +#endif /* NO_TXNCopy */ + +#ifndef NO_TXNCut +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNCut + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("TXNCut\n") + + return (jint)TXNCut((TXNObject)arg0); +} +#endif /* NO_TXNCut */ + +#ifndef NO_TXNDataSize +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNDataSize + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("TXNDataSize\n") + + return (jint)TXNDataSize((TXNObject)arg0); +} +#endif /* NO_TXNDataSize */ + +#ifndef NO_TXNDeleteObject +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNDeleteObject + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("TXNDeleteObject\n") + + TXNDeleteObject((TXNObject)arg0); +} +#endif /* NO_TXNDeleteObject */ + +#ifndef NO_TXNDraw +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNDraw + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("TXNDraw\n") + + TXNDraw((TXNObject)arg0, (GWorldPtr)arg1); +} +#endif /* NO_TXNDraw */ + +#ifndef NO_TXNEchoMode +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNEchoMode + (JNIEnv *env, jclass that, jint arg0, jchar arg1, jint arg2, jboolean arg3) +{ + DEBUG_CALL("TXNEchoMode\n") + + return (jint)TXNEchoMode((TXNObject)arg0, (UniChar)arg1, (TextEncoding)arg2, (Boolean)arg3); +} +#endif /* NO_TXNEchoMode */ + +#ifndef NO_TXNFocus +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNFocus + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("TXNFocus\n") + + TXNFocus((TXNObject)arg0, (Boolean)arg1); +} +#endif /* NO_TXNFocus */ + +#ifndef NO_TXNGetRectBounds +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetRectBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jobject arg2, jobject arg3) +{ + Rect _arg1, *lparg1=NULL; + TXNLongRect _arg2, *lparg2=NULL; + TXNLongRect _arg3, *lparg3=NULL; + jint rc; + + DEBUG_CALL("TXNGetRectBounds\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = getTXNLongRectFields(env, arg2, &_arg2); + if (arg3) lparg3 = getTXNLongRectFields(env, arg3, &_arg3); + rc = (jint)TXNGetRectBounds((TXNObject)arg0, (Rect *)lparg1, (TXNLongRect *)lparg2, (TXNLongRect *)lparg3); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) setTXNLongRectFields(env, arg2, lparg2); + if (arg3) setTXNLongRectFields(env, arg3, lparg3); + return rc; +} +#endif /* NO_TXNGetRectBounds */ + +#ifndef NO_TXNGetData +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetData + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3) +{ + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("TXNGetData\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)TXNGetData((TXNObject)arg0, (TXNOffset)arg1, (TXNOffset)arg2, (Handle *)lparg3); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; +} +#endif /* NO_TXNGetData */ + +#ifndef NO_TXNGetLineCount +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetLineCount + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + jint rc; + + DEBUG_CALL("TXNGetLineCount\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + rc = (jint)TXNGetLineCount((TXNObject)arg0, (ItemCount *)lparg1); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + return rc; +} +#endif /* NO_TXNGetLineCount */ + +#ifndef NO_TXNGetLineMetrics +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetLineMetrics + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3) +{ + jint *lparg2=NULL; + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("TXNGetLineMetrics\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)TXNGetLineMetrics((TXNObject)arg0, (UInt32)arg1, (Fixed *)lparg2, (Fixed *)lparg3); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; +} +#endif /* NO_TXNGetLineMetrics*/ + +#ifndef NO_TXNGetViewRect +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetViewRect + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("TXNGetViewRect\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + TXNGetViewRect((TXNObject)arg0, (Rect *)lparg1); + if (arg1) setRectFields(env, arg1, lparg1); +} +#endif /* NO_TXNGetViewRect */ + +#ifndef NO_TXNGetTXNObjectControls +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetTXNObjectControls + (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3) +{ + jint *lparg2=NULL; + jint *lparg3=NULL; + jint rc; + + DEBUG_CALL("TXNGetTXNObjectControls\n") + + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)TXNGetTXNObjectControls((TXNObject)arg0, (ItemCount)arg1, (const TXNControlTag *)lparg2, (TXNControlData *)lparg3); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; +} +#endif /* NO_TXNGetTXNObjectControls */ + +#ifndef NO_TXNGetSelection +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNGetSelection + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + + DEBUG_CALL("TXNGetSelection\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + TXNGetSelection((TXNObject)arg0, (TXNOffset *)lparg1, (TXNOffset *)lparg2); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); +} +#endif /* NO_TXNGetSelection */ + +#ifndef NO_TXNInitTextension +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNInitTextension + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("TXNInitTextension\n") + + return (jint)TXNInitTextension((const TXNMacOSPreferredFontDescription *)arg0, (ItemCount)arg1, (TXNInitOptions)arg2); +} +#endif /* NO_TXNInitTextension */ + +#ifndef NO_TXNNewObject +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNNewObject + (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3, jint arg4, jint arg5, jint arg6, jintArray arg7, jintArray arg8, jint arg9) +{ + Rect _arg2, *lparg2=NULL; + jint *lparg7=NULL; + jint *lparg8=NULL; + jint rc; + + DEBUG_CALL("TXNNewObject\n") + + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + if (arg7) lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL); + if (arg8) lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL); + rc = (jint)TXNNewObject((const FSSpec *)arg0, (WindowRef)arg1, (const Rect *)lparg2, (TXNFrameOptions)arg3, (TXNFrameType)arg4, (TXNFileType)arg5, (TXNPermanentTextEncodingType)arg6, (TXNObject *)lparg7, (TXNFrameID *)lparg8, (TXNObjectRefcon)arg9); + if (arg2) setRectFields(env, arg2, lparg2); + if (arg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0); + if (arg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0); + return rc; +} +#endif /* NO_TXNNewObject */ + +#ifndef NO_TXNOffsetToPoint +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNOffsetToPoint + (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2) +{ + Point _arg2, *lparg2=NULL; + jint rc; + + DEBUG_CALL("TXNOffsetToPoint\n") + + if (arg2) lparg2 = getPointFields(env, arg2, &_arg2); + rc = (jint)TXNOffsetToPoint((TXNObject)arg0, (TXNOffset)arg1, (Point *)lparg2); + if (arg2) setPointFields(env, arg2, lparg2); + return rc; +} +#endif /* NO_TXNOffsetToPoint */ + +#ifndef NO_TXNPaste +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNPaste + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("TXNPaste\n") + + return (jint)TXNPaste((TXNObject)arg0); +} +#endif /* NO_TXNPaste */ + +#ifndef NO_TXNPointToOffset +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNPointToOffset + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jintArray arg2) +{ + Point _arg1, *lparg1=NULL; + jint *lparg2=NULL; + jint rc; + + DEBUG_CALL("TXNPointToOffset\n") + + if (arg1) lparg1 = getPointFields(env, arg1, &_arg1); + if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL); + rc = (jint)TXNPointToOffset((TXNObject)arg0, (Point)*lparg1, (TXNOffset *)lparg2); + if (arg1) setPointFields(env, arg1, lparg1); + if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + return rc; +} +#endif /* NO_TXNPointToOffset */ + +#ifndef NO_TXNSelectAll +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSelectAll + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("TXNSelectAll\n") + + TXNSelectAll((TXNObject)arg0); +} +#endif /* NO_TXNSelectAll */ + +#ifndef NO_TXNSetData +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetData + (JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5) +{ + jchar *lparg2=NULL; + jint rc; + + DEBUG_CALL("TXNSetData\n") + + if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL); + rc = (jint)TXNSetData((TXNObject)arg0, (TXNDataType)arg1, (const void *)lparg2, (ByteCount)arg3, (TXNOffset)arg4, (TXNOffset)arg5); + if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0); + return rc; +} +#endif /* NO_TXNSetData */ + +#ifndef NO_TXNSetFrameBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetFrameBounds + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5) +{ + DEBUG_CALL("TXNSetFrameBounds\n") + + TXNSetFrameBounds((TXNObject)arg0, (SInt32)arg1, (SInt32)arg2, (SInt32)arg3, (SInt32)arg4, (TXNFrameID)arg5); +} +#endif /* NO_TXNSetFrameBounds */ + +#ifndef NO_TXNSetRectBounds +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetRectBounds + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jobject arg2, jboolean arg3) +{ + Rect _arg1, *lparg1=NULL; + TXNLongRect _arg2, *lparg2=NULL; + + DEBUG_CALL("TXNSetRectBounds\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = getTXNLongRectFields(env, arg2, &_arg2); + TXNSetRectBounds((TXNObject)arg0, (Rect *)lparg1, (TXNLongRect *)lparg2, (Boolean)arg3); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) setTXNLongRectFields(env, arg2, lparg2); } +#endif /* NO_TXNSetRectBounds */ + +#ifndef NO_TXNSetSelection +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetSelection + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("TXNSetSelection\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewConvertPoint(JNIEnv *env, jclass zz, - jfloatArray ioPoint, jint inSourceView, jint inDestView) { - jfloat *sa= (*env)->GetFloatArrayElements(env, ioPoint, 0); - HIPoint pt; - pt.x= sa[0]; - pt.y= sa[1]; - jint status= RC(HIViewConvertPoint((HIPoint*)&pt, (HIViewRef)inSourceView, (HIViewRef) inDestView)); - sa[0]= pt.x; - sa[1]= pt.y; - (*env)->ReleaseFloatArrayElements(env, ioPoint, sa, 0); - return status; + return (jint)TXNSetSelection((TXNObject)arg0, (TXNOffset)arg1, (TXNOffset)arg2); } +#endif /* NO_TXNSetSelection */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetRoot(JNIEnv *env, jclass zz, - jint inWindow) { - return (jint) HIViewGetRoot((WindowRef) inWindow); +#ifndef NO_TXNSetTXNObjectControls +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetTXNObjectControls + (JNIEnv *env, jclass that, jint arg0, jboolean arg1, jint arg2, jintArray arg3, jintArray arg4) +{ + jint *lparg3=NULL; + jint *lparg4=NULL; + jint rc; + + DEBUG_CALL("TXNSetTXNObjectControls\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + rc = (jint)TXNSetTXNObjectControls((TXNObject)arg0, (Boolean)arg1, (ItemCount)arg2, (const TXNControlTag *)lparg3, (const TXNControlData *)lparg4); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + return rc; } +#endif /* NO_TXNSetTXNObjectControls */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetNeedsDisplayInRegion(JNIEnv *env, jclass zz, - jint inView, jint inRgn, jboolean inNeedsDisplay) { - return RC(HIViewSetNeedsDisplayInRegion((HIViewRef) inView, (RgnHandle) inRgn, (Boolean) inNeedsDisplay)); +#ifndef NO_TXNShowSelection +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNShowSelection + (JNIEnv *env, jclass that, jint arg0, jboolean arg1) +{ + DEBUG_CALL("TXNShowSelection\n") + + TXNShowSelection((TXNObject)arg0, (Boolean)arg1); } +#endif /* NO_TXNShowSelection */ + +#ifndef NO_TestControl +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_TestControl + (JNIEnv *env, jclass that, jint arg0, jobject arg1) +{ + Point _arg1, *lparg1=NULL; + jshort rc; + + DEBUG_CALL("TestControl\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetNeedsDisplay(JNIEnv *env, jclass zz, - jint inView, jboolean inNeedsDisplay) { - return RC(HIViewSetNeedsDisplay((HIViewRef) inView, (Boolean) inNeedsDisplay)); + if (arg1) lparg1 = getPointFields(env, arg1, &_arg1); + rc = (jshort)TestControl((ControlRef)arg0, (Point)*lparg1); + if (arg1) setPointFields(env, arg1, lparg1); + return rc; } +#endif /* NO_TestControl */ + +#ifndef NO_TextFace +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextFace + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("TextFace\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewSetVisible(JNIEnv *env, jclass zz, - jint inView, jboolean inVisible) { - return RC(HIViewSetVisible((HIViewRef) inView, (Boolean) inVisible)); + TextFace((StyleParameter)arg0); } +#endif /* NO_TextFace */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewChangeAttributes(JNIEnv *env, jclass zz, - jint inView, jint inAttrsToSet, jint inAttrsToClear) { - return RC(HIViewChangeAttributes((HIViewRef) inView, (OptionBits) inAttrsToSet, (OptionBits) inAttrsToClear)); +#ifndef NO_TextFont +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextFont + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("TextFont\n") + + TextFont((short)arg0); } +#endif /* NO_TextFont */ + +#ifndef NO_TextMode +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextMode + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("TextMode\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewFindByID(JNIEnv *env, jclass zz, - jint inStartView, jint inID, jintArray outControl) { - jint *sa= (*env)->GetIntArrayElements(env, outControl, 0); - jint status= RC(HIViewFindByID((HIViewRef) inStartView, (HIViewID) kHIViewWindowContentID, (HIViewRef*) sa)); - (*env)->ReleaseIntArrayElements(env, outControl, sa, 0); - return status; + TextMode((short)arg0); } +#endif /* NO_TextMode */ + +#ifndef NO_TextSize +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextSize + (JNIEnv *env, jclass that, jshort arg0) +{ + DEBUG_CALL("TextSize\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIViewGetViewForMouseEvent(JNIEnv *env, jclass zz, - jint inView, jint inEvent, jintArray outView) { - jint *sa= (*env)->GetIntArrayElements(env, outView, 0); - jint status= RC(HIViewGetViewForMouseEvent((HIViewRef) inView, (EventRef) inEvent, (HIViewRef*) sa)); - (*env)->ReleaseIntArrayElements(env, outView, sa, 0); - return status; + TextSize((short)arg0); } +#endif /* NO_TextSize */ -/////// +#ifndef NO_TextWidth +JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_TextWidth + (JNIEnv *env, jclass that, jbyteArray arg0, jshort arg1, jshort arg2) +{ + jbyte *lparg0=NULL; + jshort rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxCreate(JNIEnv *env, jclass zz, - jintArray outComboBox, jint attributes) { - HIRect r= {}; - jint *sa= (*env)->GetIntArrayElements(env, outComboBox, 0); - jint status= RC(HIComboBoxCreate(&r, NULL, NULL, NULL, (OptionBits)attributes, (HIViewRef*)sa)); - (*env)->ReleaseIntArrayElements(env, outComboBox, sa, 0); - return status; + DEBUG_CALL("TextWidth\n") + + if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); + rc = (jshort)TextWidth((const void *)lparg0, (short)arg1, (short)arg2); + if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + return rc; } +#endif /* NO_TextWidth */ + +#ifndef NO_TrackMouseLocationWithOptions +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TrackMouseLocationWithOptions + (JNIEnv *env, jclass that, jint arg0, jint arg1, jdouble arg2, jobject arg3, jintArray arg4, jshortArray arg5) +{ + Point _arg3, *lparg3=NULL; + jint *lparg4=NULL; + jshort *lparg5=NULL; + jint rc; + + DEBUG_CALL("TrackMouseLocation\n") + + if (arg3) lparg3 = getPointFields(env, arg3, &_arg3); + if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL); + if (arg5) lparg5 = (*env)->GetShortArrayElements(env, arg5, NULL); + rc = (jint)TrackMouseLocationWithOptions((GrafPtr)arg0, (OptionBits)arg1, (EventTimeout)arg2, (Point *)lparg3, (UInt32 *)lparg4, (MouseTrackingResult *)lparg5); + if (arg3) setPointFields(env, arg3, lparg3); + if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + if (arg5) (*env)->ReleaseShortArrayElements(env, arg5, lparg5, 0); + return rc; +} +#endif /* NO_TrackMouseLocationWithOptions */ + +#ifndef NO_UnionRect +JNIEXPORT void JNICALL OS_NATIVE(UnionRect) + (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jobject arg2) +{ + Rect _arg0, *lparg0=NULL; + Rect _arg1, *lparg1=NULL; + Rect _arg2, *lparg2=NULL; + + DEBUG_CALL("UnionRect\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxGetItemCount(JNIEnv *env, jclass zz, - jint inComboBox) { - return (jint) HIComboBoxGetItemCount((HIViewRef)inComboBox); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + if (arg2) lparg2 = getRectFields(env, arg2, &_arg2); + UnionRect(lparg0, lparg1, lparg2); + if (arg0) setRectFields(env, arg0, lparg0); + if (arg1) setRectFields(env, arg1, lparg1); + if (arg2) setRectFields(env, arg2, lparg2); } +#endif + +#ifndef NO_UnionRgn +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_UnionRgn + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("UnionRgn\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxAppendTextItem(JNIEnv *env, jclass zz, - jint inView, jint inText) { - return RC(HIComboBoxAppendTextItem((HIViewRef)inView, (CFStringRef) inText, (CFIndex*) NULL)); + UnionRgn((RgnHandle)arg0, (RgnHandle)arg1, (RgnHandle)arg2); } +#endif /* NO_UnionRgn */ -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxInsertTextItemAtIndex(JNIEnv *env, jclass zz, - jint inView, jint inIndex, jint inText) { - return RC(HIComboBoxInsertTextItemAtIndex((HIViewRef)inView, (CFIndex) inIndex, (CFStringRef) inText)); +#ifndef NO_UnlockPortBits +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_UnlockPortBits + (JNIEnv *env, jclass that, jint arg0) +{ + DEBUG_CALL("UnlockPortBits\n") + + return (jint)UnlockPortBits((GrafPtr)arg0); } +#endif /* NO_UnlockPortBits */ + +#ifndef NO_UpdateControls +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_UpdateControls + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + DEBUG_CALL("UpdateControls\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxRemoveItemAtIndex(JNIEnv *env, jclass zz, - jint inView, jint inIndex) { - return RC(HIComboBoxRemoveItemAtIndex((HIViewRef)inView, (CFIndex) inIndex)); + UpdateControls((WindowRef)arg0, (RgnHandle)arg1); } +#endif /* NO_UpdateControls */ + +#ifndef NO_UpdateDataBrowserItems +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_UpdateDataBrowserItems + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4, jint arg5) +{ + jint *lparg3=NULL; + jint rc; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_HIComboBoxCopyTextItemAtIndex(JNIEnv *env, jclass zz, - jint inView, jint inIndex, jintArray outString) { - jint *sa= (*env)->GetIntArrayElements(env, outString, 0); - jint status= RC(HIComboBoxCopyTextItemAtIndex((HIViewRef)inView, (CFIndex) inIndex, (CFStringRef*) sa)); - (*env)->ReleaseIntArrayElements(env, outString, sa, 0); - return status; + DEBUG_CALL("UpdateDataBrowserItems\n") + + if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL); + rc = (jint)UpdateDataBrowserItems((ControlRef)arg0, (DataBrowserItemID)arg1, (UInt32)arg2, (const DataBrowserItemID *)lparg3, (DataBrowserPropertyID)arg4, (DataBrowserPropertyID)arg5); + if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + return rc; } +#endif /* NO_UpdateDataBrowserItems */ -// core graphics +#ifndef NO_kHIViewWindowContentID +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_kHIViewWindowContentID + (JNIEnv *env, jclass that) +{ + DEBUG_CALL("kHIViewWindowContentID\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDBeginCGContext(JNIEnv *env, jclass zz, - jint inPort, jintArray outContext) { - jint *sa= (*env)->GetIntArrayElements(env, outContext, 0); - jint status= RC(QDBeginCGContext((CGrafPtr)inPort, (CGContextRef*) sa)); - (*env)->ReleaseIntArrayElements(env, outContext, sa, 0); - return status; + return (jint)&kHIViewWindowContentID; } +#endif /* NO_kHIViewWindowContentID */ + +#ifndef NO_memcpy__I_3BI +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__I_3BI + (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2) +{ + jbyte *lparg1=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_QDEndCGContext(JNIEnv *env, jclass zz, - jint inPort, jintArray inoutContext) { - jint *sa= (*env)->GetIntArrayElements(env, inoutContext, 0); - jint status= RC(QDEndCGContext((CGrafPtr)inPort, (CGContextRef*) sa)); - (*env)->ReleaseIntArrayElements(env, inoutContext, sa, 0); - return status; + DEBUG_CALL("memcpy__I_3BI\n") + + if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); } +#endif /* NO_memcpy__I_3BI */ + +#ifndef NO_memcpy__III +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__III + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("memcpy__III\n") -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SyncCGContextOriginWithPort(JNIEnv *env, jclass zz, - jint inContext, jint port) { - return RC(SyncCGContextOriginWithPort((CGContextRef)inContext, (CGrafPtr) port)); + memcpy((void *)arg0, (const void *)arg1, (size_t)arg2); } +#endif /* NO_memcpy__III */ + +#ifndef NO_memcpy___3BII +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy___3BII + (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2) +{ + jbyte *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextSaveGState(JNIEnv *env, jclass zz, - jint inContext) { - CGContextSaveGState((CGContextRef)inContext); + DEBUG_CALL("memcpy___3BII\n") + + if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); } +#endif /* NO_memcpy___3BII */ + +#ifndef NO_memcpy___3CII +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy___3CII + (JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jint arg2) +{ + jchar *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextRestoreGState(JNIEnv *env, jclass zz, - jint inContext) { - CGContextRestoreGState((CGContextRef)inContext); + DEBUG_CALL("memcpy___3CII\n") + + if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0); +} +#endif /* NO_memcpy___3CII */ + +#ifndef NO_memcpy___3III +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy___3III + (JNIEnv *env, jclass that, jintArray arg0, jint arg1, jint arg2) +{ + jint *lparg0=NULL; + + DEBUG_CALL("memcpy___3III\n") + + if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0); } +#endif /* NO_memcpy___3III */ + +#ifndef NO_memcpy__Lorg_eclipse_swt_internal_carbon_ATSTrapezoid_2II +JNIEXPORT void JNICALL OS_NATIVE(memcpy__Lorg_eclipse_swt_internal_carbon_ATSTrapezoid_2II) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + ATSTrapezoid _arg0, *lparg0=NULL; + + DEBUG_CALL("memcpy__Lorg_eclipse_swt_internal_carbon_ATSTrapezoid_2II\n") + + if (arg0) lparg0 = getATSTrapezoidFields(env, arg0, &_arg0); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) setATSTrapezoidFields(env, arg0, lparg0); +} +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextStrokeRect(JNIEnv *env, jclass zz, - jint inContext, jfloat x, jfloat y, jfloat width, jfloat height) { - CGRect r; - r.origin.x= x; - r.origin.y= y; - r.size.width= width; - r.size.height= height; - CGContextStrokeRect((CGContextRef)inContext, r); +#ifndef NO_memcpy__I_3CI +JNIEXPORT void JNICALL OS_NATIVE(memcpy__I_3CI) + (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2) +{ + jchar *lparg1=NULL; + + DEBUG_CALL("memcpy__I_3CI\n") + + if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextFillRect(JNIEnv *env, jclass zz, - jint inContext, jfloat x, jfloat y, jfloat width, jfloat height) { - CGRect r; - r.origin.x= x; - r.origin.y= y; - r.size.width= width; - r.size.height= height; - CGContextFillRect((CGContextRef)inContext, r); +#ifndef NO_memcpy__I_3II +JNIEXPORT void JNICALL OS_NATIVE(memcpy__I_3II) + (JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2) +{ + jint *lparg1=NULL; + + DEBUG_CALL("memcpy__I_3II\n") + + if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextScaleCTM(JNIEnv *env, jclass zz, - jint inContext, jfloat sx, jfloat sy) { - CGContextScaleCTM((CGContextRef)inContext, sx, sy); + +#ifndef NO_memcpy__Lorg_eclipse_swt_internal_carbon_GDevice_2II +JNIEXPORT void JNICALL OS_NATIVE(memcpy__Lorg_eclipse_swt_internal_carbon_GDevice_2II) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + GDevice _arg0, *lparg0=NULL; + + DEBUG_CALL("memcpy__Lorg_eclipse_swt_internal_carbon_GDevice_2II\n") + + if (arg0) lparg0 = getGDeviceFields(env, arg0, &_arg0); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) setGDeviceFields(env, arg0, lparg0); } +#endif + +#ifndef NO_memcpy__ILorg_eclipse_swt_internal_carbon_BitMap_2I +JNIEXPORT void JNICALL OS_NATIVE(memcpy__ILorg_eclipse_swt_internal_carbon_BitMap_2I) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + BitMap _arg1, *lparg1=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextTranslateCTM(JNIEnv *env, jclass zz, - jint inContext, jfloat tx, jfloat ty) { - CGContextTranslateCTM((CGContextRef)inContext, tx, ty); + DEBUG_CALL("memcpy__ILorg_eclipse_swt_internal_carbon_BitMap_2I\n") + + if (arg1) lparg1 = getBitMapFields(env, arg1, &_arg1); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) setBitMapFields(env, arg1, lparg1); } +#endif + +#ifndef NO_memcpy__ILorg_eclipse_swt_internal_carbon_Cursor_2I +JNIEXPORT void JNICALL OS_NATIVE(memcpy__ILorg_eclipse_swt_internal_carbon_Cursor_2I) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + Cursor _arg1, *lparg1=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextClipToRect(JNIEnv *env, jclass zz, - jint inContext, jfloat x, jfloat y, jfloat width, jfloat height) { - CGRect r; - r.origin.x= x; - r.origin.y= y; - r.size.width= width; - r.size.height= height; - CGContextClipToRect((CGContextRef)inContext, r); + DEBUG_CALL("memcpy__ILorg_eclipse_swt_internal_carbon_Cursor_2I\n") + + if (arg1) lparg1 = getCursorFields(env, arg1, &_arg1); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) setCursorFields(env, arg1, lparg1); } +#endif + +#ifndef NO_memcpy__ILorg_eclipse_swt_internal_carbon_PixMap_2I +JNIEXPORT void JNICALL OS_NATIVE(memcpy__ILorg_eclipse_swt_internal_carbon_PixMap_2I) + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + PixMap _arg1, *lparg1=NULL; -JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ClipCGContextToRegion(JNIEnv *env, jclass zz, - jint inContext, jshortArray portRect, jint rgnHandle) { - jshort *sa= (*env)->GetShortArrayElements(env, portRect, 0); - jint status= RC(ClipCGContextToRegion((CGContextRef)inContext, (const Rect*) sa, (RgnHandle) rgnHandle)); - (*env)->ReleaseShortArrayElements(env, portRect, sa, 0); - return status; + DEBUG_CALL("memcpy__ILorg_eclipse_swt_internal_carbon_PixMap_2I\n") + + if (arg1) lparg1 = getPixMapFields(env, arg1, &_arg1); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) setPixMapFields(env, arg1, lparg1); } +#endif + +#ifndef NO_memcpy__Lorg_eclipse_swt_internal_carbon_PixMap_2II +JNIEXPORT void JNICALL OS_NATIVE(memcpy__Lorg_eclipse_swt_internal_carbon_PixMap_2II) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + PixMap _arg0, *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextBeginPath(JNIEnv *env, jclass zz, - jint inContext) { - CGContextBeginPath((CGContextRef)inContext); + DEBUG_CALL("memcpy__Lorg_eclipse_swt_internal_carbon_PixMap_2II\n") + + if (arg0) lparg0 = getPixMapFields(env, arg0, &_arg0); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) setPixMapFields(env, arg0, lparg0); } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextMoveToPoint(JNIEnv *env, jclass zz, - jint inContext, jfloat x, jfloat y) { - CGContextMoveToPoint((CGContextRef)inContext, x, y); +#ifndef NO_memcpy__ILorg_eclipse_swt_internal_carbon_Rect_2I +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__ILorg_eclipse_swt_internal_carbon_Rect_2I + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + Rect _arg1, *lparg1=NULL; + + DEBUG_CALL("memcpy__ILorg_eclipse_swt_internal_carbon_Rect_2I\n") + + if (arg1) lparg1 = getRectFields(env, arg1, &_arg1); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) setRectFields(env, arg1, lparg1); } +#endif /* NO_memcpy__ILorg_eclipse_swt_internal_carbon_Rect_2I */ + +#ifndef NO_memcpy__ILorg_eclipse_swt_internal_carbon_FontSelectionQDStyle_2I +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__ILorg_eclipse_swt_internal_carbon_FontSelectionQDStyle_2I + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + FontSelectionQDStyle _arg1, *lparg1=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextAddArc(JNIEnv *env, jclass zz, - jint inContext, jfloat x, jfloat y, jfloat radius, jfloat startAngle, jfloat endAngle, jint clockwise) { - CGContextAddArc((CGContextRef)inContext, x, y, radius, startAngle, endAngle, clockwise); + DEBUG_CALL("memcpy__ILorg_eclipse_swt_internal_carbon_FontSelectionQDStyle_2I\n") + + if (arg1) lparg1 = getFontSelectionQDStyleFields(env, arg1, &_arg1); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) setFontSelectionQDStyleFields(env, arg1, lparg1); } +#endif + +#ifndef NO_memcpy__Lorg_eclipse_swt_internal_carbon_FontSelectionQDStyle_2II +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__Lorg_eclipse_swt_internal_carbon_FontSelectionQDStyle_2II + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + FontSelectionQDStyle _arg0, *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextClosePath(JNIEnv *env, jclass zz, - jint inContext) { - CGContextClosePath((CGContextRef)inContext); + DEBUG_CALL("memcpy__Lorg_eclipse_swt_internal_carbon_FontSelectionQDStyle_2II\n") + + if (arg0) lparg0 = getFontSelectionQDStyleFields(env, arg0, &_arg0); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) setFontSelectionQDStyleFields(env, arg0, lparg0); } +#endif + +#ifndef NO_memcpy__Lorg_eclipse_swt_internal_carbon_HMHelpContentRec_2II +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__Lorg_eclipse_swt_internal_carbon_HMHelpContentRec_2II + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + HMHelpContentRec _arg0, *lparg0=NULL; -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextStrokePath(JNIEnv *env, jclass zz, - jint inContext) { - CGContextStrokePath((CGContextRef)inContext); + DEBUG_CALL("memcpy__Lorg_eclipse_swt_internal_carbon_HMHelpContentRec_2II\n") + + if (arg0) lparg0 = getHMHelpContentRecFields(env, arg0, &_arg0); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) setHMHelpContentRecFields(env, arg0, lparg0); } +#endif -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextFillPath(JNIEnv *env, jclass zz, - jint inContext) { - CGContextFillPath((CGContextRef)inContext); +#ifndef NO_memcpy__ILorg_eclipse_swt_internal_carbon_HMHelpContentRec_2I +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__ILorg_eclipse_swt_internal_carbon_HMHelpContentRec_2I + (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2) +{ + HMHelpContentRec _arg1, *lparg1=NULL; + + DEBUG_CALL("memcpy__ILorg_eclipse_swt_internal_carbon_HMHelpContentRec_2I\n") + + if (arg1) lparg1 = getHMHelpContentRecFields(env, arg1, &_arg1); + memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2); + if (arg1) setHMHelpContentRecFields(env, arg1, lparg1); } +#endif + +#ifndef NO_memcpy__Lorg_eclipse_swt_internal_carbon_Rect_2II +JNIEXPORT void JNICALL OS_NATIVE(memcpy__Lorg_eclipse_swt_internal_carbon_Rect_2II) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2) +{ + Rect _arg0, *lparg0=NULL; + + DEBUG_CALL("memcpy__Lorg_eclipse_swt_internal_carbon_Rect_2II\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextShowGlyphsAtPoint(JNIEnv *env, jclass zz, - jint inContext, jfloat x, jfloat y, jcharArray glyphs) { - jshort *sa= (*env)->GetShortArrayElements(env, glyphs, 0); - size_t count= (*env)->GetArrayLength(env, glyphs); - CGContextShowGlyphsAtPoint((CGContextRef)inContext, x, y, (const CGGlyph*) sa, count); - (*env)->ReleaseShortArrayElements(env, glyphs, sa, 0); + if (arg0) lparg0 = getRectFields(env, arg0, &_arg0); + memcpy((void *)lparg0, (const void *)arg1, (size_t)arg2); + if (arg0) setRectFields(env, arg0, lparg0); } +#endif + +#ifndef NO_memset +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memset + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + DEBUG_CALL("memset\n") -JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextShowTextAtPoint(JNIEnv *env, jclass zz, - jint inContext, jfloat x, jfloat y, jbyteArray cstring) { - jbyte *sa= (*env)->GetByteArrayElements(env, cstring, 0); - size_t count= (*env)->GetArrayLength(env, cstring); - CGContextShowTextAtPoint((CGContextRef)inContext, x, y, (const char*) sa, count); - (*env)->ReleaseByteArrayElements(env, cstring, sa, 0); + memset((void *)arg0, arg1, arg2); } +#endif /* NO_memset */ + +#ifndef NO_ZoomWindowIdeal +JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ZoomWindowIdeal + (JNIEnv *env, jclass that, jint arg0, jshort arg1, jobject arg2) +{ + Point _arg2, *lparg2=NULL; + jint rc; + DEBUG_CALL("ZoomWindowIdeal\n") + if (arg2) lparg2 = getPointFields(env, arg2, &_arg2); + rc = (jint)ZoomWindowIdeal((WindowRef)arg0, (WindowPartCode)arg1, (Point *)lparg2); + if (arg2) setPointFields(env, arg2, lparg2); + return rc; +} +#endif /* NO_ZoomWindowIdeal */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/AEDesc.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/AEDesc.java new file mode 100644 index 0000000000..c403554e85 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/AEDesc.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class AEDesc { + public int descriptorType; + public int dataHandle; + public static final int sizeof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ATSTrapezoid.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ATSTrapezoid.java new file mode 100644 index 0000000000..b070f3aabc --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ATSTrapezoid.java @@ -0,0 +1,24 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class ATSTrapezoid { + //FixedPoint upperLeft; + public int upperLeft_x; + public int upperLeft_y; + //FixedPoint upperRight; + public int upperRight_x; + public int upperRight_y; + //FixedPoint lowerRight; + public int lowerRight_x; + public int lowerRight_y; + //FixedPoint lowerLeft; + public int lowerLeft_x; + public int lowerLeft_y; + public static final int sizeof = 32; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/AlertStdCFStringAlertParamRec.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/AlertStdCFStringAlertParamRec.java new file mode 100644 index 0000000000..e1a3ec6230 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/AlertStdCFStringAlertParamRec.java @@ -0,0 +1,23 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class AlertStdCFStringAlertParamRec { + public int version; + public boolean movable; + public boolean helpButton; + public int defaultText; + public int cancelText; + public int otherText; + public short defaultButton; + public short cancelButton; + public short position; + public int flags; + + public static final int sizeof = 28; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/BitMap.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/BitMap.java new file mode 100644 index 0000000000..fe5e0c041e --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/BitMap.java @@ -0,0 +1,19 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class BitMap { + public int baseAddr; + public short rowBytes; + //Rect bounds; + public short top; + public short left; + public short bottom; + public short right; + public static final int sizeof = 14; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CFRange.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CFRange.java new file mode 100644 index 0000000000..2be75bdf54 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CFRange.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class CFRange { + public int location; + public int length; + public static final int sizeof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CGPoint.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CGPoint.java new file mode 100644 index 0000000000..ca069e654c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CGPoint.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class CGPoint { + public float x; + public float y; + public static final int sizeof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CGRect.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CGRect.java new file mode 100644 index 0000000000..e038da28c8 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/CGRect.java @@ -0,0 +1,16 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class CGRect { + public float x; + public float y; + public float width; + public float height; + public static final int sizeof = 16; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ColorPickerInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ColorPickerInfo.java new file mode 100644 index 0000000000..db9e0323fe --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ColorPickerInfo.java @@ -0,0 +1,38 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class ColorPickerInfo { +// PMColor theColor; + public int profile; + public short red; + public short green; + public short blue; + public int dstProfile; + public int flags; + public short placeWhere; +// Point dialogOrigin + public short h; + public short v; + public int pickerType; + public int eventProc; + public int colorProc; + public int colorProcData; +// Str255 prompt; + public byte [] prompt = new byte [256]; +// PickerMenuItemInfo mInfo; + public short editMenuID; + public short cutItem; + public short copyItem; + public short pasteItem; + public short clearItem; + public short undoItem; + public boolean newColorChosen; +// SInt8 filler; + public static final int sizeof = 312; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlButtonContentInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlButtonContentInfo.java new file mode 100644 index 0000000000..2dd818435d --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlButtonContentInfo.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class ControlButtonContentInfo { + public short contentType; + public int iconRef; + public static final int sizeof = 6; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlFontStyleRec.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlFontStyleRec.java new file mode 100644 index 0000000000..101695b63e --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlFontStyleRec.java @@ -0,0 +1,26 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class ControlFontStyleRec { + public short flags; + public short font; + public short size; + public short style; + public short mode; + public short just; +// RGBColor foreColor; + public short foreColor_red; + public short foreColor_green; + public short foreColor_blue; +// RGBColor backColor; + public short backColor_red; + public short backColor_green; + public short backColor_blue; + public static final int sizeof = 24; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlTabEntry.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlTabEntry.java new file mode 100644 index 0000000000..566c8a6519 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlTabEntry.java @@ -0,0 +1,15 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class ControlTabEntry { + public int icon; + public int name; + public boolean enabled; + public static final int sizeof = 10; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlTabInfoRecV1.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlTabInfoRecV1.java new file mode 100644 index 0000000000..3e7bb7b85e --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ControlTabInfoRecV1.java @@ -0,0 +1,15 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class ControlTabInfoRecV1 { + public short version; + public short iconSuiteID; + public int name; + public static final int sizeof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Cursor.java new file mode 100644 index 0000000000..3fd4e474ab --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Cursor.java @@ -0,0 +1,16 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class Cursor { + public short[] data = new short[16]; + public short[] mask = new short[16]; + public short hotSpot_v; + public short hotSpot_h; + public static final int sizeof = 68; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserCallbacks.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserCallbacks.java new file mode 100644 index 0000000000..deb92c2733 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserCallbacks.java @@ -0,0 +1,23 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class DataBrowserCallbacks { + public int version; + public int v1_itemDataCallback; + public int v1_itemCompareCallback; + public int v1_itemNotificationCallback; + public int v1_addDragItemCallback; + public int v1_acceptDragCallback; + public int v1_receiveDragCallback; + public int v1_postProcessDragCallback; + public int v1_itemHelpContentCallback; + public int v1_getContextualMenuCallback; + public int v1_selectContextualMenuCallback; + public static final int sizeof = 44; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserCustomCallbacks.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserCustomCallbacks.java new file mode 100644 index 0000000000..8a4d9d4834 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserCustomCallbacks.java @@ -0,0 +1,20 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class DataBrowserCustomCallbacks { + public int version; + public int v1_drawItemCallback; + public int v1_editTextCallback; + public int v1_hitTestCallback; + public int v1_trackingCallback; + public int v1_dragRegionCallback; + public int v1_acceptDragCallback; + public int v1_receiveDragCallback; + public static final int sizeof = 32; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserListViewColumnDesc.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserListViewColumnDesc.java new file mode 100644 index 0000000000..ebe6945200 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserListViewColumnDesc.java @@ -0,0 +1,41 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class DataBrowserListViewColumnDesc { + //DataBrowserTableViewColumnDesc propertyDesc; + public int propertyDesc_propertyID; + public int propertyDesc_propertyType; + public int propertyDesc_propertyFlags; + //DataBrowserListViewHeaderDesc headerBtnDesc; + public int headerBtnDesc_version; + public short headerBtnDesc_minimumWidth; + public short headerBtnDesc_maximumWidth; + public short headerBtnDesc_titleOffset; + public int headerBtnDesc_titleString; + public short headerBtnDesc_initialOrder; + //ControlFontStyleRec headerBtnDesc_btnFontStyle; + public short headerBtnDesc_btnFontStyle_flags; + public short headerBtnDesc_btnFontStyle_font; + public short headerBtnDesc_btnFontStyle_size; + public short headerBtnDesc_btnFontStyle_style; + public short headerBtnDesc_btnFontStyle_mode; + public short headerBtnDesc_btnFontStyle_just; + // RGBColor headerBtnDesc_btnFontStyle_foreColor; + public short headerBtnDesc_btnFontStyle_foreColor_red; + public short headerBtnDesc_btnFontStyle_foreColor_green; + public short headerBtnDesc_btnFontStyle_foreColor_blue; + //RGBColor headerBtnDesc_btnFontStyle_backColor; + public short headerBtnDesc_btnFontStyle_backColor_red; + public short headerBtnDesc_btnFontStyle_backColor_green; + public short headerBtnDesc_btnFontStyle_backColor_blue; + //public ControlButtonContentInfo headerBtnDesc_btnContentInfo; + public short headerBtnDesc_btnContentInfo_contentType; + public int headerBtnDesc_btnContentInfo_iconRef; // union field + public static final int sizeof = 58; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserListViewHeaderDesc.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserListViewHeaderDesc.java new file mode 100644 index 0000000000..098bcfb6d5 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/DataBrowserListViewHeaderDesc.java @@ -0,0 +1,37 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class DataBrowserListViewHeaderDesc { + public int version; + public short minimumWidth; + public short maximumWidth; + public short titleOffset; + public int titleString; + public short initialOrder; + // ControlFontStyleRec btnFontStyle; + public short btnFontStyle_flags; + public short btnFontStyle_font; + public short btnFontStyle_size; + public short btnFontStyle_style; + public short btnFontStyle_mode; + public short btnFontStyle_just; + //RGBColor btnFontStyle_foreColor; + public short btnFontStyle_foreColor_red; + public short btnFontStyle_foreColor_green; + public short btnFontStyle_foreColor_blue; + //RGBColor btnFontStyle_backColor; + public short btnFontStyle_backColor_red; + public short btnFontStyle_backColor_green; + public short btnFontStyle_backColor_blue; + //ControlButtonContentInfo btnContentInfo; + public short btnContentInfo_contentType; + public int btnContentInfo_iconRef; + + public static final int sizeof = 46; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/EventRecord.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/EventRecord.java new file mode 100644 index 0000000000..08933d4e24 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/EventRecord.java @@ -0,0 +1,18 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ +public class EventRecord { + public short what; + public int message; + public int when; + //Point where; + public short where_v; + public short where_h; + public short modifiers; + public static final int sizeof = 16; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/FontInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/FontInfo.java new file mode 100644 index 0000000000..f34d743bb5 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/FontInfo.java @@ -0,0 +1,16 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class FontInfo { + public short ascent; + public short descent; + public short widMax; + public short leading; + public static final int sizeof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/FontSelectionQDStyle.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/FontSelectionQDStyle.java new file mode 100644 index 0000000000..369073e322 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/FontSelectionQDStyle.java @@ -0,0 +1,23 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class FontSelectionQDStyle { + public int version; + //FMFontFamilyInstance instance; + public short instance_fontFamily; + public short instance_fontStyle; + public short size; + public boolean hasColor; + public byte reserved; + //RGBColor color + public short color_red; + public short color_green; + public short color_blue; + public static final int sizeof = 18; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/GDevice.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/GDevice.java new file mode 100644 index 0000000000..a11c971b1c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/GDevice.java @@ -0,0 +1,34 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class GDevice { + public short gdRefNum; + public short gdID; + public short gdType; + public int gdITable; + public short gdResPref; + public int gdSearchProc; + public int gdCompProc; + public short gdFlags; + public int gdPMap; + public int gdRefCon; + public int gdNextGD; + //Rect gdRect; + public short left; + public short top; + public short right; + public short bottom; + public int gdMode; + public short gdCCBytes; + public short gdCCDepth; + public int gdCCXData; + public int gdCCXMask; + public int gdExt; + public static final int sizeof = 62; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/HICommand.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/HICommand.java new file mode 100644 index 0000000000..b65b065fe2 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/HICommand.java @@ -0,0 +1,17 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class HICommand { + public int attributes; + public int commandID; + public int menu_menuRef; + public short menu_menuItemIndex; + + public static final int sizeof = 14; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/HMHelpContentRec.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/HMHelpContentRec.java new file mode 100644 index 0000000000..29213140a6 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/HMHelpContentRec.java @@ -0,0 +1,24 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class HMHelpContentRec { + public int version; +// Rect absHotRect; + public short absHotRect_top; + public short absHotRect_left; + public short absHotRect_bottom; + public short absHotRect_right; + public short tagSide; +// HMHelpContent content[2]; + public int content0_contentType; + public int content0_tagCFString; + public int content1_contentType; + public int content1_tagCFString; + public static final int sizeof = 534; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacControlEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacControlEvent.java deleted file mode 100644 index fd4d0bb87d..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacControlEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corp. All rights reserved. - * This file is made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version - */ -package org.eclipse.swt.internal.carbon; - -public class MacControlEvent { - - private int fControlhandle; - private int fPartCode; - private boolean fMouseDown; - private int fDamageRegion; - - public MacControlEvent(int handle, int partCode, boolean mouseDown) { - fControlhandle= handle; - fPartCode= partCode; - fMouseDown= mouseDown; - } - - public MacControlEvent(int handle, int damageRegion) { - fControlhandle= handle; - fDamageRegion= damageRegion; - } - - public int getControlHandle() { - return fControlhandle; - } - - public int getPartCode() { - return fPartCode; - } - - public int getDamageRegionHandle() { - return fDamageRegion; - } - - public boolean isMouseDown() { - return fMouseDown; - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacEvent.java deleted file mode 100644 index f0c2bb120f..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacEvent.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corp. All rights reserved. - * This file is made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version - */ -package org.eclipse.swt.internal.carbon; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.*; - -public class MacEvent { - - private static int fgMouseButtonState; - - private static final boolean EMULATE_RIGHT_BUTTON= true; - - private int fEventRef; - private int fNextHandler; - - public MacEvent() { - fEventRef= -1; - } - - public MacEvent(int eventRef) { - fEventRef= eventRef; - } - - public MacEvent(int eventRef, int nextHandler) { - fEventRef= eventRef; - fNextHandler= nextHandler; - } - - public int getEventRef() { - return fEventRef; - } - - public int getNextHandler() { - return fNextHandler; - } - - public int[] toOldMacEvent() { - if (fEventRef != -1) { - int macEvent[]= new int[6]; - if (OS.ConvertEventRefToEventRecord(fEventRef, macEvent)) - return macEvent; - } - System.out.println("MacEvent.toOldMacEvent: can't convert event"); - return null; - } - - public int getKind() { - if (fEventRef != -1) - return OS.GetEventKind(fEventRef); - System.out.println("MacEvent.getKind: no EventRef"); - return 0; - } - - public int getWhen() { - if (fEventRef != -1) - return (int)(OS.GetEventTime(fEventRef) * 1000.0); - System.out.println("MacEvent.getModifierKeys: no EventRef"); - return 0; - } - - public MacPoint getWhere() { - if (fEventRef != -1) { - short[] loc= new short[2]; - if (OS.GetEventParameter(fEventRef, OS.kEventParamMouseLocation, OS.typeQDPoint, null, null, loc) == OS.kNoErr) { - return new MacPoint(loc[1], loc[0]); - } - } - System.out.println("MacEvent.getWhere: no EventRef"); - return new MacPoint(0, 0); - } - - public Point getWhere2() { - if (fEventRef != -1) { - short[] loc= new short[2]; - if (OS.GetEventParameter(fEventRef, OS.kEventParamMouseLocation, OS.typeQDPoint, null, null, loc) == OS.kNoErr) { - return new Point(loc[1], loc[0]); - } - } - System.out.println("MacEvent.getWhere2: no EventRef"); - return new Point(0, 0); - } - - /** - * Returns the Mac modifiers for this event - */ - public int getModifiers() { - if (fEventRef != -1) - return getEventModifiers(fEventRef); - System.out.println("MacEvent.getModifiers: no EventRef"); - return 0; - } - - /** - * Returns the SWT modifiers for this event - */ - public int getStateMask() { - int stateMask= fgMouseButtonState; - int modifiers= getModifiers (); - if ((modifiers & OS.shiftKey) != 0) stateMask |= SWT.SHIFT; - if ((modifiers & OS.controlKey) != 0) { - if (EMULATE_RIGHT_BUTTON) { - // we only report CONTROL, iff it was not used to emulate the right mouse button - if ((stateMask & SWT.BUTTON3) == 0) stateMask |= SWT.CONTROL; - } else { - stateMask |= SWT.CONTROL; - } - } - if ((modifiers & OS.cmdKey) != 0) stateMask |= SWT.COMMAND; - if ((modifiers & OS.optionKey) != 0) stateMask |= SWT.ALT; - return stateMask; - } - - public int getKeyCode() { - if (fEventRef != -1) - return getKeyCode(fEventRef); - System.out.println("MacEvent.getKeyCode: no EventRef"); - return 0; - } - - /** - * Returns the SWT mouse button - */ - public int getButton() { - if (fEventRef != -1) - return getEventMouseButton(fEventRef); - - System.out.println("MacEvent.getButton: no EventRef"); - return 0; - } - - public boolean isShowContextualMenuClick() { - if (fEventRef == -1) { - System.out.println("MacEvent.isShowContextualMenuClick: no EventRef"); - return false; - } - return (OS.GetEventClass(fEventRef) == OS.kEventClassMouse) && - (getKind() == OS.kEventMouseDown) && - (getButton() == 3); - // return OS.IsShowContextualMenuClick(getData()); - } - - public int getMacCharCodes() { - if (fEventRef != -1) - return getCharCode(fEventRef); - System.out.println("MacEvent.getMacCharCodes: no EventRef"); - return -1; - } - - public String getText() { - if (fEventRef == -1) { - System.out.println("MacEvent.getText: no EventRef"); - return null; - } - int[] actualSize= new int[1]; - OS.GetEventParameter(fEventRef, OS.kEventParamTextInputSendText, OS.typeUnicodeText, null, actualSize, (char[])null); - int size= actualSize[0] / 2; - if (size > 0) { - char[] buffer= new char[size]; - OS.GetEventParameter(fEventRef, OS.kEventParamTextInputSendText, OS.typeUnicodeText, null, null, buffer); - return new String(buffer); - } - return ""; - } - - //---- Carbon event accessors - - public static int getDirectObject(int eRefHandle) { - int[] wHandle= new int[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamDirectObject, OS.typeWindowRef, null, null, wHandle) == OS.kNoErr) - return wHandle[0]; - return 0; - } - - public static short getWindowDefPart(int eRefHandle) { - short[] part= new short[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamWindowDefPart, OS.typeWindowDefPartCode, null, null, part) == OS.kNoErr) - return part[0]; - return 0; - } - - public static int getControlRef(int eRefHandle) { - int[] cHandle= new int[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamControlRef, OS.typeControlRef, null, null, cHandle) == OS.kNoErr) - return cHandle[0]; - return 0; - } - - public static int getEventModifiers(int eRefHandle) { - int[] modifierKeys= new int[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamKeyModifiers, OS.typeUInt32, null, null, modifierKeys) == OS.kNoErr) { - return modifierKeys[0]; - } - System.out.println("MacEvent.getModifierKeys: getEventModifiers error"); - return -1; - } - - private static int getMouseChord(int eRefHandle) { - int[] mouseChord= new int[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamMouseChord, OS.typeUInt32, null, null, mouseChord) == OS.kNoErr) { - return mouseChord[0]; - } - System.out.println("MacEvent.getMouseChord: getMouseChord error"); - return -1; - } - - public static int getKeyCode(int eRefHandle) { - int[] keyCode= new int[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamKeyCode, OS.typeUInt32, null, null, keyCode) == OS.kNoErr) - return keyCode[0]; - System.out.println("MacEvent.getMouseChord: getKeyCode error"); - return -1; - } - - public static int getCharCode(int eRefHandle) { - byte[] charCode= new byte[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamKeyMacCharCodes, OS.typeChar, null, null, charCode) == OS.kNoErr) - return charCode[0]; - return -1; - } - - private static short getEventMouseButton(int eRefHandle) { - short[] mouseButtons= new short[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamMouseButton, OS.typeMouseButton, null, null, mouseButtons) == OS.kNoErr) { - short button= mouseButtons[0]; - switch (button) { - case OS.kEventMouseButtonPrimary: // left mouse button - if (EMULATE_RIGHT_BUTTON) { - if ((getEventModifiers(eRefHandle) & OS.controlKey) != 0) - return 3; - } - return 1; - case OS.kEventMouseButtonSecondary: // right mouse button - return 3; - case OS.kEventMouseButtonTertiary: // middle mouse button - return 2; - default: - return button; - } - } - return 0; - } - - public static void trackStateMask(int event, int kind) { - switch (kind) { - case OS.kEventMouseDown: - case OS.kEventMouseDragged: - case OS.kEventMouseUp: - int chord= getMouseChord(event); - if (chord != -1) { - fgMouseButtonState= 0; - if ((chord & 1) != 0) { - int modifiers= getEventModifiers(event); - if (EMULATE_RIGHT_BUTTON && ((modifiers & OS.controlKey) != 0)) { - fgMouseButtonState |= SWT.BUTTON3; - } else { - fgMouseButtonState |= SWT.BUTTON1; - } - } - if ((chord & 2) != 0) - fgMouseButtonState |= SWT.BUTTON3; - if ((chord & 4) != 0) - fgMouseButtonState |= SWT.BUTTON2; - } - break; - case OS.kEventMouseMoved: - fgMouseButtonState= 0; - break; - } - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacFont.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacFont.java deleted file mode 100644 index ba7b874b46..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacFont.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corp. All rights reserved. - * This file is made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version - */ -package org.eclipse.swt.internal.carbon; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; - -public class MacFont { - - public short fID= 1; - public short fSize= 12; - public short fFace= 0; - - - public MacFont() { - } - - public MacFont(String name, int size, int face) { - - fFace= OS.normal; - if ((face & SWT.BOLD) != 0) - fFace |= OS.bold; - if ((face & SWT.ITALIC) != 0) - fFace |= OS.italic; - - if ("Courier".equals(name)) { - name= "Monaco"; - } - - if ("MS Sans Serif".equals(name)) { - MacFont f= Display.getThemeFont(OS.kThemeSystemFont); - fID= f.fID; - fSize= f.fSize; - return; - } - - if (size < 10) - size= 10; - - short id= OS.FMGetFontFamilyFromName(MacUtil.Str255(name)); - //System.out.print("MacFont(" + name + ", " + size + ", " + face + "): "); - if (id == OS.kInvalidFontFamily) { - fID= (short) 1; - //System.out.println("not found"); - } else { - fID= id; - //System.out.println(fID); - } - fSize= (short)size; - } - - public MacFont(short ID, short size, short face) { - fID= ID; - fSize= size; - fFace= OS.normal; - if ((face & SWT.BOLD) != 0) - fFace |= OS.bold; - if ((face & SWT.ITALIC) != 0) - fFace |= OS.italic; - } - - public MacFont(short ID) { - fID= ID; - } - - public String getName() { - byte[] name= new byte[256]; - if (OS.FMGetFontFamilyName(fID, name) == OS.kNoErr) - return MacUtil.toString(name); - return "no name"; - } - - public short getSize() { - return fSize; - } - - public int getFace() { - int face= 0; - if ((fFace & OS.bold) != 0) - face |= SWT.BOLD; - if ((fFace & OS.italic) != 0) - face |= SWT.ITALIC; - return face; - } - - public void installInGrafPort() { - OS.TextFont(fID); - OS.TextSize(fSize); - OS.TextFace(fFace); - } - - public boolean equals(Object object) { - if (object == this) return true; - if (!(object instanceof MacFont)) return false; - MacFont font= (MacFont) object; - return fID == font.fID && fSize == font.fSize && fFace == font.fFace; - } - - public int hashCode() { - return (fID << 16) | (fSize << 8) | fFace; - } - - public String toString() { - return fID + "," + fSize + "," + fFace; - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacMouseEvent.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacMouseEvent.java deleted file mode 100644 index e21d230c5d..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacMouseEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corp. All rights reserved. - * This file is made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version - */ -package org.eclipse.swt.internal.carbon; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.SWT; - -public class MacMouseEvent { - - private int fWhen; - private Point fWhere; - private int fState; - private int fButton; - private MacEvent fMacEvent; - - public MacMouseEvent() { - } - - public MacMouseEvent(int button, Point where) { - fButton= button; - fWhere= where; - fState= SWT.BUTTON1; - } - - public MacMouseEvent(MacEvent me) { - fMacEvent= me; - fWhen= me.getWhen(); - fWhere= me.getWhere2(); - fState= me.getStateMask(); - fButton= me.getButton(); - } - - public int getWhen() { - return fWhen; - } - - public Point getWhere() { - return fWhere; - } - - public int getState() { - return fState; - } - - public int getButton() { - return fButton; - } - - public int[] toOldMacEvent() { - if (fMacEvent != null) - return fMacEvent.toOldMacEvent(); - System.err.println("MacMouseEvent.toOldMacEvent: nyi"); - return null; - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacPoint.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacPoint.java deleted file mode 100644 index 06ed351b5f..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacPoint.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corp. All rights reserved. - * This file is made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version - */ -package org.eclipse.swt.internal.carbon; - -import org.eclipse.swt.graphics.Point; - -public class MacPoint { - - // 0: vertical - // 1: horizontal - private short[] fData= new short[2]; - - public MacPoint() { - } - - public MacPoint(short x, short y) { - fData[0]= y; - fData[1]= x; - } - - public MacPoint(int x, int y) { - fData[0]= (short) y; - fData[1]= (short) x; - } - - public MacPoint(Point p) { - fData[0]= (short) p.y; - fData[1]= (short) p.x; - } - - public short[] getData() { - return fData; - } - - public int getX() { - return fData[1]; - } - - public int getY() { - return fData[0]; - } - - public Point toPoint() { - return new Point(fData[1], fData[0]); - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacRect.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacRect.java deleted file mode 100644 index 5a0b3d0631..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacRect.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corp. All rights reserved. - * This file is made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version - */ -package org.eclipse.swt.internal.carbon; - -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.graphics.Point; - -public class MacRect { - - // 0: top - // 1: left - // 2: bottom - // 3: right - private short[] fData= new short[4]; - - public MacRect() { - } - - public MacRect(int x, int y, int w, int h) { - fData[0]= (short) y; - fData[1]= (short) x; - fData[2]= (short) (y+h); - fData[3]= (short) (x+w); - } - - public MacRect(Rectangle r) { - fData[0]= (short) (r.y); - fData[1]= (short) (r.x); - fData[2]= (short) (r.y+r.height); - fData[3]= (short) (r.x+r.width); - } - - public void set(int x, int y, int w, int h) { - fData[0]= (short) y; - fData[1]= (short) x; - fData[2]= (short) (y+h); - fData[3]= (short) (x+w); - } - - public short[] getData() { - return fData; - } - - public Rectangle toRectangle() { - return new Rectangle(fData[1], fData[0], fData[3]-fData[1], fData[2]-fData[0]); - } - - public Point getSize() { - return new Point(fData[3]-fData[1], fData[2]-fData[0]); - } - - public Point getLocation() { - return new Point(fData[1], fData[0]); - } - - public void setLocation(int x, int y) { - int w= fData[3]-fData[1]; - int h= fData[2]-fData[0]; - fData[0]= (short)(y); - fData[1]= (short)(x); - fData[2]= (short)(y+h); - fData[3]= (short)(x+w); - } - - public void setSize(int width, int height) { - fData[2]= (short)(fData[0]+ height); - fData[3]= (short)(fData[1]+ width); - } - - public int getX() { - return fData[1]; - } - - public int getY() { - return fData[0]; - } - - public int getWidth() { - return fData[3]-fData[1]; - } - - public int getHeight() { - return fData[2]-fData[0]; - } - - public boolean isEmpty() { - return (fData[0] >= fData[2]) || (fData[1] >= fData[3]); - } - - public boolean contains(Point p) { - return p.x >= fData[1] && p.x < fData[3] && p.y >= fData[0] && p.y < fData[2]; - } - - public void inset(int left, int top, int right, int bottom) { - fData[0]+= top; - fData[1]+= left; - fData[2]-= bottom; - fData[3]-= right; - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacUtil.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacUtil.java deleted file mode 100644 index ba33b09b19..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MacUtil.java +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corp. All rights reserved. - * This file is made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version - */ -package org.eclipse.swt.internal.carbon; - -import org.eclipse.swt.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.Callback; - -public class MacUtil { - - public final static boolean DEBUG; - - public final static boolean USE_MENU_ICONS; - - /** Prevent use of standard Mac shortcuts Cmd-Q, Cmd-H */ - public final static boolean KEEP_MAC_SHORTCUTS; - public final static boolean FULL_KBD_NAV; - - /** use HIViews instead of ControlManager controls */ - public final static boolean HIVIEW; - /** use setFrame calls instead of setBounds */ - public final static boolean USE_FRAME; - - static final char MNEMONIC = '&'; - - static { - DEBUG= false; - USE_MENU_ICONS= true; - KEEP_MAC_SHORTCUTS= true; - FULL_KBD_NAV= true; - HIVIEW= false; - USE_FRAME= false; - } - - ////////////////////////////////////////////////////////////////////// - - private static int fViewClassID= 0; - - static int createCallback(String method, int argCount) { - Callback cb= new Callback(MacUtil.class, method, argCount); - int proc= cb.getAddress(); - return proc; - } - - static int hiobProc(int a, int b, int c) { - System.out.println("hiobProc"); - return OS.kNoErr; - } - - static int createHIView() { - int rc; - - if (fViewClassID == 0) { - - fViewClassID= OS.CFStringCreateWithCharacters("org.eclipse.swt.hiview"); - int baseClassID= OS.CFStringCreateWithCharacters("com.apple.hiview"); - - int[] events= new int[] { - OS.kEventClassHIObject, OS.kEventHIObjectConstruct, - //OS.kEventClassHIObject, OS.kEventHIObjectInitialize, - OS.kEventClassHIObject, OS.kEventHIObjectDestruct, - - OS.kEventClassControl, OS.kEventControlDraw, - OS.kEventClassControl, OS.kEventControlAddedSubControl, - OS.kEventClassControl, OS.kEventControlRemovingSubControl, - }; - - int hiobProc= createCallback("hiobProc", 3); - - int[] tmp= new int[1]; - rc= OS.HIObjectRegisterSubclass(fViewClassID, baseClassID, 0, hiobProc, events, 0, tmp); - System.out.println("HIObjectRegisterSubclass: " + rc); - - OS.CFRelease(baseClassID); - } - - int[] oref= new int[1]; - //rc= OS.HIObjectCreate(fViewClassID, 0, oref); - rc= OS.HIObjectCreate(OS.CFStringCreateWithCharacters("com.apple.hiview"), 0, oref); - System.out.println("HIObjectCreate: " + rc + " " + oref[0]); - return oref[0]; - } - - ////////////////////////////////////////////////////////////////////// - - public static int getChild(int handle, int[] t, int n, int i) { - int index= (n-1 - i); - int status= OS.GetIndexedSubControl(handle, (short)(index+1), t); - if (status != OS.kNoErr) - System.out.println("MacUtil.getChild: error"); - return status; - } - - public static int indexOf(int parentHandle, int handle) { - int n= countSubControls(parentHandle); - int[] outControl= new int[1]; - for (int i= 0; i < n; i++) { - if (getChild(parentHandle, outControl, n, i) == OS.kNoErr) - if (outControl[0] == handle) - return i; - } - return -1; - } - - /** - * Inserts the given child at position in the parent. - * If pos is out of range the child is added at the end (below all other). - */ - private static void insertControl(int controlHandle, int parentControlHandle, int pos) { - - - int n= countSubControls(parentControlHandle); - - int should= pos; - if (should < 0 || should > n) - should= n; - - boolean add= false; - if (getSuperControl(controlHandle) != parentControlHandle) { - add= true; - } else { - /* - String w1= getHIObjectClassID(parentControlHandle); - String w2= getHIObjectClassID(controlHandle); - System.out.println("MacUtil.insertControl: already there: " + w1 + " " + w2); - */ - if (n == 1) - return; - } - - if (n == 0) { - OS.HIViewAddSubview(parentControlHandle, controlHandle); - pos= 0; - } else { - if (pos >= 0 && pos < n) { - int[] where= new int[1]; - getChild(parentControlHandle, where, n, pos); - if (add) - OS.HIViewAddSubview(parentControlHandle, controlHandle); - OS.HIViewSetZOrder(controlHandle, OS.kHIViewZOrderAbove, where[0]); - } else { - if (add) - OS.HIViewAddSubview(parentControlHandle, controlHandle); - if (OS.HIViewSetZOrder(controlHandle, OS.kHIViewZOrderBelow, 0) != OS.kNoErr) - System.out.println("error 2"); - pos= n; - } - } - - // verify correct position - int i= indexOf(parentControlHandle, controlHandle); - if (i != should) - System.out.println("MacUtil.insertControl: is: "+i+" should: "+ should + " n:" + n + " add: " + add); - } - - /** - * Adds the given child at the end. - */ - public static void addControl(int controlHandle, int parentControlHandle) { - insertControl(controlHandle, parentControlHandle, -1); - } - - public static int getVisibleRegion(int cHandle, int result, boolean includingTop) { - int tmpRgn= OS.NewRgn(); - - getControlRegion(cHandle, OS.kControlEntireControl, result); - - int parent= cHandle; - while ((parent= MacUtil.getSuperControl(parent)) != 0) { - getControlRegion(parent, OS.kControlContentMetaPart, tmpRgn); - OS.SectRgn(result, tmpRgn, result); - } - - if (includingTop) { - int n= countSubControls(cHandle); - if (n > 0) { - //System.out.println("have children on top"); - int[] outHandle= new int[1]; - for (int i= 0; i < n; i++) { - int index= i; // was: n-1-i - if (OS.GetIndexedSubControl(cHandle, (short)(index+1), outHandle) == 0) { // indices are 1 based - if (OS.IsControlVisible(outHandle[0])) { - getControlRegion(outHandle[0], OS.kControlStructureMetaPart, tmpRgn); - OS.DiffRgn(result, tmpRgn, result); - } - } else - throw new SWTError(); - } - } - } - - OS.DisposeRgn(tmpRgn); - - return OS.kNoErr; - } - - private static int find(int cHandle, Rectangle parentBounds, MacRect tmp, Point where) { - - if (! OS.IsControlVisible(cHandle)) - return 0; - if (! OS.IsControlActive(cHandle)) - return 0; - - OS.GetControlBounds(cHandle, tmp.getData()); - Rectangle rr= tmp.toRectangle(); - if (parentBounds != null) - rr= parentBounds.intersection(rr); - - int n= countSubControls(cHandle); - if (n > 0) { - int[] outHandle= new int[1]; - for (int i= 0; i < n; i++) { - int index= (n-1-i); - if (OS.GetIndexedSubControl(cHandle, (short)(index+1), outHandle) == 0) { // indices are 1 based - int result= find(outHandle[0], rr, tmp, where); - if (result != 0) - return result; - } - } - } - - if (rr.contains(where)) - return cHandle; - return 0; - } - - ////////////////////////////////////////////////////////////////////// - - public static Point toControl(int cHandle, Point point) { - MacPoint mp= new MacPoint(point); - - int wHandle= OS.GetControlOwner(cHandle); - int port= OS.GetWindowPort(wHandle); - OS.QDGlobalToLocalPoint(port, mp.getData()); - - MacRect bounds= new MacRect(); - OS.GetControlBounds(cHandle, bounds.getData()); - - Point p= mp.toPoint(); - p.x-= bounds.getX(); - p.y-= bounds.getY(); - - /* - float[] p2= new float[2]; - p2[0]= mp.getX(); - p2[1]= mp.getY(); - OS.HIViewConvertPoint(p2, 0, cHandle); - System.out.println("MacUtil.toControl: " + p + " " + p2[0] + " " + p2[1]); - */ - - return p; - } - - public static Point toDisplay(int cHandle, Point point) { - MacRect bounds= new MacRect(); - OS.GetControlBounds(cHandle, bounds.getData()); - MacPoint mp= new MacPoint(point.x+bounds.getX(), point.y+bounds.getY()); - - int wHandle= OS.GetControlOwner(cHandle); - int port= OS.GetWindowPort(wHandle); - OS.QDLocalToGlobalPoint(port, mp.getData()); - - return mp.toPoint(); - } - - private static void getControlRegion(int cHandle, short part, int rgn) { - if (true) { - short[] bounds= new short[4]; - OS.GetControlBounds(cHandle, bounds); - OS.RectRgn(rgn, bounds); - } else { - OS.GetControlRegion(cHandle, part, rgn); - } - } - - // Hit detection on the Mac is reversed and doesn't consider clipping, - // so we have to do it ourselves - - public static int findControlUnderMouse(MacPoint where, int wHandle, short[] cpart) { - - int root; - if (true) { - int[] rootHandle= new int[1]; - int rc= OS.GetRootControl(wHandle, rootHandle); - if (rc != OS.kNoErr) { - System.out.println("MacUtil.findControlUnderMouse: " + rc); - return 0; - } - root= rootHandle[0]; - } else { - root= OS.HIViewGetRoot(wHandle); - } - Point w= where.toPoint(); - int cHandle= find(root, null, new MacRect(), w); - if (cHandle != 0 && cpart != null && cpart.length > 0) { - cpart[0]= OS.TestControl(cHandle, where.getData()); - //System.out.println("findControlUnderMouse: " + cpart[0]); - } - return cHandle; - } - - private static int countSubControls(int cHandle) { - short[] cnt= new short[1]; - int status= OS.CountSubControls(cHandle, cnt); - switch (status) { - case OS.kNoErr: - return cnt[0]; - case OS.errControlIsNotEmbedder: - //System.out.println("MacUtil.countSubControls: errControlIsNotEmbedder"); - break; - case -30599: // OS.controlHandleInvalidErr - System.out.println("MacUtil.countSubControls: controlHandleInvalidErr"); - break; - default: - System.out.println("MacUtil.countSubControls: " + status); - break; - } - return 0; - } - - public static String getStringAndRelease(int sHandle) { - int length= OS.CFStringGetLength(sHandle); - char[] buffer= new char[length]; - OS.CFStringGetCharacters(sHandle, 0, length, buffer); - OS.CFRelease(sHandle); - return new String(buffer); - } - - public static byte[] Str255(String s) { - int l= 0; - if (s != null) - l= s.length(); - if (l > 255) { - throw new SWTError(SWT.ERROR_INVALID_RANGE); - //System.out.println("MacUtil.Str255: string length > 255"); - } - byte[] b= new byte[l+1]; - b[0]= (byte) l; - for (int i= 0; i < l; i++) - b[i+1]= (byte) s.charAt(i); - return b; - } - - public static String toString(byte[] str255) { - int n= str255[0]; - char[] c= new char[n]; - for (int i= 0; i < n; i++) - c[i]= (char) str255[i+1]; - return new String(c); - } - - public static int OSType(String s) { - return ((s.charAt(0) & 0xff) << 24) | ((s.charAt(1) & 0xff) << 16) | ((s.charAt(2) & 0xff) << 8) | (s.charAt(3) & 0xff); - } - - public static String getHIObjectClassID(int handle) { - int sh= OS.HIObjectCopyClassID(handle); - return getStringAndRelease(sh); - } - - /** - * Create a new control and embed it in the given parent control. - */ - public static int newControl(int parentControlHandle, short procID) { - return newControl(parentControlHandle, -1, (short)0, (short)0, (short)0, procID); - } - - /** - * Create a new control and embed it in the given parent control. - */ - public static int newControl(int parentControlHandle, short init, short min, short max, short procID) { - return newControl(parentControlHandle, -1, init, min, max, procID); - } - - /** - * Create a new control and embed it in the given parent control. - */ - public static int newControl(int parentControlHandle, int pos, short init, short min, short max, short procID) { - int controlHandle; - if (HIVIEW) { - controlHandle= OS.NewControl(0, false, init, min, max, procID); - insertControl(controlHandle, parentControlHandle, pos); - OS.HIViewSetVisible(controlHandle, true); - OS.HIViewSetNeedsDisplay(controlHandle, true); - } else { - int windowHandle= OS.GetControlOwner(parentControlHandle); - controlHandle= OS.NewControl(windowHandle, false, init, min, max, procID); - insertControl(controlHandle, parentControlHandle, pos); - initLocation(controlHandle); - OS.HIViewSetVisible(controlHandle, true); - } - - return controlHandle; - } - - public static int createDrawingArea(int parentControlHandle, int pos, boolean visible, int width, int height, int border) { - int features= OS.kControlSupportsEmbedding | OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick; - int controlHandle; - if (HIVIEW) { - features |= OS.kControlHandlesTracking; - controlHandle= OS.NewControl(0, false, (short)features, (short)0, (short)0, OS.kControlUserPaneProc); - OS.SizeControl(controlHandle, (short)width, (short)height); - insertControl(controlHandle, parentControlHandle, pos); - OS.HIViewSetVisible(controlHandle, visible); - OS.HIViewSetNeedsDisplay(controlHandle, true); - } else { - int windowHandle= OS.GetControlOwner(parentControlHandle); - controlHandle= OS.NewControl(windowHandle, false, (short)features, (short)0, (short)0, OS.kControlUserPaneProc); - OS.SizeControl(controlHandle, (short)width, (short)height); - insertControl(controlHandle, parentControlHandle, pos); - initLocation(controlHandle); - OS.HIViewSetVisible(controlHandle, visible); - } - return controlHandle; - } - - public static void initLocation(int cHandle) { - int parent= getSuperControl(cHandle); - short[] bounds= new short[4]; - OS.GetControlBounds(parent, bounds); - short x= bounds[1]; - short y= bounds[0]; - if (x > 0 || y > 0) - OS.MoveControl(cHandle, x, y); - } - - /** - * Returns the parent of the given control or null if the control is a root control. - */ - public static int getSuperControl(int cHandle) { - - int wHandle= OS.GetControlOwner(cHandle); - if (wHandle == 0) { - //System.out.println("MacUtil.getSuperControl: GetControlOwner error"); - return 0; - } - int[] rootHandle= new int[1]; - OS.GetRootControl(wHandle, rootHandle); - if (cHandle == rootHandle[0]) - return 0; - - int[] parentHandle= new int[1]; - int rc= OS.GetSuperControl(cHandle, parentHandle); - if (rc != OS.kNoErr) - System.out.println("MacUtil.getSuperControl: " + rc); - return parentHandle[0]; - } - - public static void dump(int matchHandle) { - int wHandle= OS.GetControlOwner(matchHandle); - int[] rootHandle= new int[1]; - OS.GetRootControl(wHandle, rootHandle); - dump(rootHandle[0], 0, matchHandle); - System.out.println(); - } - - public static void dump(int cHandle, int level, int matchHandle) { - for (int x= 0; x < level; x++) - System.out.print(" "); - Widget w= WidgetTable.get(cHandle); - if (w != null) - System.out.print(w); - else - System.out.print(cHandle); - - MacRect bounds= new MacRect(); - OS.GetControlBounds(cHandle, bounds.getData()); - System.out.print(" " + bounds.toRectangle()); - - if (cHandle == matchHandle) - System.out.println(" ******************"); - else - System.out.println(); - - int n= countSubControls(cHandle); - if (n > 0) { - int[] outHandle= new int[1]; - for (int i= 0; i < n; i++) { - if (OS.GetIndexedSubControl(cHandle, (short)(i+1), outHandle) == 0) - dump(outHandle[0], level+1, matchHandle); - } - } - } - - public static Point computeSize(int handle) { - if (OS.IsValidControlHandle(handle)) { - MacRect rect= new MacRect(); - short[] base= new short[1]; - OS.GetBestControlRect(handle, rect.getData(), base); - if (rect.isEmpty()) - System.out.println("MacUtil.computeSize: 0 size"); - return rect.getSize(); - } - System.out.println("MacUtil.computeSize: unknown handle type"); - return new Point(50, 50); - } - - public static int getDisplayWidth() { - MacRect bounds= new MacRect(); - OS.GetAvailableWindowPositioningBounds(OS.GetMainDevice(), bounds.getData()); - return bounds.getWidth(); - } - - public static int getDisplayHeight() { - MacRect bounds= new MacRect(); - OS.GetAvailableWindowPositioningBounds(OS.GetMainDevice(), bounds.getData()); - return bounds.getHeight(); - } - - public static String toString(int i) { - StringBuffer sb= new StringBuffer(); - sb.append((char)((i & 0xff000000) >> 24)); - sb.append((char)((i & 0x00ff0000) >> 16)); - sb.append((char)((i & 0x0000ff00) >> 8)); - sb.append((char)((i & 0x000000ff) >> 0)); - return sb.toString(); - } - - public static String removeMnemonics(String s) { - if (s != null) { - int l= s.length(); - if (l > 0) { - char[] buf= new char[l]; - int j= 0; - for (int i= 0; i < l; i++) { - char c= s.charAt(i); - if (c != MNEMONIC) - buf[j++]= c; - } - return new String(buf, 0, j); - } - } - return s; - } - - public static void RGBBackColor(int packed) { - if ((packed & 0xff000000) == 0) { - OS.RGBBackColor((short)(((packed >> 16) & 0xFF) * 257), - (short)(((packed >> 8) & 0xFF) * 257), - (short)(((packed) & 0xFF) * 257)); - } else { - OS.RGBBackColor((short)0xFFFF, (short)0xFFFF, (short)0xFFFF); - } - } - - public static void RGBForeColor(int packed) { - if ((packed & 0xff000000) == 0) { - OS.RGBForeColor((short)(((packed >> 16) & 0xFF) * 257), - (short)(((packed >> 8) & 0xFF) * 257), - (short)(((packed) & 0xFF) * 257)); - } else { - OS.RGBForeColor((short)0xFFFF, (short)0xFFFF, (short)0xFFFF); - } - } - - public static int[] getDataBrowserItems(int dataBrowserHandle, int containerID, int state, boolean recurse) { - int resultHandle= 0; - try { - resultHandle= OS.NewHandle(0); - if (OS.GetDataBrowserItems(dataBrowserHandle, containerID, recurse, state, resultHandle) == OS.kNoErr) { - int itemCount= OS.GetHandleSize(resultHandle) / 4; // sizeof(int) - if (itemCount > 0) { - int resultIDs[]= new int[itemCount]; - OS.getHandleData(resultHandle, resultIDs); - return resultIDs; - } - } - } finally { - OS.DisposeHandle(resultHandle); - } - return new int[0]; - } - - public static int[] getSelectionIDs(int dataBrowserHandle, int containerID, boolean recurse) { - return getDataBrowserItems(dataBrowserHandle, containerID, OS.kDataBrowserItemIsSelected, recurse); - } - -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MenuTrackingData.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MenuTrackingData.java new file mode 100644 index 0000000000..6c16cf6678 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/MenuTrackingData.java @@ -0,0 +1,22 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class MenuTrackingData { + public int menu; + public short itemSelected; + public short itemUnderMouse; +// Rect itemRect; + public short top; + public short left; + public short bottom; + public short right; + public int virtualMenuTop; + public int virtualMenuBottom; + public static int sizeof = 24; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/NavDialogCreationOptions.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/NavDialogCreationOptions.java new file mode 100644 index 0000000000..ab11044cd1 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/NavDialogCreationOptions.java @@ -0,0 +1,28 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class NavDialogCreationOptions { + public short version; + public int optionFlags; +// Point location; + public short location_h; + public short location_v; + public int clientName; + public int windowTitle; + public int actionButtonLabel; + public int cancelButtonLabel; + public int saveFileName; + public int message; + public int preferenceKey; + public int popupExtension; + public int modality; + public int parentWindow; +// char reserved[16]; + public static final int sizeof = 66; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/NavReplyRecord.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/NavReplyRecord.java new file mode 100644 index 0000000000..40ab0693da --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/NavReplyRecord.java @@ -0,0 +1,27 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class NavReplyRecord { + public short version; + public boolean validRecord; + public boolean replacing; + public boolean isStationery; + public boolean translationNeeded; + //AEDescList selection; + public int selection_descriptorType; + public int selection_dataHandle; + public short keyScript; + public int fileTranslation; + public int reserved1; + public int saveFileName; + public boolean saveFileExtensionHidden; + public byte reserved2; + public byte[] reserved = new byte[225]; + public static final int sizeof = 256; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java index 0559be3b8b..643bc3e4cf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java @@ -1,12 +1,11 @@ +package org.eclipse.swt.internal.carbon; + /* - * Copyright (c) 2002 IBM Corp. All rights reserved. + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. * This file is made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * - * Andre Weinand, OTI - Initial version */ -package org.eclipse.swt.internal.carbon; import org.eclipse.swt.internal.Library; @@ -17,1414 +16,1061 @@ public class OS { Library.loadLibrary ("swt"); } - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Carbon Toolbox native API - ////////////////////////////////////////////////////////////////////////////////////////////////// - - // status - public static final int kNoErr = 0; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Appearance Manager - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - public static final short kThemeBrushDialogBackgroundActive = 1; /* Dialogs */ - public static final short kThemeBrushDialogBackgroundInactive = 2; /* Dialogs */ - public static final short kThemeBrushAlertBackgroundActive = 3; - public static final short kThemeBrushAlertBackgroundInactive = 4; - public static final short kThemeBrushModelessDialogBackgroundActive = 5; - public static final short kThemeBrushModelessDialogBackgroundInactive = 6; - public static final short kThemeBrushUtilityWindowBackgroundActive = 7; /* Miscellaneous */ - public static final short kThemeBrushUtilityWindowBackgroundInactive = 8; /* Miscellaneous */ - public static final short kThemeBrushListViewSortColumnBackground = 9; /* Finder */ - public static final short kThemeBrushListViewBackground = 10; - public static final short kThemeBrushIconLabelBackground = 11; - public static final short kThemeBrushListViewSeparator = 12; - public static final short kThemeBrushChasingArrows = 13; - public static final short kThemeBrushDragHilite = 14; - public static final short kThemeBrushDocumentWindowBackground = 15; - public static final short kThemeBrushFinderWindowBackground = 16; - - public static final short kThemeSystemFont = 0; - public static final short kThemeSmallSystemFont = 1; - public static final short kThemeSmallEmphasizedSystemFont = 2; - public static final short kThemeViewsFont = 3; /* The following ID's are only available with MacOS X or CarbonLib 1.3 and later*/ - public static final short kThemeEmphasizedSystemFont = 4; - public static final short kThemeApplicationFont = 5; - public static final short kThemeLabelFont = 6; - public static final short kThemeMenuTitleFont = 100; - public static final short kThemeMenuItemFont = 101; - public static final short kThemeMenuItemMarkFont = 102; - public static final short kThemeMenuItemCmdKeyFont = 103; - public static final short kThemeWindowTitleFont = 104; - public static final short kThemePushButtonFont = 105; - public static final short kThemeUtilityWindowTitleFont = 106; - public static final short kThemeAlertHeaderFont = 107; - public static final short kThemeCurrentPortFont = 200; - - public static final short kThemeStateInactive = 0; - public static final short kThemeStateActive = 1; - public static final short kThemeStatePressed = 2; - public static final short kThemeStateRollover = 6; - public static final short kThemeStateUnavailable = 7; - public static final short kThemeStateUnavailableInactive = 8; - - public static final short kThemeSmallBevelButton = 8; /* small-shadow bevel button */ - - public static final short kThemeButtonOff = 0; - public static final short kThemeButtonOn = 1; - public static final short kThemeButtonMixed = 2; - - public static final short smSystemScript = -1; /* designates system script.*/ - - public static native int RegisterAppearanceClient(); - - public static native int SetThemeWindowBackground(int wHandle, short brush, boolean update); - - public static native int DrawThemeTextBox(int sHandle, short fontID, int state, boolean wrapToWidth, - short[] bounds, short just, int context); - - public static native int GetThemeTextDimensions(int sHandle, short fontID, int state, boolean wrapToWidth, - short[] ioBounds, short[] baseLine); - - public static native int DrawThemeEditTextFrame(short[] bounds, int state); - public static native int DrawThemeFocusRect(short[] bounds, boolean hasFocus); - public static native int DrawThemeGenericWell(short[] bounds, int state, boolean fillCenter); - public static native int DrawThemeSeparator(short[] bounds, int state); - - public static native int GetThemeFont(short themeFontId, short scriptCode, - byte[] fontName, short[] fontSize, byte[] style); - - public static native int DrawThemeButton(short[] bounds, short kind, short[] newInfo, short[] prevInfo, - int eraseProc, int labelProc, int userData); - - public static native int SetThemeBackground(short inBrush, short depth, boolean isColorDevice); - public static native int GetThemeDrawingState(int[] state); - public static native int SetThemeDrawingState(int state, boolean disposeNow); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Event Manager - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - // event what - public static final short nullEvent = 0; - public static final short mouseDown = 1; - public static final short mouseUp = 2; - public static final short keyDown = 3; - public static final short keyUp = 4; - public static final short autoKey = 5; - public static final short updateEvt = 6; - public static final short diskEvt = 7; - public static final short activateEvt = 8; - public static final short osEvt = 15; - public static final short kHighLevelEvent = 23; - - // masks - public static final short updateMask = 1 << updateEvt; - public static final short everyEvent = (short) 0xFFFF; - - // masks - public static final int charCodeMask = 0x000000FF; - public static final int keyCodeMask = 0x0000FF00; - - // EventModifiers - public static final int activeFlag = 1; /* activate? (activateEvt and mouseDown)*/ - public static final int btnState = 1 << 7; /* state of button?*/ - public static final int cmdKey = 1 << 8; /* command key down?*/ - public static final int shiftKey = 1 << 9; /* shift key down?*/ - public static final int alphaLock = 1 << 10; /* alpha lock down?*/ - public static final int optionKey = 1 << 11; /* option key down?*/ - public static final int controlKey = 1 << 12; /* control key down?*/ - public static final int rightShiftKey = 1 << 13; /* right shift key down?*/ - public static final int rightOptionKey = 1 << 14; /* right Option key down?*/ - public static final int rightControlKey = 1 << 15; /* right Control key down?*/ - - public static native boolean GetNextEvent(short eventMask, int[] eventData); - public static native boolean WaitNextEvent(short eventMask, int[] eventData, int sleepTime); - public static native boolean StillDown(); - public static native void GetMouse(short[] where); - public static native void AEProcessAppleEvent(int[] eventData); - public static native int MenuEvent(int[] eventData); - public static native int PostEvent(short eventNum, int eventMsg); - public static native int GetKeyboardFocus(int wHandle, int[] cHandle); - public static native int SetKeyboardFocus(int wHandle, int cHandle, short inPart); - public static native int AdvanceKeyboardFocus(int wHandle); - public static native boolean IsShowContextualMenuClick(int[] eventData); - public static native int ContextualMenuSelect(int mHandle, short[] location, short[] menuId, short[] index); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Carbon Event Manager - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - public static final double kEventDurationForever = -1.0; - public static final double kEventDurationNoWait = 0.0; - - public static final int eventNotHandledErr = -9874; - public static final int eventLoopTimedOutErr= -9875; - - public static final int kEventAttributeNone = 0; - public static final int kEventAttributeUserEvent = 1 << 0; - - public static final int kEventClassMouse = ('m'<<24) + ('o'<<16) + ('u'<<8) + 's'; - public static final int kEventClassKeyboard = ('k'<<24) + ('e'<<16) + ('y'<<8) + 'b'; - public static final int kEventClassTextInput = ('t'<<24) + ('e'<<16) + ('x'<<8) + 't'; - public static final int kEventClassApplication = ('a'<<24) + ('p'<<16) + ('p'<<8) + 'l'; - public static final int kEventClassAppleEvent = ('e'<<24) + ('p'<<16) + ('p'<<8) + 'c'; - public static final int kEventAppleEvent = 1; - public static final int kEventClassMenu = ('m'<<24) + ('e'<<16) + ('n'<<8) + 'u'; - public static final int kEventClassWindow = ('w'<<24) + ('i'<<16) + ('n'<<8) + 'd'; - public static final int kEventClassControl = ('c'<<24) + ('n'<<16) + ('t'<<8) + 'l'; - public static final int kEventClassTablet = ('t'<<24) + ('b'<<16) + ('l'<<8) + 't'; - public static final int kEventClassVolume = ('v'<<24) + ('o'<<16) + ('l'<<8) + ' '; - public static final int kEventClassAppearance = ('a'<<24) + ('p'<<16) + ('p'<<8) + 'm'; - public static final int kEventClassService = ('s'<<24) + ('e'<<16) + ('r'<<8) + 'v'; - public static final int kEventClassCommand = ('c'<<24) + ('m'<<16) + ('d'<<8) + 's'; - public static final int kEventProcessCommand = 1; - - - public static final int typeUInt32= ('m'<<24) + ('a'<<16) + ('g'<<8) + 'n'; - public static final int typeChar= ('T'<<24) + ('E'<<16) + ('X'<<8) + 'T'; - public static final int typeUnicodeText= ('u'<<24) + ('t'<<16) + ('x'<<8) + 't'; - public static final int typeWindowRef= ('w'<<24) + ('i'<<16) + ('n'<<8) + 'd'; - public static final int typeWindowDefPartCode= ('w'<<24) + ('d'<<16) + ('p'<<8) + 't'; - public static final int typeControlRef= ('c'<<24) + ('t'<<16) + ('r'<<8) + 'l'; - public static final int typeMouseButton= ('m'<<24) + ('b'<<16) + ('t'<<8) + 'n'; - public static final int typeQDPoint= ('Q'<<24) + ('D'<<16) + ('p'<<8) + 't'; - public static final int typeType= ('t'<<24) + ('y'<<16) + ('p'<<8) + 'e'; - public static final int typeSInt32= ('l'<<24) + ('o'<<16) + ('n'<<8) + 'g'; - - - public static final int kEventParamDirectObject = ('-'<<24) + ('-'<<16) + ('-'<<8) + '-'; /* type varies depending on event*/ - public static final int kEventParamAttributes = ('a'<<24) + ('t'<<16) + ('t'<<8) + 'r'; /* typeUInt32*/ - - public static final int kEventParamWindowDefPart= ('w'<<24) + ('d'<<16) + ('p'<<8) + 'c'; - - // Generic toolbox parameters and types - public static final int kEventParamWindowRef = ('w'<<24) + ('i'<<16) + ('n'<<8) + 'd'; - public static final int kEventParamControlRef= ('c'<<24) + ('t'<<16) + ('r'<<8) + 'l'; - public static final int kEventParamAEEventID= ('e'<<24) + ('v'<<16) + ('t'<<8) + 'i'; - public static final int kEventParamAEEventClass= ('e'<<24) + ('v'<<16) + ('c'<<8) + 'l'; - - // Mouse Event - public static final int kEventParamWindowMouseLocation= ('w'<<24) + ('m'<<16) + ('o'<<8) + 'u'; /* typeHIPoint*/ - public static final int kEventParamMouseButton= ('m'<<24) + ('b'<<16) + ('t'<<8) + 'n'; - public static final int kEventParamMouseLocation= ('m'<<24) + ('l'<<16) + ('o'<<8) + 'c'; - public static final int kEventParamMouseChord= ('c'<<24) + ('h'<<16) + ('o'<<8) + 'r'; - public static final int kEventParamMouseWheelDelta= ('m'<<24) + ('w'<<16) + ('d'<<8) + 'l'; - - // Window event parameters and types - - - public static final int kEventParamTextInputSendText= ('t'<<24) + ('s'<<16) + ('t'<<8) + 'x'; - - public static final int kEventParamKeyCode= ('k'<<24) + ('c'<<16) + ('o'<<8) + 'd'; - public static final int kEventParamKeyMacCharCodes= ('k'<<24) + ('c'<<16) + ('h'<<8) + 'r'; - public static final int kEventParamKeyModifiers= ('k'<<24) + ('m'<<16) + ('o'<<8) + 'd'; - public static final int kEventParamKeyUnicodes= ('k'<<24) + ('u'<<16) + ('n'<<8) + 'i'; - - public static final short kEventMouseButtonPrimary= 1; // the left mouse button - public static final short kEventMouseButtonSecondary= 2; // the right mouse button - public static final short kEventMouseButtonTertiary= 3; // the middle mouse button - - public static final int kEventMouseDown = 1; - public static final int kEventMouseUp = 2; - public static final int kEventMouseMoved = 5; - public static final int kEventMouseDragged = 6; - public static final int kEventMouseEntered = 8; - public static final int kEventMouseExited = 9; - public static final int kEventMouseWheelMoved= 10; - - public static final int kEventRawKeyDown = 1; // A key was pressed - public static final int kEventRawKeyRepeat = 2; // Sent periodically as a key is held down by the user - public static final int kEventRawKeyUp = 3; // A key was released - public static final int kEventRawKeyModifiersChanged= 4; // The keyboard modifiers (bucky bits) have changed. - public static final int kEventHotKeyPressed = 5; // A registered Hot Key was pressed. - public static final int kEventHotKeyReleased= 6; // A registered Hot Key was released (this is only sent on Mac OS X). - - public static final int kEventWindowDrawContent = 2; - public static final int kEventWindowActivated = 5; - public static final int kEventWindowDeactivated = 6; - public static final int kEventWindowBoundsChanged = 27; - public static final int kEventWindowClose = 72; - - public static final int kWindowBoundsChangeUserDrag = (1 << 0); - public static final int kWindowBoundsChangeUserResize = (1 << 1); - public static final int kWindowBoundsChangeSizeChanged = (1 << 2); - public static final int kWindowBoundsChangeOriginChanged = (1 << 3); - - public static final int kEventMenuBeginTracking = 1; - public static final int kEventMenuEndTracking = 2; - - public static final int kEventTextInputUnicodeForKeyEvent = 2; - + /** Constants */ + public static final int RGBDirect = 16; + public static final int bold = 1; + public static final int checkMark = 18; + public static final int cmdKey = 1 << 8; + public static final int controlKey = 1 << 12; + public static final int diamondMark = 19; + public static final int errControlIsNotEmbedder = -30590; + public static final int errUnknownControl = -30584; + public static final int eventLoopTimedOutErr = -9875; + public static final int eventNotHandledErr = -9874; + public static final int inContent = 3; + public static final int inMenuBar = 1; + public static final int inStructure = 15; + public static final int inZoomIn = 7; + public static final int inZoomOut = 8; + public static final int italic = 2; public static final int kAEQuitApplication = ('q'<<24) + ('u'<<16) + ('i'<<8) + 't'; - - public static native int CallNextEventHandler(int nextHandler, int eventRefHandle); - - public static native int InstallEventHandler(int eventTargetRef, int controlHandlerUPP, int[] eventTypes, int clientData); - - public static native int GetEventHICommand(int eRefHandle, int[] outParamType); - - public static native int GetEventParameter(int eRefHandle, int paramName, int paramType, int[] outParamType, - int[] outActualSize, byte[] data); - public static native int GetEventParameter(int eRefHandle, int paramName, int paramType, int[] outParamType, - int[] outActualSize, char[] data); - public static native int GetEventParameter(int eRefHandle, int paramName, int paramType, int[] outParamType, - int[] outActualSize, short[] data); - public static native int GetEventParameter(int eRefHandle, int paramName, int paramType, int[] outParamType, - int[] outActualSize, int[] data); - public static native int SetEventParameter(int eRefHandle, int paramName, int paramType, char[] data); - - public static native int GetControlEventTarget(int cHandle); - public static native int GetMenuEventTarget(int cHandle); - public static native int GetUserFocusEventTarget(); - public static native int GetApplicationEventTarget(); - - public static native int GetUserFocusWindow(); - - public static native int GetCurrentEventLoop(); - - public static native int InstallEventLoopTimer(int inEventLoop, double inFireDelay, - double inInterval, int inTimerProc, int inTimerData, int[] outTimer); - public static native int RemoveEventLoopTimer(int inTimer); - public static native double GetLastUserEventTime(); - public static native int ReceiveNextEvent(int[] eventTypeSpecList, double inTimeout, boolean inPullEvent, int[] outEvent); - public static native int GetEventDispatcherTarget(); - public static native int SendEventToEventTarget(int theEvent, int theTarget); - public static native void ReleaseEvent(int theEvent); - public static native boolean ConvertEventRefToEventRecord(int eHandle, int[] outEvent); - public static native int InstallStandardEventHandler(int inTarget); - public static native int GetWindowEventTarget(int wHandle); - public static native int GetEventClass(int eHandle); - public static native int GetEventKind(int eHandle); - public static native double GetEventTime(int eHandle); - public static native int GetMouseLocation(int eHandle, short[] location); - public static native int TrackMouseLocation(int portHandle, short[] outPt, short[] outResult); - public static native void GetGlobalMouse(short[] where); - public static native int CreateEvent(int allocator, int inClassID, int kind, double when, int flags, int[] outEventRef); - public static native int PostEventToQueue(int inQueue, int inEvent, short inPriority); - public static native int GetMainEventQueue(); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Font manager - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - public static final short kInvalidFontFamily = -1; - - public static native short FMGetFontFamilyFromName(byte[] name); - public static native int FMGetFontFamilyName(short id, byte[] name); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Cursors - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - public static final int kThemeArrowCursor = 0; - public static final int kThemeCopyArrowCursor = 1; - public static final int kThemeAliasArrowCursor = 2; - public static final int kThemeContextualMenuArrowCursor = 3; - public static final int kThemeIBeamCursor = 4; - public static final int kThemeCrossCursor = 5; - public static final int kThemePlusCursor = 6; - public static final int kThemeWatchCursor = 7; - public static final int kThemeClosedHandCursor = 8; - public static final int kThemeOpenHandCursor = 9; - public static final int kThemePointingHandCursor = 10; - public static final int kThemeCountingUpHandCursor = 11; - public static final int kThemeCountingDownHandCursor = 12; - public static final int kThemeCountingUpAndDownHandCursor = 13; - public static final int kThemeSpinningCursor = 14; - public static final int kThemeResizeLeftCursor = 15; - public static final int kThemeResizeRightCursor = 16; - public static final int kThemeResizeLeftRightCursor = 17; - - public static final short iBeamCursor = 1; - public static final short crossCursor = 2; - public static final short plusCursor = 3; - public static final short watchCursor = 4; - - public static native void InitCursor(); - public static native int NewCursor(short hotX, short hotY, short[] data, short[] mask); - public static native int GetCursor(short id); - public static native void SetCursor(int cursor); - public static native int SetThemeCursor(int themeCursor); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // QuickDraw - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - // transfer modes - public static final short srcCopy = 0; - public static final short srcOr = 1; - - // text faces - public static final short normal = 0; - public static final short bold = 1; - public static final short italic = 2; - - public static final int kQDUseDefaultTextRendering = 0; - public static final int kQDUseTrueTypeScalerGlyphs = (1 << 0); - public static final int kQDUseCGTextRendering = (1 << 1); - public static final int kQDUseCGTextMetrics = (1 << 2); - public static final int kQDSupportedFlags = - kQDUseTrueTypeScalerGlyphs | kQDUseCGTextRendering | kQDUseCGTextMetrics; - public static final int kQDDontChangeFlags = 0xFFFFFFFF; - - public static native int QDSwapTextFlags(int flags); - public static native void QDSetPatternOrigin(short[] point); - public static native int GetQDGlobalsScreenBits(int bitmap); - - public static native int GetPort(); - public static native void SetPort(int pHandle); - public static native boolean IsValidPort(int pHandle); - public static native int GetWindowFromPort(int pHandle); - public static native void GetPortBounds(int pHandle, short[] rect); - public static native void NormalizeThemeDrawingState(); - public static native void RGBForeColor(short red, short green, short blue); - public static native void RGBBackColor(short red, short green, short blue); - //public static native void GlobalToLocal(short[] point); - //public static native void LocalToGlobal(short[] point); - public static native void QDGlobalToLocalPoint(int port, short[] point); - public static native void QDLocalToGlobalPoint(int port, short[] point); - - public static native void ScrollRect(short[] rect, short dh, short dv, int updateRgn); - public static native int GetPortVisibleRegion(int portHandle, int rgnHandle); - public static native void SetPortVisibleRegion(int portHandle, int rgnHandle); - public static native void QDFlushPortBuffer(int port, int rgnHandle); - public static native int QDGetDirtyRegion(int portHandle, int rgnHandle); - public static native int QDSetDirtyRegion(int portHandle, int rgnHandle); - public static native int LockPortBits(int portHandle); - public static native int UnlockPortBits(int portHandle); - - // clipping - public static native void ClipRect(short[] clipRect); - public static native void GetClip(int rgnHandle); - public static native void SetClip(int rgnHandle); - public static native void SetOrigin(short h, short v); - public static native void GetPortClipRegion(int port, int clipRgn); - - // Text - public static native void TextFont(short fontID); - public static native void TextSize(short size); - public static native void TextFace(short face); - public static native void TextMode(short mode); - public static native void DrawText(String s, short font, short size, short face); - public static native short TextWidth(String s, short font, short size, short face); - public static native short CharWidth(byte c); - public static native void GetFontInfo(short[] info); // FontInfo: short[4] - public static native void SetFractEnable(boolean enable); - - // Lines & Polygons - public static native void PenSize(short h, short v); - public static native void MoveTo(short h, short v); - public static native void LineTo(short h, short v); - - // Rectangles - public static native void EraseRect(short[] bounds); // rect: short[4] - public static native void FrameRect(short[] bounds); - public static native void PaintRect(short[] bounds); - public static native void InvertRect(short x, short y, short w, short h); - - // Ovals - public static native void FrameOval(short[] bounds); - public static native void PaintOval(short[] bounds); - - // Round Rectangle - public static native void FrameRoundRect(short[] bounds, short ovalWidth, short ovalHeight); - public static native void PaintRoundRect(short[] bounds, short ovalWidth, short ovalHeight); - - // Regions - public static native int NewRgn(); - public static native void SetEmptyRgn(int rgnHandle); - public static native void RectRgn(int rgnHandle, short[] rect); - public static native void SetRectRgn(int rgnHandle, short left, short top, short right, short bottom); - public static native void DisposeRgn(int rgnHandle); - public static native boolean EmptyRgn(int rgnHandle); - public static native void GetRegionBounds(int rgnHandle, short[] bounds); - public static native void SectRgn(int srcRgnA, int srcRgnB, int dstRgn); - public static native void UnionRgn(int srcRgnA, int srcRgnB, int dstRgn); - public static native void DiffRgn(int srcRgnA, int srcRgnB, int dstRgn); - public static native boolean PtInRgn(short[] pt, int rgnHandle); - public static native boolean RectInRgn(short[] rect, int rgnHandle); - public static native void CopyRgn(int srcRgnHandle, int dstRgnHandle); - public static native void OffsetRgn(int rgnHandle, short dh, short dv); - - public static native void EraseRgn(int rgnHandle); - public static native void InvertRgn(int rgnHandle); - - // Polygons - public static native int OpenPoly(); - public static native void ClosePoly(); - public static native void OffsetPoly(int polyHandle, short dx, short dy); - public static native void FramePoly(int polyHandle); - public static native void PaintPoly(int polyHandle); - public static native void KillPoly(int polyHandle); - - - // BitMaps & PixMaps - public static final short Indexed= 0; - public static final short RGBDirect= 16; - - public static native int NewPixMap(short w, short h, short rowBytes, - short pixelType, short pixelSize, short cmpSize, short cmpCount, short pixelFormat); - public static native void DisposePixMap(int pHandle); - public static native int duplicatePixMap(int srcPixmap); - - public static native int getRowBytes(int pHandle); - public static native void setRowBytes(int pHandle, short rowBytes); - public static native int GetPixRowBytes(int pHandle); - public static native void GetPixBounds(int pHandle, short[] bounds); - public static native void setPixBounds(int pHandle, short top, short left, short bottom, short right); - public static native short GetPixDepth(int pHandle); - public static native int getPixHRes(int pHandle); - public static native int getPixVRes(int pHandle); - public static native int getBaseAddr(int pHandle); - public static native void setBaseAddr(int pHandle, int data); - public static native int getColorTableSize(int pHandle); // returns number of slots - public static native void getColorTable(int pHandle, short[] colorSpec); - public static native void setColorTable(int pHandle, short[] colorSpec); - - public static native void CopyBits(int srcPixMapHandle, int dstPixMapHandle, short[] srcRect, short[] dstRect, - short mode, int maskRgn); - public static native void CopyMask(int srcPixMapHandle, int maskPixMapHandle, int dstPixMapHandle, - short[] srcRect, short[] maskRect, short[] dstRect); - public static native void CopyDeepMask(int srcPixMapHandle, int maskPixMapHandle, int dstPixMapHandle, - short[] srcRect, short[] maskRect, short[] dstRect, short mode, int maskRgn); - - public static native int GetPortBitMapForCopyBits(int portHandle); - - // CIcon - public static native int NewCIcon(int pixmapHandle, int maskHandle); - public static native int getCIconIconData(int iconHandle); - public static native int getCIconColorTable(int iconHandle); - - // GWorlds - public static native int NewGWorldFromPtr(int[] offscreenGWorld, int pHandle); - public static native void DisposeGWorld(int offscreenGWorld); - public static native void SetGWorld(int portHandle, int gdHandle); - public static native void GetGWorld(int[] portHandle, int[] gdHandle); - public static native int GetGDevice(); - public static native int GetMainDevice(); - public static native int getgdPMap(int gdHandle); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Window Manager - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - // window class - public static final int kAlertWindowClass = 1; /* I need your attention now.*/ - public static final int kMovableAlertWindowClass = 2; /* I need your attention now, but I'm kind enough to let you switch out of this app to do other things.*/ - public static final int kModalWindowClass = 3; /* system modal, not draggable*/ - public static final int kMovableModalWindowClass = 4; /* application modal, draggable*/ - public static final int kFloatingWindowClass = 5; /* floats above all other application windows*/ - public static final int kDocumentWindowClass = 6; /* document windows*/ - public static final int kUtilityWindowClass = 8; /* system-wide floating windows (TSM, AppleGuide) (available in CarbonLib 1.1)*/ - public static final int kHelpWindowClass = 10; /* help window (no frame; coachmarks, help tags ) (available in CarbonLib 1.1)*/ - public static final int kSheetWindowClass = 11; /* sheet windows for dialogs (available in Mac OS X and CarbonLib 1.3)*/ - public static final int kToolbarWindowClass = 12; /* toolbar windows (above documents, below floating windows) (available in CarbonLib 1.1)*/ - public static final int kPlainWindowClass = 13; /* plain window (in document layer)*/ - public static final int kOverlayWindowClass = 14; /* transparent window which allows 'screen' drawing via CoreGraphics (Mac OS X only)*/ - public static final int kSheetAlertWindowClass = 15; /* sheet windows for alerts (available in Mac OS X after 10.0.x and CarbonLib 1.3)*/ - public static final int kAltPlainWindowClass = 16; /* alternate plain window (in document layer) (available in Mac OS X after 10.0.x and CarbonLib 1.3)*/ - public static final int kAllWindowClasses = 0xFFFFFFFF; /* for use with GetFrontWindowOfClass, FindWindowOfClass, GetNextWindowOfClass*/ - - // window attributes - public static final int kWindowNoAttributes = 0; - /* This window has a close box. - * Available for windows of kDocumentWindowClass, kFloatingWindowClass, and kUtilityWindowClass. */ - public static final int kWindowCloseBoxAttribute = (1 << 0); - /* This window changes width when zooming. - * Available for windows of kDocumentWindowClass, kFloatingWindowClass, and kUtilityWindowClass. */ - public static final int kWindowHorizontalZoomAttribute = (1 << 1); - /* This window changes height when zooming. - * Available for windows of kDocumentWindowClass, kFloatingWindowClass, and kUtilityWindowClass. */ - public static final int kWindowVerticalZoomAttribute = (1 << 2); - /* This window changes both width and height when zooming. - * Available for windows of kDocumentWindowClass, kFloatingWindowClass, and kUtilityWindowClass. */ - public static final int kWindowFullZoomAttribute = (kWindowVerticalZoomAttribute | kWindowHorizontalZoomAttribute); - /* This window has a collapse box. - * Available for windows of kDocumentWindowClass and, on Mac OS 9, kFloatingWindowClass and - * kUtilityWindowClass; not available for windows of kFloatingWindowClass or kUtilityWindowClass on Mac OS X. */ - public static final int kWindowCollapseBoxAttribute = (1 << 3); - /* This window can be resized. - * Available for windows of kDocumentWindowClass, kMovableModalWindowClass, - * kFloatingWindowClass, kUtilityWindowClass, and kSheetWindowClass. */ - public static final int kWindowResizableAttribute = (1 << 4); - /* This window has a vertical titlebar on the side of the window. - * Available for windows of kFloatingWindowClass and kUtilityWindowClass. */ - public static final int kWindowSideTitlebarAttribute = (1 << 5); - /* This window has a toolbar button. - * Available for windows of kDocumentWindowClass on Mac OS X. */ - public static final int kWindowToolbarButtonAttribute = (1 << 6); - /* This window receives no update events. - * Available for all windows. */ - public static final int kWindowNoUpdatesAttribute = (1 << 16); - /* This window receives no activate events. - * Available for all windows.*/ - public static final int kWindowNoActivatesAttribute = (1 << 17); - /* This window receives mouse events even for areas of the window - * that are transparent (have an alpha channel component of zero). - * Available for windows of kOverlayWindowClass on Mac OS X.*/ - public static final int kWindowOpaqueForEventsAttribute = (1 << 18); - public static final int kWindowCompositingAttribute = (1 << 19); - /* This window has no shadow. - * Available for all windows on Mac OS X. - * This attribute is automatically given to windows of kOverlayWindowClass. */ - public static final int kWindowNoShadowAttribute = (1 << 21); - /* This window is automatically hidden on suspend and shown on resume. - * Available for all windows. This attribute is automatically - * given to windows of kFloatingWindowClass, kHelpWindowClass, and - * kToolbarWindowClass. */ - public static final int kWindowHideOnSuspendAttribute = (1 << 24); - /* This window has the standard Carbon window event handler installed. - * Available for all windows. */ - public static final int kWindowStandardHandlerAttribute = (1 << 25); - /* This window is automatically hidden during fullscreen mode (when the menubar is invisible) and shown afterwards. - * Available for all windows. - * This attribute is automatically given to windows of kUtilityWindowClass. */ - public static final int kWindowHideOnFullScreenAttribute = (1 << 26); - /* This window is added to the standard Window menu. - * Available for windows of kDocumentWindowClass. - * This attribute is automatically given to windows of kDocumentWindowClass. */ - public static final int kWindowInWindowMenuAttribute = (1 << 27); - /* This window supports live resizing. - * Available for all windows on Mac OS X. */ - public static final int kWindowLiveResizeAttribute = (1 << 28); - /* This window will not be repositioned by the default kEventWindowConstrain - * handler in response to changes in monitor size, Dock position, and so on. - * Available for all windows on Mac OS X after 10.0.x. */ - public static final int kWindowNoConstrainAttribute = (1 << 31); - /* The minimum set of window attributes commonly used by document windows. */ - public static final int kWindowStandardDocumentAttributes = (kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute | kWindowResizableAttribute); - /* The minimum set of window attributes commonly used by floating windows. */ - public static final int kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute); - - // window modality - public static final int kWindowModalityNone = 0; - public static final int kWindowModalitySystemModal = 1; - public static final int kWindowModalityAppModal = 2; - public static final int kWindowModalityWindowModal = 3; - - // ScrollWindowOptions - public static final int kScrollWindowNoOptions= 0; - public static final int kScrollWindowInvalidate= 1; - public static final int kScrollWindowEraseToPortBackground= 2; - - // Region values to pass into GetWindowRegion & GetWindowBounds - //public static final short kWindowTitleBarRgn = 0; - //public static final short kWindowTitleTextRgn = 1; - //public static final short kWindowCloseBoxRgn = 2; - //public static final short kWindowZoomBoxRgn = 3; - //public static final short kWindowDragRgn = 5; - //public static final short kWindowGrowRgn = 6; - //public static final short kWindowCollapseBoxRgn = 7; - //public static final short kWindowTitleProxyIconRgn = 8; - public static final short kWindowStructureRgn = 32; - public static final short kWindowContentRgn = 33; /* Content area of the window; empty when the window is collapsed*/ - //public static final short kWindowUpdateRgn = 34; /* Carbon forward*/ - //public static final short kWindowOpaqueRgn = 35; /* Mac OS X: Area of window considered to be opaque. Only valid for windows with alpha channels.*/ - //public static final short kWindowGlobalPortRgn = 40; /* Carbon forward - bounds of the windowÕs port in global coordinates; not affected by CollapseWindow*/ - - - public static native int CreateNewWindow(int windowClass, int attributes, short[] bounds, int[] wHandle); - public static native int GetWindowPort(int wHandle); - public static native void BeginUpdate(int wHandle); - public static native void EndUpdate(int wHandle); - public static native void DrawControls(int wHandle); - public static native void UpdateControls(int wHandle, int rgnHandle); - //public static native void DrawGrowIcon(int wHandle); - public static native void SetPortWindowPort(int wHandle); - public static native int FrontWindow(); - public static native int FrontNonFloatingWindow(); - public static native void SelectWindow(int wHandle); - public static native void ActivateWindow(int wHandle, boolean activate); - public static native void BringToFront(int wHandle); - public static native short FindWindow(short[] where, int[] wHandle); - //public static native boolean ResizeWindow(int wHandle, short[] startPt, short[] sizeConstraints, short[] newContentRect); - //public static native void DragWindow(int wHandle, short[] startPt, short[] boundsRect); - //public static native void GetWindowPortBounds(int wHandle, short[] bounds); - //public static native boolean TrackGoAway(int wHandle, short[] startPt); - //public static native boolean TrackBox(int wHandle, short[] startPt, short part); - //public static native void ZoomWindow(int wHandle, short part, boolean toFront); - public static native void DisposeWindow(int wHandle); - public static native void InvalWindowRect(int wHandle, short[] bounds); - public static native void InvalWindowRgn(int wHandle, int rgnHandle); - public static native void ShowWindow(int wHandle); - public static native void HideWindow(int wHandle); - public static native int ShowSheetWindow(int wHandle, int parenthandle); - public static native int HideSheetWindow(int wHandle); - public static native void SetWindowBounds(int wHandle, short windowRegion, short[] bounds); - public static native void GetWindowBounds(int wHandle, short windowRegion, short[] bounds); - public static native boolean IsValidWindowPtr(int grafPort); - public static native int GetWRefCon(int wHandle); - public static native void SetWRefCon(int wHandle, int data); - public static native void SizeWindow(int wHandle, short w, short h, boolean update); - public static native void MoveWindow(int wHandle, short h, short v, boolean toFront); - public static native void ScrollWindowRect(int wHandle, short[] rect, short dx, short dy, int options, int exposedRgn); - public static native int CopyWindowTitleAsCFString(int wHandle, int[] sHandle); - public static native int SetWindowTitleWithCFString(int wHandle, int sHandle); - public static native boolean IsWindowVisible(int wHandle); - public static native int SetWindowDefaultButton(int wHandle, int cHandle); - public static native int GetWindowDefaultButton(int wHandle, int[] cHandle); - public static native int GetWindowModality(int wHandle, int[] modalityKind, int[] unavailableWindowHandle); - public static native int SetWindowModality(int wHandle, int modalityKind, int unavailableWindowHandle); - public static native int CollapseWindow(int wHandle, boolean collapse); - public static native boolean IsWindowActive(int wHandle); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Menu Manager - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - public static final int kMenuItemAttrDisabled = 1; - public static final int kMenuItemAttrSeparator = 64; - - // menu item mark characters - public static final char checkMark= (char)18; // for SWT.CHECK - public static final char diamondMark= (char)19; // for SWT.RADIO - - // menu glyphs - public static final short kMenuNullGlyph = 0; - public static final short kMenuTabRightGlyph = 2; - public static final short kMenuTabLeftGlyph = 3; - public static final short kMenuEnterGlyph = 4; - public static final short kMenuShiftGlyph = 5; - public static final short kMenuControlGlyph = 6; - public static final short kMenuOptionGlyph = 7; - public static final short kMenuSpaceGlyph = 9; - public static final short kMenuDeleteRightGlyph = 10; - public static final short kMenuReturnGlyph = 11; - public static final short kMenuReturnR2LGlyph = 12; - public static final short kMenuNonmarkingReturnGlyph = 13; - public static final short kMenuPencilGlyph = 15; - public static final short kMenuDownwardArrowDashedGlyph = 16; - public static final short kMenuCommandGlyph = 17; - public static final short kMenuCheckmarkGlyph = 18; - public static final short kMenuDiamondGlyph = 19; - public static final short kMenuAppleLogoFilledGlyph = 20; - public static final short kMenuParagraphKoreanGlyph = 21; - public static final short kMenuDeleteLeftGlyph = 23; - public static final short kMenuLeftArrowDashedGlyph = 24; - public static final short kMenuUpArrowDashedGlyph = 25; - public static final short kMenuRightArrowDashedGlyph = 26; - public static final short kMenuEscapeGlyph = 27; - public static final short kMenuClearGlyph = 28; - public static final short kMenuLeftDoubleQuotesJapaneseGlyph = 29; - public static final short kMenuRightDoubleQuotesJapaneseGlyph = 30; - public static final short kMenuTrademarkJapaneseGlyph = 31; - public static final short kMenuBlankGlyph = 97; - public static final short kMenuPageUpGlyph = 98; - public static final short kMenuCapsLockGlyph = 99; - public static final short kMenuLeftArrowGlyph = 100; - public static final short kMenuRightArrowGlyph = 101; - public static final short kMenuNorthwestArrowGlyph = 102; - public static final short kMenuHelpGlyph = 103; - public static final short kMenuUpArrowGlyph = 104; - public static final short kMenuSoutheastArrowGlyph = 105; - public static final short kMenuDownArrowGlyph = 106; - public static final short kMenuPageDownGlyph = 107; - public static final short kMenuAppleLogoOutlineGlyph = 108; - public static final short kMenuContextualMenuGlyph = 109; - public static final short kMenuPowerGlyph = 110; - public static final short kMenuF1Glyph = 111; - public static final short kMenuF2Glyph = 112; - public static final short kMenuF3Glyph = 113; - public static final short kMenuF4Glyph = 114; - public static final short kMenuF5Glyph = 115; - public static final short kMenuF6Glyph = 116; - public static final short kMenuF7Glyph = 117; - public static final short kMenuF8Glyph = 118; - public static final short kMenuF9Glyph = 119; - public static final short kMenuF10Glyph = 120; - public static final short kMenuF11Glyph = 121; - public static final short kMenuF12Glyph = 122; - public static final short kMenuF13Glyph = 135; - public static final short kMenuF14Glyph = 136; - public static final short kMenuF15Glyph = 137; - public static final short kMenuControlISOGlyph = 138; - - // menu event types - public static final int kEventMenuOpening= 4; - public static final int kEventMenuClosed= 5; - public static final int kEventMenuPopulate= 9; - - // For use with Get/SetMenuItemModifiers - public static final byte kMenuNoModifiers = 0; /* Mask for no modifiers*/ - public static final byte kMenuShiftModifier = (1 << 0); /* Mask for shift key modifier*/ - public static final byte kMenuOptionModifier = (1 << 1); /* Mask for option key modifier*/ - public static final byte kMenuControlModifier = (1 << 2); /* Mask for control key modifier*/ - public static final byte kMenuNoCommandModifier = (1 << 3); /* Mask for no command key modifier*/ - - public static native int MenuSelect(short[] where); - public static native void HiliteMenu(short menuID); - public static native void DrawMenuBar(); - public static native void InvalMenuBar(); - - public static native int CreateNewMenu(int menuID, int menuAttributes, int[] menuRef); - public static native void DisposeMenu(int mHandle); - public static native int InitContextualMenus(); - - public static native void InsertMenu(int mHandle, short beforeID); - public static native void DeleteMenu(short menuID); - public static native void ClearMenuBar(); - - public static native short CountMenuItems(int mHandle); - public static native int DeleteMenuItems(int mHandle, short firstItem, int numItems); - - public static native int GetMenuItemRefCon(int mHandle, short index, int[] refCon); - public static native int SetMenuItemRefCon(int mHandle, short index, int refCon); - public static native int SetMenuItemCommandKey(int mHandle, short index, boolean virtualKey, char key); - public static native int SetMenuItemModifiers(int mHandle, short index, byte modifiers); - public static native int SetMenuItemKeyGlyph(int mHandle, short index, short glyph); - public static native int InvalidateMenuItems(int mHandle, short index, int numItems); - - public static native int AppendMenuItemTextWithCFString(int mHandle, int sHandle, int attributes, int commandID, short[] outItemIndex); - public static native int InsertMenuItemTextWithCFString(int mHandle, int sHandle, short index, int attributes, int commandID); - public static native int SetMenuItemTextWithCFString(int mHandle, short index, int sHandle); - public static native int CopyMenuItemTextAsCFString(int mHandle, short index, int[] sHandle); - - //public static native int SetMenuItemCommandID(int mHandle, short index, int commandId); - public static native void EnableMenuCommand(int mHandle, int commandId); - public static native void DisableMenuCommand(int mHandle, int commandId); - public static native boolean IsMenuCommandEnabled (int mHandle, int commandId); - public static native int GetIndMenuItemWithCommandID(int mHandle, int commandId, int index, int[] outMenu, short[] outIndex); - public static native void DeleteMenuItem(int mHandle, short index); - public static native int GetMenuItemCommandID(int mHandle, short index, int[] outCommandID); - public static native short GetMenuID(int mHandle); - public static native int GetMenuHandle(short menuID); - public static native int PopUpMenuSelect(int mHandle, short top, short left, short popUpItem); - public static native int SetRootMenu(int mHandle); - public static native int RetainMenu(int mHandle); - public static native int ReleaseMenu(int mHandle); - public static native int SetMenuTitleWithCFString(int mHandle, int sHandle); - public static native int SetMenuItemHierarchicalMenu(int mHandle, short index, int hierMenuHandle); - public static native int GetMenuItemHierarchicalMenu(int mHandle, short index, int[] outHierMenuHandle); - //public static native void InsertMenuItem(int mHandle, byte[] text, short index); - //public static native void AppendMenu(int mHandle, byte[] text); - public static native int ChangeMenuItemAttributes(int mHandle, short index, int setAttributes, int clearAttributes); - public static native void CheckMenuItem(int mHandle, short index, boolean checked); - public static native int GetMenuCommandMark(int mHandle, int commandId, char[] outMark); - public static native int SetMenuCommandMark(int mHandle, int commandId, char mark); - public static native boolean IsValidMenu(int mHandle); - public static native void SetMenuID(int mHandle, short id); - public static native boolean IsMenuItemEnabled(int mHandle, short index); - public static native void DisableMenuItem(int mHandle, short index); - public static native void EnableMenuItem(int mHandle, short index); - public static native int SetMenuFont(int mHandle, short fontID, short size); - public static native int GetMenuFont(int mHandle, short[] fontID, short[] size); - public static native short GetMenuWidth(int mHandle); - public static native void CalcMenuSize(int mHandle); - public static native int SetMenuItemIconHandle(int mHandle, short item, byte iconType, int iconHandle); - public static native int SetMenuItemCommandID(int mHandle, short item, int commandID); - - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - // Control Manager - ///////////////////////////////////////////////////////////////////////////////////////////////////////// - - // err codes - public static final int errCouldntSetFocus = -30585; - public static final int errControlIsNotEmbedder = -30590; - public static final int errCantEmbedRoot = -30595; - - // control proc IDs - public static final short kControlBevelButtonSmallBevelProc= 32; - public static final short kControlBevelButtonNormalBevelProc= 33; - public static final short kControlBevelButtonLargeBevelProc= 34; - public static final short kControlSliderProc = 48; - public static final short kControlProgressBarProc = 80; - public static final short kControlTabSmallProc = 129; - public static final short kControlSeparatorLineProc = 144; - public static final short kControlGroupBoxTextTitleProc = 160; - public static final short kControlPopupArrowEastProc = 192; - public static final short kControlUserPaneProc = 256; - public static final short kControlEditTextProc = 272; - public static final short kControlStaticTextProc = 288; - public static final short kControlListBoxProc = 352; - public static final short kControlListBoxAutoSizeProc = 353; - public static final short kControlPushButtonProc = 368; - public static final short kControlCheckBoxProc = 369; - public static final short kControlRadioButtonProc = 370; - public static final short kControlCheckBoxAutoToggleProc= 371; - public static final short kControlRadioButtonAutoToggleProc= 372; - public static final short kControlPushButLeftIconProc = 374; - public static final short kControlScrollBarLiveProc = 386; - public static final short kControlPopupButtonProc = 400; - public static final short kControlEditUnicodeTextProc = 912; - public static final short popupMenuProc = 1008; - - // meta part codes for GetControlRegion etc. - public static final short kControlEntireControl = 0; - public static final short kControlStructureMetaPart = (short) -1; - public static final short kControlContentMetaPart = (short) -2; - - // part codes - public static final short inDesk = 0; - public static final short inNoWindow = 0; - public static final short inMenuBar = 1; - public static final short inSysWindow = 2; - public static final short inContent = 3; - public static final short inDrag = 4; - public static final short inGrow = 5; - public static final short inGoAway = 6; - public static final short inZoomIn = 7; - public static final short inZoomOut = 8; - public static final short inCollapseBox = 11; - public static final short inProxyIcon = 12; - public static final short inToolbarButton = 13; - public static final short inStructure = 15; - - // other part codes - public static final short kControlUpButtonPart = 20; - public static final short kControlDownButtonPart= 21; - public static final short kControlPageUpPart = 22; - public static final short kControlPageDownPart = 23; - public static final short kControlIndicatorPart = 129; - public static final short thumbDrag = 999; - - // tags + public static final int kAlertCautionAlert = 2; + public static final int kAlertNoteAlert = 1; + public static final int kAlertPlainAlert = 3; + public static final int kAlertStopAlert = 0; + public static final int kAlertDefaultOKText = -1; + public static final int kAlertDefaultCancelText = -1; + public static final int kAlertStdAlertOKButton = 1; + public static final int kAlertStdAlertCancelButton = 2; + public static final int kAlertStdAlertOtherButton = 3; + public static final int kAtSpecifiedOrigin = 0; + public static final int kATSUCGContextTag = 32767; + public static final int kATSUFontTag = 261; + public static final int kATSUQDBoldfaceTag = 256; + public static final int kATSUQDItalicTag = 257; + public static final int kATSUseDeviceOrigins = 1; + public static final int kATSUSizeTag = 262; + public static final int kCFAllocatorDefault = 0; + public static final int kCFURLPOSIXPathStyle = 0; + public static final int kCGImageAlphaFirst = 4; + public static final int kCGImageAlphaNoneSkipFirst = 6; + public static final int kColorPickerDialogIsMoveable = 1; + public static final int kColorPickerDialogIsModal = 2; + public static final int kControlBehaviorPushbutton = 0; + public static final int kControlBehaviorToggles = 0x0100; + public static final int kControlBevelButtonAlignCenter = 0; + public static final int kControlBevelButtonAlignLeft = 1; + public static final int kControlBevelButtonAlignRight = 2; + public static final int kControlBevelButtonAlignTextCenter = 1; + public static final int kControlBevelButtonAlignTextFlushRight = -1; + public static final int kControlBevelButtonAlignTextFlushLeft = -2; + public static final int kControlBevelButtonNormalBevelProc = 33; + public static final int kControlBevelButtonSmallBevel = 0; + public static final int kControlBevelButtonLargeBevel = 2; + public static final int kControlBevelButtonMenuRefTag = ('m'<<24) + ('h'<<16) + ('n'<<8) + 'd'; + public static final int kControlBevelButtonNormalBevel = 1; + public static final int kControlBevelButtonPlaceBelowGraphic = 3; + public static final int kControlBevelButtonPlaceToRightOfGraphic = 1; + public static final int kControlBevelButtonKindTag = ('b'<<24) + ('e'<<16) + ('b'<<8) + 'k'; + public static final int kControlBevelButtonTextAlignTag = ('t'<<24) + ('a'<<16) + ('l'<<8) + 'i'; + public static final int kControlBevelButtonTextPlaceTag = ('t'<<24) + ('p'<<16) + ('l'<<8) + 'c'; + public static final int kControlBevelButtonGraphicAlignTag = ('g'<<24) + ('a'<<16) + ('l'<<8) + 'i'; + public static final int kControlBoundsChangeSizeChanged = 1 << 2; + public static final int kControlBoundsChangePositionChanged = 1 << 3; + public static final int kControlCheckBoxAutoToggleProc = 371; + public static final int kControlContentCIconHandle = 130; + public static final int kControlContentIconRef = 132; + public static final int kControlContentMetaPart = -2; + public static final int kControlContentTextOnly = 0; + public static final int kControlDownButtonPart = 21; + public static final int kControlEditTextCFStringTag = ('c'<<24) + ('f'<<16) + ('s'<<8) + 't'; + public static final int kControlEditTextSingleLineTag = ('s'<<24) + ('g'<<16) + ('l'<<8) + 'c'; + public static final int kControlEditTextSelectionTag = ('s'<<24) + ('e'<<16) + ('l'<<8) + 'e'; + public static final int kControlEditTextTextTag = ('t'<<24) + ('e'<<16) + ('x'<<8) + 't'; + public static final int kControlEntireControl = 0; + public static final int kControlGetsFocusOnClick = 1 << 8; + public static final int kControlGroupBoxTextTitleProc = 160; + public static final int kControlHandlesTracking = 1 << 5; + public static final int kControlIconTransformTag = ('t'<<24) + ('r'<<16) + ('f'<<8) + 'm'; + public static final int kControlIndicatorPart = 129; + public static final int kControlPageDownPart = 23; + public static final int kControlPageUpPart = 22; + public static final int kControlPopupArrowEastProc = 192; + public static final int kControlPopupArrowOrientationEast = 0; + public static final int kControlPopupArrowOrientationWest = 1; + public static final int kControlPopupArrowOrientationNorth = 2; + public static final int kControlPopupArrowOrientationSouth = 3; + public static final int kControlPopupArrowSizeNormal = 0; + public static final int kControlPopupArrowSizeSmall = 1; + public static final int kControlPopupButtonProc = 400; public static final int kControlProgressBarIndeterminateTag = ('i'<<24) + ('n'<<16) + ('d'<<8) + 'e'; - - // BevelButton control types - public static final short kControlBehaviorPushbutton = 0; - public static final short kControlBehaviorToggles = 0x0100; - public static final short kControlBehaviorSticky = 0x0200; - public static final short kControlBehaviorSingleValueMenu = 0; - public static final short kControlBehaviorCommandMenu = 0x2000; /* menu holds commands, not choices. Overrides multi-value bit.*/ - public static final short kControlBehaviorMultiValueMenu = 0x4000; /* only makes sense when a menu is attached.*/ - public static final short kControlBehaviorOffsetContents = (short) 0x8000; - - public static final short kControlBevelButtonMenuOnBottom = 0; - public static final short kControlBevelButtonMenuOnRight = (1 << 2); - - - // control event types - public static final int kEventControlBoundsChanged = 154; - public static native void SetControlAction(int cHandle, int actionProc); - - public static native int NewControl(int windowHandle, boolean initiallyVisible, short initial, short min, short max, short procID); - public static native void DisposeControl(int cHandle); - - public static native int GetRootControl(int windowHandle, int[] cHandle); - public static native int CreateRootControl(int windowHandle, int[] cHandle); - public static native int EmbedControl(int cHandle, int parentControlHandle); - public static native int CountSubControls(int cHandle, short[] count); - public static native int GetIndexedSubControl(int cHandle, short index, int[] outHandle); - public static native int GetSuperControl(int cHandle, int[] parentHandle); - - public static native int GetControlOwner(int cHandle); - //public static native int FindControlUnderMouse(short[] where, int windowHandle, short[] cpart); - public static native short TestControl(int cHandle, short[] where); - public static native short HandleControlClick(int cHandle, short[] where, int modifiers, int actionUPP); - public static native void MoveControl(int cHandle, short x, short y); - public static native void SizeControl(int cHandle, short w, short h); - public static native void ShowControl(int cHandle); - public static native void HideControl(int cHandle); - public static native boolean IsValidControlHandle(int cHandle); - public static native void SetControlReference(int cHandle, int data); - public static native int GetControlReference(int cHandle); - public static native int SetControlTitleWithCFString(int cHandle, int sHandle); - public static native int GetControlTitleAsCFString(int cHandle, int[] sHandle); - //public static native int setControlToolTipText(int cHandle, short[] bounds, int sHandle); - public static native void GetControlBounds(int cHandle, short[] bounds); - public static native void SetControlBounds(int cHandle, short[] bounds); - public static native int CreateUserPaneControl(int windowHandle, short[] bounds, int features, int[] cHandle); - public static native boolean IsControlVisible(int cHandle); - public static native int SetControlVisibility(int cHandle, boolean inIsVisible, boolean inDoDraw); - public static native boolean IsControlActive(int cHandle); - public static native int EnableControl(int cHandle); - public static native int DisableControl(int cHandle); - public static native boolean IsControlEnabled(int cHandle); - public static native int GetControl32BitMinimum(int cHandle); - public static native void SetControl32BitMinimum(int cHandle, int minimum); - public static native void SetControlMinimum(int cHandle, short minimum); - public static native int GetControl32BitMaximum(int cHandle); - public static native void SetControl32BitMaximum(int cHandle, int maximum); - public static native int GetControl32BitValue(int cHandle); - public static native short GetControlValue(int cHandle); - public static native void SetControl32BitValue(int cHandle, int value); - public static native int GetControlViewSize(int cHandle); - public static native void SetControlViewSize(int cHandle, int viewSize); - public static native int GetBestControlRect(int cHandle, short[] outRect, short[] outBaseLineOffset); - public static native int GetControlKind(int cHandle, int[] outControlKind); - public static native int GetControlData(int cHandle, short part, int tag, short[] data); - public static native int GetControlData(int cHandle, short part, int tag, int[] data); - public static native int SetControlData(int cHandle, short part, int tag, int data); - public static native int SetControlData(int cHandle, short part, int tag, short[] data); - public static native short HandleControlKey(int cHandle, short keyCode, char charCode, int modifiers); - public static native int SetControlFontStyle(int cHandle, short font, short size, short style); - public static native int SetUpControlBackground(int cHandle, short depth, boolean isColorDevice); - - public static native int GetControlRegion(int cHandle, short inPart, int rgnHandle); - - public static short kControlContentCIconHandle= 130; - - public static final int kControlBevelButtonOwnedMenuRefTag = ('o'<<24) + ('m'<<16) + ('r'<<8) + 'f'; /* MenuRef (control will dispose)*/ - public static final int kControlBevelButtonCenterPopupGlyphTag = ('p'<<24) + ('g'<<16) + ('l'<<8) + 'c'; /* Boolean: true = center, false = bottom right*/ - - public static native int SetBevelButtonContentInfo(int cHandle, short controlContentType, int controlContentHandle); - - - // Slider variants - public static final short kControlSliderLiveFeedback = (1 << 0); - public static final short kControlSliderHasTickMarks = (1 << 1); - public static final short kControlSliderReverseDirection = (1 << 2); - public static final short kControlSliderNonDirectional = (1 << 3); - - // Data Browser - public static final int kDataBrowserItemNoProperty = 0; /* The anti-property (no associated data) */ - public static final int kDataBrowserItemIsActiveProperty = 1; /* Boolean typed data (defaults to true) */ - public static final int kDataBrowserItemIsSelectableProperty = 2; /* Boolean typed data (defaults to true) */ - public static final int kDataBrowserItemIsEditableProperty = 3; /* Boolean typed data (defaults to false, used for editable properties) */ - public static final int kDataBrowserItemIsContainerProperty = 4; /* Boolean typed data (defaults to false) */ - public static final int kDataBrowserContainerIsOpenableProperty = 5; /* Boolean typed data (defaults to true) */ - public static final int kDataBrowserContainerIsClosableProperty = 6; /* Boolean typed data (defaults to true) */ - public static final int kDataBrowserContainerIsSortableProperty = 7; /* Boolean typed data (defaults to true) */ - public static final int kDataBrowserItemSelfIdentityProperty = 8; /* kDataBrowserIconAndTextType (display property; ColumnView only) */ - public static final int kDataBrowserContainerAliasIDProperty = 9; /* DataBrowserItemID (alias/symlink an item to a container item) */ - public static final int kDataBrowserColumnViewPreviewProperty = 10; /* kDataBrowserCustomType (display property; ColumnView only) */ - public static final int kDataBrowserItemParentContainerProperty = 11; /* DataBrowserItemID (the parent of the specified item, used by ColumnView) */ - - // Notifications used in DataBrowserItemNotificationProcPtr - public static final int kDataBrowserItemAdded = 1; /* The specified item has been added to the browser */ - public static final int kDataBrowserItemRemoved = 2; /* The specified item has been removed from the browser */ - public static final int kDataBrowserEditStarted = 3; /* Starting an EditText session for specified item */ - public static final int kDataBrowserEditStopped = 4; /* Stopping an EditText session for specified item */ - public static final int kDataBrowserItemSelected = 5; /* Item has just been added to the selection set */ - public static final int kDataBrowserItemDeselected = 6; /* Item has just been removed from the selection set */ - public static final int kDataBrowserItemDoubleClicked = 7; - public static final int kDataBrowserContainerOpened = 8; /* Container is open */ - public static final int kDataBrowserContainerClosing = 9; /* Container is about to close (and will real soon now, y'all) */ - public static final int kDataBrowserContainerClosed = 10; /* Container is closed (y'all come back now!) */ - public static final int kDataBrowserContainerSorting = 11; /* Container is about to be sorted (lock any volatile properties) */ - public static final int kDataBrowserContainerSorted = 12; /* Container has been sorted (you may release any property locks) */ - public static final int kDataBrowserUserToggledContainer = 16; /* _User_ requested container open/close state to be toggled */ - public static final int kDataBrowserTargetChanged = 15; /* The target has changed to the specified item */ - public static final int kDataBrowserUserStateChanged = 13; /* The user has reformatted the view for the target */ - public static final int kDataBrowserSelectionSetChanged = 14; /* The selection set has been modified (net result may be the same) */ - - public static final int kDataBrowserNoItem= 0; + public static final int kControlProgressBarProc = 80; + public static final int kControlPushButtonProc = 368; + public static final int kControlRadioButtonAutoToggleProc = 372; + public static final int kControlScrollBarLiveProc = 386; + public static final int kControlSeparatorLineProc = 144; + public static final int kControlSliderLiveFeedback = (1 << 0); + public static final int kControlSliderNonDirectional = (1 << 3); + public static final int kControlSliderProc = 48; + public static final int kControlStructureMetaPart = -1; + public static final int kControlSupportsEmbedding = 1 << 1; + public static final int kControlSupportsFocus = 1 << 2; + public static final int kControlStaticTextCFStringTag = ('c'<<24) + ('f'<<16) + ('s'<<8) + 't'; + public static final int kControlTabContentRectTag = ('r'<<24) + ('e'<<16) + ('c'<<8) + 't'; + public static final int kControlTabDirectionNorth = 0; + public static final int kControlTabImageContentTag = ('c'<<24) + ('o'<<16) + ('n'<<8) + 't'; + public static final int kControlTabInfoVersionOne = 1; + public static final int kControlTabInfoTag = ('t'<<24) + ('a'<<16) + ('b'<<8) + 'i'; + public static final int kControlTabSizeLarge = 0; + public static final int kControlTabSmallProc = 129; + public static final int kControlUpButtonPart = 20; + public static final int kControlUserPaneDrawProcTag = ('d'<<24) + ('r'<<16) + ('a'<<8) + 'w'; + public static final int kControlUserPaneHitTestProcTag = ('h'<<24) + ('i'<<16) + ('t'<<8) + 't'; + public static final int kControlUserPaneProc = 256; + public static final int kControlUserPaneTrackingProcTag = ('t'<<24) + ('r'<<16) + ('a'<<8) + 'k'; + public static final int kControlUseFontMask = 0x1; + public static final int kControlUseSizeMask = 0x4; + public static final int kControlUseThemeFontIDMask = 0x80; + public static final int kControlUseFaceMask = 0x2; + public static final int kCurrentProcess = 2; + public static final int kDataBrowserCheckboxType = ('c'<<24) + ('h'<<16) + ('b'<<8) + 'x'; + public static final int kDataBrowserCmdTogglesSelection = 1 << 3; + public static final int kDataBrowserContainerClosed = 10; + public static final int kDataBrowserContainerClosing = 9; + public static final int kDataBrowserContainerIsClosableProperty = 6; + public static final int kDataBrowserContainerIsOpen = 1 << 1; + public static final int kDataBrowserContainerIsOpenableProperty = 5; + public static final int kDataBrowserContainerIsSortableProperty = 7; + public static final int kDataBrowserContainerOpened = 8; + public static final int kDataBrowserCustomType = 0x3F3F3F3F; public static final int kDataBrowserDefaultPropertyFlags = 0; - public static final int kDataBrowserPropertyIsMutable = 1 << 0; - - public static final int kDataBrowserTextType= ('t'<<24) + ('e'<<16) + ('x'<<8) + 't'; /* CFStringRef */ - public static final int kDataBrowserIconAndTextType= ('t'<<24) + ('i'<<16) + ('c'<<8) + 'n'; /* IconRef, CFStringRef, etc */ - public static final int kDataBrowserCheckboxType= ('c'<<24) + ('h'<<16) + ('b'<<8) + 'x'; /* ThemeButtonValue */ - + public static final int kDataBrowserDragSelect = 1 << 0; + public static final int kDataBrowserIconAndTextType = ('t'<<24) + ('i'<<16) + ('c'<<8) + 'n'; + public static final int kDataBrowserItemIsActiveProperty = 1; + public static final int kDataBrowserItemIsContainerProperty = 4; + public static final int kDataBrowserItemIsEditableProperty = 3; + public static final int kDataBrowserItemIsSelectableProperty = 2; + public static final int kDataBrowserItemIsSelected = 1 << 0; + public static final int kDataBrowserItemNoProperty = 0; + public static final int kDataBrowserItemParentContainerProperty = 11; + public static final int kDataBrowserItemsAdd = 0; + public static final int kDataBrowserItemsAssign = 1; + public static final int kDataBrowserItemsRemove = 3; + public static final int kDataBrowserItemRemoved = 2; + public static final int kDataBrowserItemSelected = 5; + public static final int kDataBrowserItemDeselected = 6; + public static final int kDataBrowserItemDoubleClicked = 7; + public static final int kDataBrowserLatestCallbacks = 0; + public static final int kDataBrowserLatestCustomCallbacks = 0; + public static final int kDataBrowserListView = ('l'<<24) + ('s'<<16) + ('t'<<8) + 'v'; public static final int kDataBrowserListViewLatestHeaderDesc = 0; - - public static final int kDataBrowserDragSelect = 1 << 0; - public static final int kDataBrowserSelectOnlyOne = 1 << 1; - public static final int kDataBrowserResetSelection = 1 << 2; - public static final int kDataBrowserCmdTogglesSelection = 1 << 3; - public static final int kDataBrowserNoDisjointSelection = 1 << 4; - public static final int kDataBrowserAlwaysExtendSelection = 1 << 5; + public static final int kDataBrowserListViewSelectionColumn = 1 << OS.kDataBrowserViewSpecificFlagsOffset; public static final int kDataBrowserNeverEmptySelectionSet = 1 << 6; - - public static final int kDataBrowserViewSpecificFlagsOffset = 16; - public static final int kDataBrowserListViewSelectionColumn= 1 << kDataBrowserViewSpecificFlagsOffset; - - // data browser item states - public static native int newColumnDesc(int propertyID, int propertyType, int propertyFlags, - short minimumWidth, short maximumWidth); - - public static native int AddDataBrowserListViewColumn(int cHandle, int handle, int index); - - public static native int createDataBrowserControl(int wHandle); - - public static native int AutoSizeDataBrowserListViewColumns(int cHandle); - - public static native void setDataBrowserCallbacks(int cHandle, int dataCallbackUPP, - int compareCallbackUPP, int itemNotificationCallbackUPP); - - public static native int SetDataBrowserActiveItems(int cHandle, boolean active); - public static native int AddDataBrowserItems(int cHandle, int containerID, int numItems, int[] itemIDs, int preSortProperty); - public static native int RemoveDataBrowserItems(int cHandle, int containerID, int numItems, int[] itemIDs, int preSortProperty); - - public static native int SetDataBrowserItemDataText(int itemRef, int sHandle); - public static native int SetDataBrowserItemDataBooleanValue(int itemRef, boolean data); - public static native int SetDataBrowserItemDataItemID(int itemRef, int itemID); - public static native int SetDataBrowserItemDataIcon(int itemRef, int iconRef); - public static native int SetDataBrowserItemDataButtonValue(int itemRef, short themeButtonValue); - - public static native int SetDataBrowserHasScrollBars(int cHandle, boolean hScroll, boolean vScroll); - public static native int SetDataBrowserListViewHeaderBtnHeight(int cHandle, short height); - public static native int UpdateDataBrowserItems(int cHandle, int container, int numItems, int[] items, int preSortProperty, int propertyID); - public static native int GetDataBrowserItemCount(int cHandle, int container, boolean recurse, int state, int[] numItems); - public static native int GetDataBrowserItems(int cHandle, int container, boolean recurse, int state, int handle); - public static native int RevealDataBrowserItem(int cHandle, int itemID, int colID, boolean center); - public static native boolean IsDataBrowserItemSelected(int cHandle, int itemID); - public static native int GetDataBrowserScrollPosition(int cHandle, int[] top, int[] left); - public static native int SetDataBrowserScrollPosition(int cHandle, int top, int left); - - /* Set operations for use with SetDataBrowserSelectedItems */ - public static final int kDataBrowserItemsAdd = 0; /* add specified items to existing set */ - public static final int kDataBrowserItemsAssign = 1; /* assign destination set to specified items */ - public static final int kDataBrowserItemsToggle = 2; /* toggle membership state of specified items */ - public static final int kDataBrowserItemsRemove = 3; /* remove specified items from existing set */ - - public static native int SetDataBrowserSelectionFlags(int cHandle, int selectionFlags); - public static native int SetDataBrowserSelectedItems(int cHandle, int numItems, int[] items, int operation); - - public static native int SetDataBrowserTarget(int cHandle, int rootID); - public static native int SetDataBrowserListViewDisclosureColumn(int cHandle, int colID, boolean b); - + public static final int kDataBrowserNoItem = 0; + public static final int kDataBrowserOrderIncreasing = 1; public static final int kDataBrowserPropertyEnclosingPart = 0; -// public static final int kDataBrowserPropertyContentPart = ('-'<<24) + ('-'<<16) + ('-'<<8) + '-'; -// public static final int kDataBrowserPropertyDisclosurePart = ('d'<<24) + ('i'<<16) + ('s'<<8) + 'c'; -// public static final int kDataBrowserPropertyTextPart = kDataBrowserTextType; -// public static final int kDataBrowserPropertyIconPart = kDataBrowserIconType; -// public static final int kDataBrowserPropertySliderPart = kDataBrowserSliderType; -// public static final int kDataBrowserPropertyCheckboxPart = kDataBrowserCheckboxType; -// public static final int kDataBrowserPropertyProgressBarPart = kDataBrowserProgressBarType; -// public static final int kDataBrowserPropertyRelevanceRankPart = kDataBrowserRelevanceRankType; - - public static native int GetDataBrowserItemPartBounds(int cHandle, int item, int property, - int part, short[] bounds); - - public static native int OpenDataBrowserContainer(int cHandle, int container); - public static native int CloseDataBrowserContainer(int cHandle, int container); - - public static final int kDataBrowserItemIsSelected = 1 << 0; - public static final int kDataBrowserContainerIsOpen = 1 << 1; - public static final int kDataBrowserItemIsDragTarget = 1 << 2; /* During a drag operation */ - - public static native int GetDataBrowserItemState(int cHandle, int item, int[] state); - - //---- User Pane - - // feature bits - //public static final int kControlSupportsGhosting = 1 << 0; - public static final int kControlSupportsEmbedding = 1 << 1; - public static final int kControlSupportsFocus = 1 << 2; - //public static final int kControlWantsIdle = 1 << 3; - //public static final int kControlWantsActivate = 1 << 4; - public static final int kControlHandlesTracking = 1 << 5; - //public static final int kControlSupportsDataAccess = 1 << 6; - //public static final int kControlHasSpecialBackground = 1 << 7; - public static final int kControlGetsFocusOnClick = 1 << 8; - //public static final int kControlSupportsCalcBestRect = 1 << 9; - //public static final int kControlSupportsLiveFeedback = 1 << 10; - //public static final int kControlHasRadioBehavior = 1 << 11; - //public static final int kControlSupportsDragAndDrop = 1 << 12; - //public static final int kControlAutoToggles = 1 << 14; - //public static final int kControlSupportsGetRegion = 1 << 17; - //public static final int kControlSupportsFlattening = 1 << 19; - //public static final int kControlSupportsSetCursor = 1 << 20; - //public static final int kControlSupportsContextualMenus = 1 << 21; - //public static final int kControlSupportsClickActivation = 1 << 22; - //public static final int kControlIdlesWithTimer = 1 << 23; - - public static final int kControlUserPaneDrawProcTag= ('d'<<24) + ('r'<<16) + ('a'<<8) + 'w'; - public static final int kControlUserPaneHitTestProcTag= ('h'<<24) + ('i'<<16) + ('t'<<8) + 't'; - public static final int kControlUserPaneTrackingProcTag= ('t'<<24) + ('r'<<16) + ('a'<<8) + 'k'; - - // StaticText - public static final int kControlStaticTextCFStringTag= ('c'<<24) + ('f'<<16) + ('s'<<8) + 't'; - - // TextEdit - public static final int kControlEditTextTextTag= ('t'<<24) + ('e'<<16) + ('x'<<8) + 't'; - public static final int kControlEditTextSelectionTag= ('s'<<24) + ('e'<<16) + ('l'<<8) + 'e'; - public static final int kControlEditTextCFStringTag= ('c'<<24) + ('f'<<16) + ('s'<<8) + 't'; - public static final int kControlEditTextLockedTag= ('l'<<24) + ('o'<<16) + ('c'<<8) + 'k'; - - /* - public static native int CreateEditUnicodeTextControl(int wHandle, short[] bounds, int sHandle, - boolean isPassword, int styleHandle, int[] outControl); - */ - - ///// MLTE Text - public static final int kTXNWantHScrollBarMask = 1 << 2; - public static final int kTXNWantVScrollBarMask = 1 << 3; - public static final int kTXNReadOnlyMask = 1 << 5; - public static final int kTXNAlwaysWrapAtViewEdgeMask = 1 << 11; + public static final int kDataBrowserPropertyIsMutable = 1 << 0; + public static final int kDataBrowserRevealOnly = 0; + public static final int kDataBrowserRevealAndCenterInView = 1 << 0; + public static final int kDataBrowserRevealWithoutSelecting = 1 << 1; + public static final int kDataBrowserSelectOnlyOne = 1 << 1; + public static final int kDataBrowserTextType = ('t'<<24) + ('e'<<16) + ('x'<<8) + 't'; + public static final int kDataBrowserTableViewFillHilite = 1; + public static final int kDataBrowserViewSpecificFlagsOffset = 16; + public static final int kDocumentWindowClass = 6; + public static final int kEventAppleEvent = 1; + public static final int kEventAttributeUserEvent = 1 << 0; + public static final int kEventClassAppleEvent = ('e'<<24) + ('p'<<16) + ('p'<<8) + 'c'; + public static final int kEventClassCommand = ('c'<<24) + ('m'<<16) + ('d'<<8) + 's'; + public static final int kEventClassControl = ('c'<<24) + ('n'<<16) + ('t'<<8) + 'l'; + public static final int kEventClassFont= ('f'<<24) + ('o'<<16) + ('n'<<8) + 't'; + public static final int kEventClassHIObject = ('h'<<24) + ('i'<<16) + ('o'<<8) + 'b'; + public static final int kEventClassKeyboard = ('k'<<24) + ('e'<<16) + ('y'<<8) + 'b'; + public static final int kEventClassMenu = ('m'<<24) + ('e'<<16) + ('n'<<8) + 'u'; + public static final int kEventClassMouse = ('m'<<24) + ('o'<<16) + ('u'<<8) + 's'; + public static final int kEventClassTextInput = ('t'<<24) + ('e'<<16) + ('x'<<8) + 't'; + public static final int kEventClassWindow = ('w'<<24) + ('i'<<16) + ('n'<<8) + 'd'; + public static final int kEventControlActivate = 9; + public static final int kEventControlAddedSubControl = 152; + public static final int kEventControlBoundsChanged = 154; + public static final int kEventControlClick = 13; + public static final int kEventControlContextualMenuClick = 12; + public static final int kEventControlDeactivate = 10; + public static final int kEventControlDraw = 4; + public static final int kControlFocusNextPart = -1; + public static final int kEventControlHit = 1; + public static final int kEventControlSetCursor = 11; + public static final int kEventControlSetFocusPart = 7; + public static final int kEventControlRemovingSubControl = 153; + public static final int kEventPriorityStandard = 1; + public static final double kEventDurationForever = -1.0; + public static final double kEventDurationNoWait = 0.0; + public static final int kEventFontSelection = 2; + public static final int kEventFontPanelClosed = 1; + public static final int kEventHIObjectConstruct = 1; + public static final int kEventHIObjectDestruct = 3; + public static final int kEventMenuClosed = 5; + public static final int kEventMenuOpening = 4; + public static final int kEventMenuPopulate = 9; + public static final int kEventMouseButtonPrimary = 1; + public static final int kEventMouseButtonSecondary = 2; + public static final int kEventMouseButtonTertiary = 3; + public static final int kEventMouseDown = 1; + public static final int kEventMouseDragged = 6; + public static final int kEventMouseEntered = 8; + public static final int kEventMouseExited = 9; + public static final int kEventMouseMoved = 5; + public static final int kEventMouseUp = 2; + public static final int kEventMouseWheelMoved = 10; + public static final int kEventParamAEEventClass = ('e'<<24) + ('v'<<16) + ('c'<<8) + 'l'; + public static final int kEventParamAEEventID = ('e'<<24) + ('v'<<16) + ('t'<<8) + 'i'; + public static final int kEventParamAttributes = ('a'<<24) + ('t'<<16) + ('t'<<8) + 'r'; + public static final int kEventParamCGContextRef= ('c'<<24) + ('n'<<16) + ('t'<<8) + 'x'; + public static final int kEventParamClickCount = ('c'<<24) + ('c'<<16) + ('n'<<8) + 't'; + public static final int kEventParamControlPart= ('c'<<24) + ('p'<<16) + ('r'<<8) + 't'; + public static final int kEventParamControlRef = ('c'<<24) + ('t'<<16) + ('r'<<8) + 'l'; + public static final int kEventParamCurrentBounds = ('c'<<24) + ('r'<<16) + ('c'<<8) + 't'; + public static final int kEventParamDirectObject = ('-'<<24) + ('-'<<16) + ('-'<<8) + '-'; + public static final int kEventParamFMFontFamily = ('f'<<24) + ('m'<<16) + ('f'<<8) + 'm'; + public static final int kEventParamFMFontStyle = ('f'<<24) + ('m'<<16) + ('s'<<8) + 't'; + public static final int kEventParamFMFontSize = ('f'<<24) + ('m'<<16) + ('s'<<8) + 'z'; + public static final int kEventParamFontColor = ('f'<<24) + ('c'<<16) + ('l'<<8) + 'r'; + public static final int kEventParamKeyCode = ('k'<<24) + ('c'<<16) + ('o'<<8) + 'd'; + public static final int kEventParamKeyMacCharCodes = ('k'<<24) + ('c'<<16) + ('h'<<8) + 'r'; + public static final int kEventParamKeyModifiers = ('k'<<24) + ('m'<<16) + ('o'<<8) + 'd'; + public static final int kEventParamMouseButton = ('m'<<24) + ('b'<<16) + ('t'<<8) + 'n'; + public static final int kEventParamMouseChord = ('c'<<24) + ('h'<<16) + ('o'<<8) + 'r'; + public static final int kEventParamMouseLocation = ('m'<<24) + ('l'<<16) + ('o'<<8) + 'c'; + public static final int kEventParamMouseWheelDelta = ('m'<<24) + ('w'<<16) + ('d'<<8) + 'l'; + public static final int kEventParamPreviousBounds = ('p'<<24) + ('r'<<16) + ('c'<<8) + 't'; + public static final int kEventParamOriginalBounds = ('o'<<24) + ('r'<<16) + ('c'<<8) + 't'; + public static final int kEventParamRgnHandle = ('r'<<24) + ('g'<<16) + ('n'<<8) + 'h'; + public static final int kEventParamTextInputSendText = ('t'<<24) + ('s'<<16) + ('t'<<8) + 'x'; + public static final int kEventParamWindowDefPart = ('w'<<24) + ('d'<<16) + ('p'<<8) + 'c'; + public static final int kEventParamWindowMouseLocation = ('w'<<24) + ('m'<<16) + ('o'<<8) + 'u'; + public static final int kEventParamWindowRef = ('w'<<24) + ('i'<<16) + ('n'<<8) + 'd'; + public static final int kEventProcessCommand = 1; + public static final int kEventRawKeyDown = 1; + public static final int kEventRawKeyRepeat = 2; + public static final int kEventRawKeyUp = 3; + public static final int kEventRawKeyModifiersChanged = 4; + public static final int kEventTextInputUnicodeForKeyEvent = 2; + public static final int kEventWindowActivated = 5; + public static final int kEventWindowBoundsChanged = 27; + public static final int kEventWindowClose = 72; + public static final int kEventWindowCollapsed = 67; + public static final int kEventWindowDeactivated = 6; + public static final int kEventWindowDrawContent = 2; + public static final int kEventWindowExpanded = 70; + public static final int kEventWindowFocusAcquired = 200; + public static final int kEventWindowFocusRelinquish = 201; + public static final int kEventWindowHidden = 25; + public static final int kEventWindowShown = 24; + public static final int kEventWindowUpdate = 1; + public static final int kFMIterationCompleted = -980; + public static final int kFloatingWindowClass = 5; + public static final int kFontSelectionQDStyleVersionZero = 0; + public static final int kFontSelectionQDType = ('q'<<24) + ('s'<<16) + ('t'<<8) + 'l'; + public static final int kHIComboBoxAutoCompletionAttribute = (1 << 0); + public static final int kHIComboBoxAutoSizeListAttribute = (1 << 3); + public static final int kHIComboBoxEditTextPart = 5; + public static final int kHICommandFromMenu = 1 << 0; + public static final int kHIViewZOrderAbove = 1; + public static final int kHIViewZOrderBelow = 2; + public static final int kHMCFStringContent = ('c'<<24) + ('f'<<16) + ('s'<<8) + 't'; + public static final int kHMAbsoluteCenterAligned = 23; + public static final int kHMContentProvided = 0; + public static final int kHMContentNotProvided = -1; + public static final int kHMContentNotProvidedDontPropagate = -2; + public static final int kHMDefaultSide = 0; + public static final int kHMDisposeContent = 1; + public static final int kHMSupplyContent = 0; + public static final int kHelpWindowClass = 10; + public static final int kInvalidFontFamily = -1; + public static final int kMacHelpVersion = 3; + public static final int kMenuBlankGlyph = 97; + public static final int kMenuCapsLockGlyph = 99; + public static final int kMenuCGImageRefType = 7; + public static final int kMenuCheckmarkGlyph = 18; + public static final int kMenuClearGlyph = 28; + public static final int kMenuCommandGlyph = 17; + public static final int kMenuContextualMenuGlyph = 109; + public static final int kMenuControlGlyph = 6; + public static final int kMenuControlISOGlyph = 138; + public static final int kMenuControlModifier = 4; + public static final int kMenuDeleteLeftGlyph = 23; + public static final int kMenuDeleteRightGlyph = 10; + public static final int kMenuDiamondGlyph = 19; + public static final int kMenuDownArrowGlyph = 106; + public static final int kMenuDownwardArrowDashedGlyph = 16; + public static final int kMenuEnterGlyph = 4; + public static final int kMenuEscapeGlyph = 27; + public static final int kMenuF10Glyph = 120; + public static final int kMenuF11Glyph = 121; + public static final int kMenuF12Glyph = 122; + public static final int kMenuF1Glyph = 111; + public static final int kMenuF2Glyph = 112; + public static final int kMenuF3Glyph = 113; + public static final int kMenuF4Glyph = 114; + public static final int kMenuF5Glyph = 115; + public static final int kMenuF6Glyph = 116; + public static final int kMenuF7Glyph = 117; + public static final int kMenuF8Glyph = 118; + public static final int kMenuF9Glyph = 119; + public static final int kMenuHelpGlyph = 103; + public static final int kMenuItemAttrSeparator = 64; + public static final int kMenuLeftArrowDashedGlyph = 24; + public static final int kMenuLeftArrowGlyph = 100; + public static final int kMenuNoCommandModifier = (1 << 3); + public static final int kMenuNoIcon = 0; + public static final int kMenuNoModifiers = 0; + public static final int kMenuNonmarkingReturnGlyph = 13; + public static final int kMenuNullGlyph = 0; + public static final int kMenuOptionGlyph = 7; + public static final int kMenuOptionModifier = (1 << 1); + public static final int kMenuPageDownGlyph = 107; + public static final int kMenuPageUpGlyph = 98; + public static final int kMenuPencilGlyph = 15; + public static final int kMenuPowerGlyph = 110; + public static final int kMenuReturnGlyph = 11; + public static final int kMenuReturnR2LGlyph = 12; + public static final int kMenuRightArrowDashedGlyph = 26; + public static final int kMenuRightArrowGlyph = 101; + public static final int kMenuShiftGlyph = 5; + public static final int kMenuShiftModifier = (1 << 0); + public static final int kMenuTabRightGlyph = 2; + public static final int kMenuUpArrowDashedGlyph = 25; + public static final int kMenuUpArrowGlyph = 104; + public static final int kMouseTrackingMouseDown= 1; + public static final int kMouseTrackingMouseUp= 2; + public static final int kMouseTrackingMouseExited = 3; + public static final int kMouseTrackingMouseEntered = 4; + public static final int kMouseTrackingMouseDragged= 5; + public static final int kMouseTrackingMouseKeyModifiersChanged= 6; + public static final int kMouseTrackingUserCancelled= 7; + public static final int kMouseTrackingTimedOut= 8; + public static final int kMouseTrackingMouseMoved= 9; + public static final int kModalWindowClass = 3; + public static final int kMovableModalWindowClass = 4; + public static final int kNavAllowInvisibleFiles = 0x00000100; + public static final int kNavAllowMultipleFiles = 0x00000080; + public static final int kNavAllowOpenPackages = 0x00002000; + public static final int kNavCBNewLocation = 5; + public static final int kNavGenericSignature = ('*'<<24) + ('*'<<16) + ('*'<<8) + '*'; + public static final int kNavSupportPackages = 0x00001000; + public static final int kNavUserActionCancel = 1; + public static final int kNavUserActionChoose = 4; + public static final int kNavUserActionOpen = 2; + public static final int kNavUserActionSaveAs = 3; + public static final int kQDUseCGTextMetrics = (1 << 2); + public static final int kQDUseCGTextRendering = (1 << 1); + public static final int kScrapFlavorTypeText = ('T'<<24) + ('E'<<16) + ('X'<<8) + 'T'; + public static final boolean kScrollBarsSyncAlwaysActive = true; + public static final boolean kScrollBarsSyncWithFocus = false; + public static final int kSheetWindowClass = 11; + public static final int kStdCFStringAlertVersionOne = 1; + public static final int kControlSliderDoesNotPoint = 2; + public static final int kTXNAlwaysWrapAtViewEdgeMask = 1 << 11; + public static final int kTXNDisableDragAndDropTag = ('d'<<24) + ('r'<<16) + ('a'<<8) + 'g'; + public static final int kTXNDoFontSubstitution = ('f'<<24) + ('s'<<16) + ('u'<<8) + 'b'; public static final int kTXNDontDrawCaretWhenInactiveMask = 1 << 12; - public static final int kTXNSingleLineOnlyMask = 1 << 14; - public static final int kTXNMonostyledTextMask = 1 << 17; - - public static final int kTXNTextEditStyleFrameType = 1; - - public static final int kTXNUnicodeTextFile = ('u'<<24) + ('t'<<16) + ('x'<<8) + 't'; - - public static final int kTXNSystemDefaultEncoding = 0; - - public static final int kTXNUnicodeTextData = ('u'<<24) + ('t'<<16) + ('x'<<8) + 't'; - - public static final int kTXNWordWrapStateTag = ('w'<<24) + ('w'<<16) + ('r'<<8) + 's'; - public static final int kTXNTabSettingsTag = ('t'<<24) + ('a'<<16) + ('b'<<8) + 's'; - public static final int kTXNDoFontSubstitution = ('f'<<24) + ('s'<<16) + ('u'<<8) + 'b'; - public static final int kTXNVisibilityTag = ('v'<<24) + ('i'<<16) + ('s'<<8) + 'b'; - - /* kTXNWordWrapStateTag */ - public static final boolean kTXNAutoWrap = false; - public static final boolean kTXNNoAutoWrap = true; - - /* TXNScrollBarState */ - public static final boolean kScrollBarsAlwaysActive = true; - public static final boolean kScrollBarsSyncWithFocus = false; - - // Offsets - public static final int kTXNUseCurrentSelection = -1; - public static final int kTXNStartOffset = 0; - public static final int kTXNEndOffset = 2147483647; - - - public static native int TXNInitTextension(); - public static native int TXNNewObject(int fileSpec, int wHandle, short[] bounds, int frameOptions, - int frameType, int fileType, int iPermanentEncoding, int[] handle, int[] frameID, int refcon); - public static native void TXNDeleteObject(int txHandle); - public static native void TXNSetFrameBounds(int txHandle, int top, int left, int bottom, int right, int frameID); - public static native void TXNDraw(int txHandle, int gDevice); - public static native int TXNGetData(int txHandle, int startOffset, int endOffset, int[] dataHandle); - public static native int TXNSetData(int txHandle, char[] data, int startOffset, int endOffset); - public static native int TXNGetLineCount(int txHandle, int[] lineTotal); - public static native int TXNDataSize(int txHandle); - public static native void TXNGetSelection(int txHandle, int[] startOffset, int[] endOffset); - public static native int TXNSetSelection(int txHandle, int startOffset, int endOffset); - public static native void TXNSelectAll(int txHandle); - public static native void TXNShowSelection(int txHandle, boolean showEnd); - public static native void TXNKeyDown(int txHandle, int[] eventData); - public static native void TXNClick(int txHandle, int[] eventData); - public static native void TXNFocus(int txHandle, boolean becomingFocused); - public static native int TXNCut(int txHandle); - public static native int TXNCopy(int txHandle); - public static native int TXNPaste(int txHandle); - public static native int TXNGetRectBounds(int txHandle, short[] viewRect, int[] destinationRect, int[] textRect); - public static native void TXNSetRectBounds(int txHandle, short[] viewRect, int[] destRect, boolean update); - public static native int TXNActivate(int txHandle, int frameID, boolean scrollBarState); - public static native int TXNEchoMode(int txHandle, char echoCharacter, int encoding, boolean on); - public static native int TXNOffsetToPoint(int txHandle, int offset, short[] point); - public static native void TXNResizeFrame(int txHandle, int width, int height, int frameID); - public static native void TXNGetViewRect(int txHandle, short[] viewRect); - public static native int TXNGetLineMetrics(int txHandle, int lineNumber, int[] lineWidth, int[] lineHeight); - public static native void TXNForceUpdate(int txHandle); - public static native int TXNSetTXNObjectControls(int txHandle, boolean clearAll, int controlCount, int[] controlTags, int[] controlData); - //public static native int TXNSetBackground(int txHandle, TXNBackground *iBackgroundInfo); - public static native void setTXNMargins(int txHandle, short margin); - - // TabFolder - public static final int kControlTabInfoTag= ('t'<<24) + ('a'<<16) + ('b'<<8) + 'i'; /* ControlTabInfoRec*/ - public static final int kControlTabContentRectTag= ('r'<<24) + ('e'<<16) + ('c'<<8) + 't'; /* Rect*/ - - public static native int CreateTabFolderControl(int wHandle, int[] cHandle); - public static native int setTabText(int cHandle, int index, int sHandle); - public static native int setTabIcon(int cHandle, int index, int iconHandle); - - // Popup menus - /* - public static final int kControlPopupButtonMenuRefTag = OSType("mhan"); // MenuRef - public static final int kControlPopupButtonExtraHeightTag = OSType("exht"); // SInt16 - extra vertical whitespace within the button - public static final int kControlPopupButtonOwnedMenuRefTag = OSType("omrf"); // MenuRef - public static final int kControlPopupButtonCheckCurrentTag = OSType("chck"); // Boolean - whether the popup puts a checkmark next to the current item (defaults to true) - public static native int CreatePopupButtonControl(int wHandle, short[] bounds, int sHandle, short menuID, - boolean variableWidth, short titleWidth, short titleJustification, byte titleStyle, int[] outControl); - */ - public static native void SetControlPopupMenuHandle(int cHandle, int popupMenuHandle); - - //---- Alerts and Dialogs - // Alert types - public static final short kAlertStopAlert = 0; - public static final short kAlertNoteAlert = 1; - public static final short kAlertCautionAlert = 2; - public static final short kAlertPlainAlert = 3; - - public static native int CreateStandardAlert(short alertType, int errorSHandle, int explanationSHandle, - int alertParamHandle, int[] dialogHandle); - - public static native int RunStandardAlert(int dialogHandle, int modalFilterUPP, short[] itemHit); - - public static native int PickColor(short[] rgb, short[] where, byte[] title, boolean[] success); - - // File dialog - public static final int kNavAllowMultipleFiles= 0x00000080; /* allow multiple items to be selected */ - - public static final int kNavUserActionNone = 0; - public static final int kNavUserActionCancel = 1; /* The user cancelled the dialog. */ - public static final int kNavUserActionOpen = 2; /* Open button in the GetFile dialog. */ - public static final int kNavUserActionSaveAs = 3; /* Save button in the PutFile dialog. */ - public static final int kNavUserActionChoose = 4; /* Choose button in the ChooseFile, ChooseFolder, ChooseVolume or ChooseObject dialogs.*/ - public static final int kNavUserActionNewFolder = 5; /* New Folder button in the New Folder dialog. */ - public static final int kNavUserActionSaveChanges = 6; /* Save button in an AskSaveChanges dialog. */ - public static final int kNavUserActionDontSaveChanges = 7; /* Don't Save button in an AskSaveChanges dialog. */ - public static final int kNavUserActionDiscardChanges = 8; /* Discard button in the AskDiscardChanges dialog. */ - public static final int kNavUserActionReviewDocuments = 9; /* Review Unsaved button in the AskReviewDocuments dialog (Mac OS X only). */ - public static final int kNavUserActionDiscardDocuments = 10; /* The user clicked the Discard Changes button in the AskReviewDocuments dialog (Mac OS X only). */ - - public static native int NavCreateGetFileDialog(int options, int titleHandle, int parentHandle, int[] dialogHandle); - public static native int NavCreatePutFileDialog(int options, int titleHandle, int parentHandle, int[] dialogHandle, - int fileType, int fileCreator); - public static native int NavCreateChooseFolderDialog(int options, int windowTitle, int messageHandle, - int parentWindowHandle, int[] dialogHandle); - - public static native int NavDialogSetSaveFileName(int dialogHandle, int fileNameHandle); - public static native int NavDialogGetSaveFileName(int dialogHandle); - - public static native int NavDialogRun(int dialogHandle); - public static native int NavDialogGetUserAction(int dialogHandle); - - public static native int NavDialogGetReply(int dialogHandle, int[] replyHandle); - public static native int NavReplyRecordGetSelection(int replyHandle); // returns AEDescList - public static native void NavDialogDisposeReply(int replyHandle); - - public static native int AECountItems(int aeDescList, int[] count); - public static native int AEGetNthPtr(int aeDescList, int oneBasedIndex, int[] sHandle); - - public static native int getFiles(int dialogHandle); - public static native void NavDialogDispose(int dialogHandle); - - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // CFStrings - ////////////////////////////////////////////////////////////////////////////////////////////////// - public static native int CFStringCreateWithCharacters(String s); - public static native void CFRelease(int sHandle); - public static native int CFStringGetLength(int sHandle); - public static native void CFStringGetCharacters(int sHandle, int start, int length, char[] buffer); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Handles - ////////////////////////////////////////////////////////////////////////////////////////////////// - public static native int NewHandle(int size); - public static native int NewHandleClear(int size); - public static native void DisposeHandle(int handle); - public static native int GetHandleSize(int handle); - public static native void getHandleData(int handle, char[] data); - public static native void getHandleData(int handle, int[] data); - public static native int DerefHandle(int handle); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Ptrs - ////////////////////////////////////////////////////////////////////////////////////////////////// - public static native int NewPtr(int size); - public static native int NewPtrClear(int size); - public static native void DisposePtr(int ptr); - public static native int GetPtrSize(int ptr); - //public static native int MemError(); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Unix memory utilities - ////////////////////////////////////////////////////////////////////////////////////////////////// - public static native void memcpy(int dest, int src, int n); - public static native void memcpy(int dest, byte[] src, int n); - public static native void memcpy(byte[] dest, int src, int n); - public static native void memset(int dest, int value, int size); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Scrap - ////////////////////////////////////////////////////////////////////////////////////////////////// - - public static native int GetCurrentScrap(int[] scrapHandle); - public static native int GetScrapFlavorCount(int scrapHandle, int[] flavorCount); - public static native int GetScrapFlavorInfoList(int scrapHandle, int[] flavorCount, int[] info); - public static native int GetScrapFlavorSize(int scrapHandle, int flavorType, int[] size); - public static native int GetScrapFlavorData(int scrapHandle, int flavorType, int[] size, byte[] data); - public static native int PutScrapFlavor(int scrapHandle, int flavorType, int flavorFlags, byte[] data); - public static native int ClearCurrentScrap(); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Misc - ////////////////////////////////////////////////////////////////////////////////////////////////// - public static native short HiWord(int doubleWord); - public static native short LoWord(int doubleWord); - public static native void SysBeep(short duration); - public static native int GetDblTime(); - public static native int GetCaretTime(); - public static native int GetAvailableWindowPositioningBounds(int gHandle, short[] mainScreenRect); - - public static native int GetIconRef(short vRefNum, int creator, int iconType, int[] iconRef); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - // Jaguar - ////////////////////////////////////////////////////////////////////////////////////////////////// - - // HIObject - public static final int kEventClassHIObject= ('h'<<24) + ('i'<<16) + ('o'<<8) + 'b'; - - public static final int kEventHIObjectConstruct= 1; - public static final int kEventHIObjectInitialize= 2; - public static final int kEventHIObjectDestruct= 3; - //public static final int kEventHIObjectIsEqual= 4; - //public static final int kEventHIObjectPrintDebugInfo= 5; - - public static native int HIObjectRegisterSubclass(int inClassID, int inBaseClassID, int inOptions, - int inConstructProc, int[] inEventList, int inConstructData, int[] outClassRef); - public static native int HIObjectCreate(int inClassID, int inConstructData, int[] outObject); - public static native int HIObjectCopyClassID(int inObject); - - // HIView - public static final int kEventControlDraw= 4; - public static final int kEventControlAddedSubControl= 152; - public static final int kEventControlRemovingSubControl= 153; - public static native int HIViewAddSubview(int parent, int child); - public static native int HIViewRemoveFromSuperview(int inView); - public static native int HIViewGetFrame(int inView, float[] outRect); - public static native int HIViewSetFrame(int inView, int x, int y, int width, int height); - public static native int HIViewSetDrawingEnabled(int inView, boolean isEnabled); - public static native int HIViewSimulateClick(int inView, short inPartToClick, int modifiers, - short[] outPartClicked); - public static native int HIViewSetZOrder(int inView, int inOp, int inOther); - public static final int kHIViewZOrderAbove= 1; - public static final int kHIViewZOrderBelow= 2; - - public static native int HIViewClick(int inView, int inEvent); - public static native int HIViewConvertPoint(float[] ioPoint, int inSourceView, int inDestView); - public static native int HIViewGetRoot(int wHandle); - public static native int HIViewSetNeedsDisplay(int inView, boolean inNeedsDisplay); - public static native int HIViewSetNeedsDisplayInRegion(int inView, int inRgn, boolean inNeedsDisplay); - public static native int HIViewSetVisible(int inView, boolean inVisible); - public static native int HIViewChangeAttributes(int inView, int inAttrsToSet, int inAttrsToClear); - public static native int HIViewFindByID(int inStartView, int inID, int[] outControl); - public static native int HIViewGetViewForMouseEvent(int inView, int inEvent, int[] outView); - - // HIComboBox - public static final short kHIComboBoxEditTextPart= 5; - public static final short kHIComboBoxDisclosurePart= 28; - - public static native int HIComboBoxCreate(int[] outComboBox, int attributes); - public static final int kHIComboBoxNoAttributes = 0; - public static final int kHIComboBoxAutoCompletionAttribute = (1 << 0); - public static final int kHIComboBoxAutoDisclosureAttribute = (1 << 1); - public static final int kHIComboBoxAutoSortAttribute = (1 << 2); - public static final int kHIComboBoxAutoSizeListAttribute = (1 << 3); - public static final int kHIComboBoxStandardAttributes = (kHIComboBoxAutoCompletionAttribute | kHIComboBoxAutoDisclosureAttribute | kHIComboBoxAutoSizeListAttribute); - - public static native int HIComboBoxGetItemCount(int inComboBox); - public static native int HIComboBoxInsertTextItemAtIndex(int inComboBox, int inIndex, int inText); - public static native int HIComboBoxAppendTextItem(int inComboBox, int inText); - public static native int HIComboBoxRemoveItemAtIndex(int inComboBox, int inIndex); - - public static native int HIComboBoxCopyTextItemAtIndex(int inComboBox, int inIndex, int[] outString); - - public static native void Init(); - - // core graphics - - public static native int QDBeginCGContext(int inPort, int[] outContext); - public static native int QDEndCGContext(int inPort, int[] inoutContext); - public static native int SyncCGContextOriginWithPort(int inContext, int port); - - public static native void CGContextSaveGState(int inContext); - public static native void CGContextRestoreGState(int inContext); - - public static native void CGContextStrokeRect(int inContext, float x, float y, float w, float h); - public static native void CGContextFillRect(int inContext, float x, float y, float w, float h); - - public static native void CGContextScaleCTM(int inContext, float sx, float sy); - public static native void CGContextTranslateCTM(int inContext, float tx, float ty); - - public static native void CGContextClipToRect(int inContext, float x, float y, float w, float h); - public static native int ClipCGContextToRegion(int inContext, short[] portRect, int rgnHandle); - - public static native void CGContextBeginPath(int inContext); - public static native void CGContextMoveToPoint(int inContext, float x, float y); - public static native void CGContextAddArc(int inContext, float x, float y, float radius, - float startAngle, float endAngle, int clockwise); - public static native void CGContextClosePath(int inContext); - public static native void CGContextStrokePath(int inContext); - public static native void CGContextFillPath(int inContext); - - public static native void CGContextShowGlyphsAtPoint(int inContext, float x, float y, char[] glyphs); - public static native void CGContextShowTextAtPoint(int inContext, float x, float y, byte[] chars); - - // process manager - public static native int GetCurrentProcess(int[] psn); - public static native int SetFrontProcess(int[] psn); - - public static final int kCFAllocatorDefault = 0; + public static final int kTXNEndOffset = 2147483647; + public static final int kTXNMarginsTag = ('m'<<24) + ('a'<<16) + ('r'<<8) + 'g'; + public static final int kTXNMonostyledTextMask = 1 << 17; + public static final int kTXNReadOnlyMask = 1 << 5; + public static final int kTXNSingleLineOnlyMask = 1 << 14; + public static final int kTXNStartOffset = 0; + public static final int kTXNSystemDefaultEncoding = 0; + public static final int kTXNTextEditStyleFrameType = 1; + public static final int kTXNUnicodeTextData = ('u'<<24) + ('t'<<16) + ('x'<<8) + 't'; + public static final int kTXNUnicodeTextFile = ('u'<<24) + ('t'<<16) + ('x'<<8) + 't'; + public static final int kTXNUseCurrentSelection = -1; + public static final int kTXNVisibilityTag = ('v'<<24) + ('i'<<16) + ('s'<<8) + 'b'; + public static final int kTXNWantHScrollBarMask = 1 << 2; + public static final int kTXNWantVScrollBarMask = 1 << 3; + public static final int kThemeArrowButton = 4; + public static final int kThemeArrowCursor = 0; + public static final int kThemeBrushDialogBackgroundActive = 1; + public static final int kThemeBrushDocumentWindowBackground = 15; + public static final int kThemeBrushPrimaryHighlightColor = -3; + public static final int kThemeBrushSecondaryHighlightColor = -4; + public static final int kThemeBrushButtonFaceActive = 29; + public static final int kThemeBrushFocusHighlight = 19; + public static final int kThemeBrushListViewBackground = 10; + public static final int kThemeButtonOff = 0; + public static final int kThemeButtonOn = 1; + public static final int kThemeCheckBox = 1; + public static final int kThemeCrossCursor = 5; + public static final int kThemeCurrentPortFont = 200; + public static final int kThemeDisclosureButton = 6; + public static final int kThemeDisclosureRight = 0; + public static final int kThemeDisclosureDown = 1; + public static final int kThemeDisclosureLeft = 2; + public static final int kThemeEmphasizedSystemFont = 4; + public static final int kThemeIBeamCursor = 4; + public static final int kThemeMetricDisclosureTriangleHeight = 25; + public static final int kThemeMetricCheckBoxWidth = 50; + public static final int kThemeMetricRadioButtonWidth = 52; + public static final int kThemeMetricEditTextFrameOutset = 5; + public static final int kThemeMetricFocusRectOutset = 7; + public static final int kThemeMetricHSliderHeight = 41; + public static final int kThemeMetricNormalProgressBarThickness = 58; + public static final int kThemeMetricScrollBarWidth = 0; + public static final int kThemeMetricVSliderWidth = 45; + public static final int kThemeNotAllowedCursor = 18; + public static final int kThemePointingHandCursor = 10; + public static final int kThemePushButton = 0; + public static final int kThemePushButtonFont = 105; + public static final int kThemeRadioButton = 2; + public static final int kThemeResizeLeftRightCursor = 17; + public static final int kThemeResizeLeftCursor = 15; + public static final int kThemeResizeRightCursor = 16; + public static final int kThemeRoundedBevelButton = 15; + public static final int kThemeSmallBevelButton = 8; + public static final int kThemeSmallEmphasizedSystemFont = 2; + public static final int kThemeSmallSystemFont = 1; + public static final int kThemeSpinningCursor = 14; + public static final int kThemeStateActive = 1; + public static final int kThemeStateInactive = 0; + public static final int kThemeStatePressed = 2; + public static final int kThemeSystemFont = 0; + public static final int kThemeTextColorDocumentWindowTitleActive = 23; + public static final int kThemeTextColorDocumentWindowTitleInactive = 24; + public static final int kThemeTextColorListView = 22; + public static final int kThemeTextColorPushButtonActive = 12; + public static final int kThemeToolbarFont = 108; + public static final int kThemeViewsFont = 3; + public static final int kThemeWatchCursor = 7; + public static final int kTransformSelected = 0x4000; + public static final int kUtilityWindowClass = 8; + public static final int kWindowActivationScopeNone = 0; + public static final int kWindowActivationScopeIndependent = 1; + public static final int kWindowActivationScopeAll = 2; + public static final int kWindowAlertPositionParentWindowScreen = 0x700A; + public static final int kWindowBoundsChangeOriginChanged = 1<<3; + public static final int kWindowBoundsChangeSizeChanged = 1<<2; + public static final int kWindowCascadeOnMainScreen = 4; + public static final int kWindowCloseBoxAttribute = (1 << 0); + public static final int kWindowCollapseBoxAttribute = (1 << 3); + public static final int kWindowCompositingAttribute = (1 << 19); + public static final int kWindowContentRgn = 33; + public static final int kWindowGroupAttrHideOnCollapse = 16; + public static final int kWindowHorizontalZoomAttribute = 1 << 1; + public static final int kWindowVerticalZoomAttribute = 1 << 2; + public static final int kWindowFullZoomAttribute = (OS.kWindowVerticalZoomAttribute | OS.kWindowHorizontalZoomAttribute); + public static final int kWindowLiveResizeAttribute = (1 << 28); + public static final int kWindowModalityAppModal = 2; + public static final int kWindowModalityNone = 0; + public static final int kWindowModalitySystemModal = 1; + public static final int kWindowModalityWindowModal = 3; + public static final int kWindowNoShadowAttribute = (1 << 21); + public static final int kWindowResizableAttribute = (1 << 4); + public static final int kWindowStandardHandlerAttribute = (1 << 25); + public static final int kWindowStructureRgn = 32; + public static final int mouseDown = 1; + public static final int noErr = 0; + public static final int normal = 0; + public static final int optionKey = 1 << 11; + public static final int shiftKey = 1 << 9; + public static final int smSystemScript = -1; + public static final int srcCopy = 0; + public static final int srcOr = 1; + public static final int typeCGContextRef= ('c'<<24) + ('n'<<16) + ('t'<<8) + 'x'; + public static final int typeChar = ('T'<<24) + ('E'<<16) + ('X'<<8) + 'T'; + public static final int typeControlPartCode = ('c'<<24) + ('p'<<16) + ('r'<<8) + 't'; + public static final int typeControlRef = ('c'<<24) + ('t'<<16) + ('r'<<8) + 'l'; + public static final int typeFileURL= ('f'<<24) + ('u'<<16) + ('r'<<8) + 'l'; + public static final int typeFSRef = ('f'<<24) + ('s'<<16) + ('r'<<8) + 'f'; + public static final int typeHICommand = ('h'<<24) + ('c'<<16) + ('m'<<8) + 'd'; + public static final int typeHIPoint = ('h'<<24) + ('i'<<16) + ('p'<<8) + 't'; + public static final int typeMenuRef = ('m'<<24) + ('e'<<16) + ('n'<<8) + 'u'; + public static final int typeMouseButton = ('m'<<24) + ('b'<<16) + ('t'<<8) + 'n'; + public static final int typeQDPoint = ('Q'<<24) + ('D'<<16) + ('p'<<8) + 't'; + public static final int typeQDRectangle = ('q'<<24) + ('d'<<16) + ('r'<<8) + 't'; + public static final int typeQDRgnHandle = ('r'<<24) + ('g'<<16) + ('n'<<8) + 'h'; + public static final int typeRGBColor = ('c'<<24) + ('R'<<16) + ('G'<<8) + 'B'; + public static final int typeSInt16 = ('s'<<24) + ('h'<<16) + ('o'<<8) + 'r'; + public static final int typeSInt32 = ('l'<<24) + ('o'<<16) + ('n'<<8) + 'g'; + public static final int typeType = ('t'<<24) + ('y'<<16) + ('p'<<8) + 'e'; + public static final int typeUInt32 = ('m'<<24) + ('a'<<16) + ('g'<<8) + 'n'; + public static final int typeUnicodeText = ('u'<<24) + ('t'<<16) + ('x'<<8) + 't'; + public static final int typeWindowDefPartCode = ('w'<<24) + ('d'<<16) + ('p'<<8) + 't'; + public static final int typeWindowRef = ('w'<<24) + ('i'<<16) + ('n'<<8) + 'd'; + public static final int updateEvt = 6; + public static final int updateMask = 1 << updateEvt; + public static final int userCanceledErr = -128; + +/** Natives */ +public static final native int kHIViewWindowContentID(); +public static final native int ActiveNonFloatingWindow(); +public static final native int AECountItems(AEDesc theAEDescList, int[] theCount); +public static final native int AEGetNthPtr(AEDesc theAEDescList, int index, int desiredType, int[] theAEKeyword, int[] typeCode, int dataPtr, int maximumSize, int[] actualSize); +public static final native int AEProcessAppleEvent(EventRecord theEventRecord); +public static final native int ATSUCreateStyle(int[] oStyle); +public static final native int ATSUCreateTextLayout(int[] oTextLayout); +public static final native int ATSUDisposeStyle(int iStyle); +public static final native int ATSUDisposeTextLayout(int iTextLayout); +public static final native int ATSUDrawText(int iTextLayout, int iLineOffset, int iLineLength, int iLocationX, int iLocationY); +public static final native int ATSUGetGlyphBounds(int iTextLayout, int iTextBasePointX, int iTextBasePointY, int iBoundsCharStart, int iBoundsCharLength, short iTypeOfBounds, int iMaxNumberOfBounds, int oGlyphBounds, int[] oActualNumberOfBounds); +public static final native int ATSUSetAttributes(int iStyle, int iAttributeCount, int[] iTag, int[] iValueSize, int[] iValue); +public static final native int ATSUSetLayoutControls(int iTextLayout, int iAttributeCount, int[] iTag, int[] iValueSize, int[] iValue); +public static final native int ATSUSetRunStyle(int iTextLayout, int iStyle, int iRunStart, int iRunLength); +public static final native int ATSUSetTextPointerLocation(int iTextLayout, int iText, int iTextOffset, int iTextLength, int iTextTotalLength); +public static final native int AddDataBrowserItems(int cHandle, int containerID, int numItems, int[] itemIDs, int preSortProperty); +public static final native int AddDataBrowserListViewColumn(int browser, DataBrowserListViewColumnDesc columnDesc, int position); +public static final native int AppendMenuItemTextWithCFString(int mHandle, int sHandle, int attributes, int commandID, short[] outItemIndex); +public static final native int AutoSizeDataBrowserListViewColumns(int cHandle); +public static final native void BeginUpdate(int wHandle); +public static final native void BringToFront(int wHandle); +public static final native void CFRelease(int sHandle); +public static final native int CFStringCreateWithBytes(int alloc, byte[] bytes, int numBytes, int encoding, boolean isExternalRepresentation); +public static final native int CFStringCreateWithCharacters(int alloc, char[] chars, int numChars); +public static final native int CFStringGetBytes(int theString, CFRange range, int encoding, byte lossByte, boolean isExternalRepresentation, byte[] buffer, int maxBufLen, int[] usedBufLen); +public static final native void CFStringGetCharacters(int theString, CFRange range, char[] buffer); +public static final native int CFStringGetLength(int theString); +public static final native int CFStringGetSystemEncoding(); +public static final native int CFURLCopyFileSystemPath(int anURL, int pathStyle); +public static final native int CFURLCopyLastPathComponent(int url); +public static final native int CFURLCreateCopyAppendingPathComponent(int allocator, int url, int pathComponent, boolean isDirectory); +public static final native int CFURLCreateCopyDeletingLastPathComponent(int allocator, int url); +public static final native int CFURLCreateFromFSRef(int allocator, byte[] fsRef); +public static final native void CGContextScaleCTM(int inContext, float sx, float sy); +public static final native void CGContextTranslateCTM(int inContext, float tx, float ty); +public static final native int CGBitmapContextCreate(int data, int width, int height, int bitsPerComponent, int bytesPerRow, int colorspace, int alphaInfo); +public static final native int CGColorSpaceCreateDeviceRGB (); +public static final native void CGColorSpaceRelease (int cs); +public static final native void CGContextAddArc (int ctx, float x, float y, float radius, float startAngle, float endAngle, boolean clockwise); +public static final native void CGContextAddArcToPoint (int ctx, float x1, float y1, float x2, float y2, float radius); +public static final native void CGContextAddLineToPoint (int ctx, float x, float y); +public static final native void CGContextAddLines (int ctx, float[] points, int count); +public static final native void CGContextBeginPath (int ctx); +public static final native void CGContextClip (int ctx); +public static final native void CGContextClosePath (int ctx); +public static final native void CGContextDrawImage (int ctx, CGRect rect, int image); +public static final native void CGContextFillPath (int ctx); +public static final native void CGContextStrokeRect (int ctx, CGRect rect); +public static final native void CGContextFillRect (int ctx, CGRect rect); +public static final native void CGContextFlush (int ctx); +public static final native void CGContextGetTextPosition (int ctx, CGPoint point); +public static final native void CGContextMoveToPoint (int ctx, float x, float y); +public static final native void CGContextRelease(int ctx); +public static final native void CGContextRestoreGState(int ctx); +public static final native void CGContextSaveGState(int ctx); +public static final native void CGContextSelectFont (int ctx, byte[] name, float size, int textEncoding); +public static final native void CGContextSetFillColorSpace (int ctx, int colorspace); +public static final native void CGContextSetFontSize (int ctx, float size); +public static final native void CGContextSetStrokeColorSpace (int ctx, int colorspace); +public static final native void CGContextSetFillColor (int ctx, float[] value); +public static final native void CGContextSetLineDash (int ctx, float phase, float[] lengths, int count); +public static final native void CGContextSetLineWidth (int ctx, float width); +public static final native void CGContextSetStrokeColor (int ctx, float[] value); +public static final native void CGContextSetRGBFillColor (int ctx, float r, float g, float b, float alpha); +public static final native void CGContextSetRGBStrokeColor (int ctx, float r, float g, float b, float alpha); +public static final native void CGContextSetTextDrawingMode (int ctx, int mode); +public static final native void CGContextSetTextPosition (int ctx, float x, float y); +public static final native void CGContextShowText (int ctx, byte[] cstring, int length); +public static final native void CGContextShowTextAtPoint (int ctx, float x, float y, byte[] cstring, int length); +public static final native void CGContextSetTextMatrix (int ctx, float[] transform); +public static final native void CGContextStrokePath (int ctx); +public static final native void CGContextSynchronize (int ctx); +public static final native int CGDataProviderCreateWithData (int info, int data, int size, int releaseData); +public static final native void CGDataProviderRelease (int provider); +public static final native int CGImageCreate (int width, int height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow, int colorspace, int alphaInfo, int provider, float[] decode, boolean shouldInterpolate, int intent); +public static final native int CGImageGetAlphaInfo (int image); +public static final native int CGImageGetBitsPerComponent (int image); +public static final native int CGImageGetBitsPerPixel (int image); +public static final native int CGImageGetBytesPerRow (int image); +public static final native int CGImageGetColorSpace (int image); +public static final native int CGImageGetHeight (int image); +public static final native int CGImageGetWidth (int image); +public static final native void CGImageRelease (int image); +public static final native int CallNextEventHandler(int nextHandler, int eventRefHandle); +public static final native short CharWidth(short c); +public static final native int ClearCurrentScrap(); +public static final native int ClearKeyboardFocus(int inWindow); +public static final native void ClearMenuBar(); +public static final native int ClipCGContextToRegion(int inContext, Rect portRect, int rgnHandle); +public static final native int CloseDataBrowserContainer(int cHandle, int container); +public static final native void ClosePoly(); +public static final native int CollapseWindow(int wHandle, boolean collapse); +public static final native boolean ConvertEventRefToEventRecord(int inEvent, EventRecord outEvent); +public static final native void CopyBits(int srcPixMapHandle, int dstPixMapHandle, Rect srcRect, Rect dstRect, short mode, int maskRgn); +public static final native int CopyControlTitleAsCFString(int cHandle, int[] sHandle); +public static final native void CopyDeepMask(int srcPixMapHandle, int maskPixMapHandle, int dstPixMapHandle, Rect srcRect, Rect maskRect, Rect dstRect, short mode, int maskRgn); +public static final native int CopyMenuItemTextAsCFString(int mHandle, short index, int[] sHandle); +public static final native void CopyRgn(int srcRgnHandle, int dstRgnHandle); +public static final native short CountMenuItems(int mHandle); +public static final native int CountSubControls(int cHandle, short[] count); +public static final native int CreateBevelButtonControl(int window, Rect boundsRect, int title, short thickness, short behavior, int info, short menuID, short menuBehavior, short menuPlacement, int[] outControl); +public static final native int CreateCheckBoxControl(int window, Rect boundsRect, int title, int initialValue, boolean autoToggle, int[] outControl); +public static final native int CreateCGContextForPort(int inPort, int[] outContext); +public static final native int CreateDataBrowserControl(int window, Rect boundsRect, int style,int[] outControl); +public static final native int CreateEvent(int allocator, int inClassID, int kind, double when, int flags, int[] outEventRef); +public static final native int CreateGroupBoxControl(int window, Rect boundsRect, int title, boolean primary, int[] outControl); +public static final native int CreateIconControl(int window, Rect boundsRect, ControlButtonContentInfo icon, boolean dontTrack, int[] outControl); +public static final native int CreateNewMenu(short menuID, int menuAttributes, int[] outMenuRef); +public static final native int CreateNewWindow(int windowClass, int attributes, Rect bounds, int[] wHandle); +public static final native int CreatePopupArrowControl(int window, Rect boundsRect, short orientation, short size, int[] outControl); +public static final native int CreatePopupButtonControl(int window, Rect boundsRect, int title, short menuID, boolean variableWidth, short titleWidth, short titleJustification, int titleStyle, int[] outControl); +public static final native int CreateProgressBarControl(int window, Rect boundsRect, int value, int minimim, int maximum, boolean indeterminate, int [] outControl); +public static final native int CreatePushButtonControl(int window, Rect boundsRect, int title, int[] outControl); +public static final native int CreatePushButtonWithIconControl(int window, Rect boundsRect, int title, ControlButtonContentInfo icon, short iconAlignment, int[] outControl); +public static final native int CreateRadioButtonControl(int window, Rect boundsRect, int title, int initialValue, boolean autoToggle, int[] outControl); +public static final native int CreateRootControl(int windowHandle, int[] cHandle); +public static final native int CreateSliderControl(int window, Rect boundsRect, int value, int minimum, int maximum, int orientation, short numTickMarks, boolean liveTracking, int liveTrackingProc, int [] outControl); +public static final native int CreateScrollBarControl(int window, Rect boundsRect, int value, int minimum, int maximum, int viewSize, boolean liveTracking, int liveTrackingProc, int [] outControl); +public static final native int CreateSeparatorControl(int window, Rect boundsRect, int [] outControl); +public static final native int CreateStandardAlert(short alertType, int errorSHandle, int explanationSHandle, AlertStdCFStringAlertParamRec alertParamHandle, int[] dialogHandle); +public static final native int CreateStaticTextControl(int window, Rect boundsRect, int text, ControlFontStyleRec style, int [] outControl); +public static final native int CreateTabsControl(int window, Rect boundsRect, short size, short direction, short numTabs, int tabArray, int[] outControl); +public static final native int CreateEditUnicodeTextControl(int window, Rect boundsRect, int text, boolean isPassword, ControlFontStyleRec style, int [] outControl); +public static final native int CreateUserPaneControl(int window, Rect boundsRect, int features, int [] outControl); +public static final native int CreateWindowGroup (int inAttributes, int [] outGroup); +public static final native void DeleteMenu(short menuID); +public static final native void DeleteMenuItem(int mHandle, short index); +public static final native int DeleteMenuItems(int mHandle, short firstItem, int numItems); +public static final native void DiffRgn(int srcRgnA, int srcRgnB, int dstRgn); +public static final native int DisableControl(int cHandle); +public static final native void DisableMenuCommand(int mHandle, int commandId); +public static final native void DisableMenuItem(int mHandle, short index); +public static final native void DisposeControl(int cHandle); +public static final native void DisposeGWorld(int offscreenGWorld); +public static final native void DisposeHandle(int handle); +public static final native void DisposeMenu(int mHandle); +public static final native void DisposePtr(int ptr); +public static final native void DisposeRgn(int rgnHandle); +public static final native void DisposeWindow(int wHandle); +public static final native void DrawMenuBar(); +public static final native void DrawText(byte[] textBuf, short firstByte, short byteCount); +public static final native int DrawThemeButton(Rect inBounds, short inKind, ThemeButtonDrawInfo inNewInfo, ThemeButtonDrawInfo inPrevInfo, int inEraseProc, int inLabelProc, int inUserData); +public static final native int DrawThemeEditTextFrame(Rect bounds, int state); +public static final native int DrawThemeFocusRect(Rect bounds, boolean hasFocus); +public static final native int DrawThemeSeparator(Rect bounds, int state); +public static final native int DrawThemeTextBox(int sHandle, short fontID, int state, boolean wrapToWidth, Rect bounds, short just, int context); +public static final native int EmbedControl(int inControl, int inContainer); +public static final native boolean EmptyRect(Rect r); +public static final native boolean EmptyRgn(int rgnHandle); +public static final native int EnableControl(int cHandle); +public static final native void EnableMenuCommand(int mHandle, int commandId); +public static final native void EnableMenuItem(int mHandle, short index); +public static final native void EndUpdate(int wHandle); +public static final native boolean EqualRect(Rect rect1, Rect rect2); +public static final native void EraseRect(Rect bounds); +public static final native void EraseRgn(int rgnHandle); +public static final native int FetchFontInfo(short fontID, short fontSize, short fontStyle, FontInfo info); +public static final native int Fix2Long(int x); +public static final native int FMCreateFontFamilyInstanceIterator(short iFontFamily, int ioIterator); +public static final native int FMCreateFontFamilyIterator(int iFilter, int iRefCon, int iOptions, int ioIterator); +public static final native int FMDisposeFontFamilyIterator(int ioIterator); +public static final native int FMDisposeFontFamilyInstanceIterator(int ioIterator); +public static final native int FMGetFontFamilyName(short id, byte[] name); +public static final native short FMGetFontFamilyFromName(byte[] name); +public static final native int FMGetFontFromFontFamilyInstance(short iFontFamily, short iStyle, int[] oFont, short[] oIntrinsicStyle); +public static final native int FMGetNextFontFamily(int ioIterator, short[] oFontFamily); +public static final native int FMGetNextFontFamilyInstance(int ioIterator, int[] oFont, short[] oStyle, short[] oSize); +public static final native boolean FPIsFontPanelVisible(); +public static final native int FPShowHideFontPanel(); +public static final native short FindWindow(Point where, int[] wHandle); +public static final native void FrameOval(Rect bounds); +public static final native void FramePoly(int polyHandle); +public static final native void FrameRect(Rect bounds); +public static final native void FrameRoundRect(Rect bounds, short ovalWidth, short ovalHeight); +public static final native int FrontWindow(); +public static final native short GetAppFont(); +public static final native int GetApplicationEventTarget(); +public static final native int GetAvailableWindowAttributes(int windowClass); +public static final native int GetAvailableWindowPositioningBounds(int inDevice, Rect outAvailableRect); +public static final native int GetBestControlRect(int inControl, Rect outRect, short[] outBaseLineOffset); +public static final native int GetCaretTime(); +public static final native void GetClip(int rgnHandle); +public static final native int GetControl32BitMaximum(int cHandle); +public static final native int GetControl32BitMinimum(int cHandle); +public static final native int GetControl32BitValue(int cHandle); +public static final native void GetControlBounds(int cHandle, Rect bounds); +public static final native int GetControlData(int inControl, short inPart, int inTagName, int inBufferSize, Rect inBuffer, int[] outActualSize); +public static final native int GetControlData(int inControl, short inPart, int inTagName, int inBufferSize, int[] inBuffer, int[] outActualSize); +public static final native int GetControlData(int inControl, short inPart, int inTagName, int inBufferSize, short[] inBuffer, int[] outActualSize); +public static final native int GetControlData(int inControl, short inPart, int inTagName, int inBufferSize, byte[] inBuffer, int[] outActualSize); +public static final native int GetControlEventTarget(int cHandle); +public static final native int GetControlFeatures(int inControl, int[] outFeatures); +public static final native int GetControlOwner(int cHandle); +public static final native int GetControlProperty(int control, int propertyCreator, int propertyTag, int bufferSize, int[] actualSize, int[] propertyBuffer); +public static final native int GetControlReference(int cHandle); +public static final native int GetControlRegion(int cHandle, short inPart, int rgnHandle); +public static final native short GetControlValue(int cHandle); +public static final native int GetControlViewSize(int cHandle); +public static final native int GetCurrentEventButtonState(); +public static final native int GetCurrentEventLoop(); +public static final native int GetCurrentEventKeyModifiers(); +public static final native int GetCurrentEventQueue(); +public static final native int GetCurrentProcess(int[] psn); +public static final native int GetCurrentScrap(int[] scrap); +public static final native int GetDataBrowserCallbacks(int browser, DataBrowserCallbacks callbacks); +public static final native int GetDataBrowserItemCount(int cHandle, int container, boolean recurse, int state, int[] numItems); +public static final native int GetDataBrowserItemDataButtonValue(int itemData, short [] theData); +public static final native int GetDataBrowserItemPartBounds(int cHandle, int item, int property, int part, Rect bounds); +public static final native int GetDataBrowserItems(int browser, int container, boolean recurse, int state, int items); +public static final native int GetDataBrowserItemState(int browser, int item, int [] state); +public static final native int GetDataBrowserListViewHeaderBtnHeight(int browser, short [] height); +public static final native int GetDataBrowserListViewHeaderDesc(int browser, int column, DataBrowserListViewHeaderDesc desc); +public static final native int GetDataBrowserTableViewItemID(int browser, int row, int [] item); +public static final native int GetDataBrowserTableViewItemRow(int browser, int item, int [] row); +public static final native int GetDataBrowserTableViewColumnPosition(int browser, int column, int [] position); +public static final native int GetDataBrowserTableViewNamedColumnWidth(int browser, int column, short [] width); +public static final native int GetDataBrowserTableViewRowHeight(int browser, short [] height); +public static final native int GetDataBrowserScrollBarInset(int browser, Rect insetRect); +public static final native int GetDataBrowserScrollPosition(int cHandle, int[] top, int[] left); +public static final native int GetDataBrowserSelectionAnchor(int browser, int [] first, int [] last); +public static final native int GetDblTime(); +public static final native short GetDefFontSize(); +public static final native int GetEventClass(int eHandle); +public static final native int GetEventDispatcherTarget(); +public static final native int GetEventKind(int eHandle); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, int[] outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, char[] outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, short[] outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, byte[] outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, HICommand outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, Point outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, CGPoint outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, RGBColor outData); +public static final native int GetEventParameter(int inEvent, int inName, int inDesiredType, int[] outActualType, int inBufferSize, int[] outActualSize, Rect outData); +public static final native double GetEventTime(int eHandle); +public static final native void GetFontInfo(short[] info); +public static final native int GetGDevice(); +public static final native void GetGWorld(int[] portHandle, int[] gdHandle); +public static final native void GetGlobalMouse(Point where); +public static final native int GetHandleSize(int handle); +public static final native int GetIconRef(short vRefNum, int creator, int iconType, int[] theIconRef); +public static final native int GetIndMenuItemWithCommandID(int mHandle, int commandId, int index, int[] outMenu, short[] outIndex); +public static final native int GetIndexedSubControl(int cHandle, short index, int[] outHandle); +public static final native int GetKeyboardFocus(int wHandle, int[] cHandle); +public static final native double GetLastUserEventTime(); +public static final native int GetMainDevice(); +public static final native int GetMainEventQueue(); +public static final native int GetMenuCommandMark(int theMenu, int commandId, char[] outMark); +public static final native int GetMenuEventTarget(int cHandle); +public static final native int GetMenuFont(int inMenu, short[] outFontID, short[] outFontSize); +public static final native short GetMenuID(int menu); +public static final native int GetMenuItemCommandID(int inMenu, short inItem, int[] outCommandID); +public static final native int GetMenuItemHierarchicalMenu(int inMenu, short inItem, int []outHierMenu); +public static final native int GetMenuItemRefCon(int inMenu, short intItem, int[] outRefCon); +public static final native int GetMenuTrackingData(int menu, MenuTrackingData outData); +public static final native void GetMouse(Point where); +public static final native void GetPixBounds(int pHandle, Rect bounds); +public static final native short GetPixDepth(int pHandle); +public static final native void GetPort(int[] port); +public static final native int GetPortBitMapForCopyBits(int portHandle); +public static final native void GetPortBounds(int pHandle, Rect rect); +public static final native void GetPortClipRegion(int port, int clipRgn); +public static final native int GetPortVisibleRegion(int portHandle, int rgnHandle); +public static final native int GetPtrSize(int ptr); +public static final native void GetRegionBounds(int rgnHandle, Rect bounds); +public static final native int GetRootControl(int windowHandle, int[] cHandle); +public static final native int GetScrapFlavorCount(int scrap, int[] infoCount); +public static final native int GetScrapFlavorData(int scrap, int flavorType, int[] byteCount, byte[] destination); +public static final native int GetScrapFlavorInfoList(int scrap, int[] infoCount, int[] info); +public static final native int GetScrapFlavorSize(int scrap, int flavorType, int[] byteCount); +public static final native int GetSuperControl(int cHandle, int[] parentHandle); +public static final native int GetThemeBrushAsColor(short inBrush, short inDepth, boolean inColorDev, RGBColor outColor); +public static final native int GetThemeDrawingState(int[] state); +public static final native int GetThemeFont(short themeFontId, short scriptCode, byte[] fontName, short[] fontSize, byte[] style); +public static final native int GetThemeMetric(int inMetric, int [] outMetric); +public static final native int GetThemeTextColor(short inColor, short inDepth, boolean inColorDev, RGBColor outColor); +public static final native int GetThemeTextDimensions(int sHandle, short fontID, int state, boolean wrapToWidth, Point ioBounds, short[] baseLine); +public static final native int GetUserFocusEventTarget(); +public static final native int GetWRefCon(int wHandle); +public static final native void GetWindowBounds(int wHandle, short windowRegion, Rect bounds); +public static final native int GetWindowDefaultButton(int wHandle, int[] cHandle); +public static final native int GetWindowEventTarget(int wHandle); +public static final native int GetWindowFromPort(int pHandle); +public static final native int GetWindowGroupOfClass (int windowClass); +public static final native int GetWindowModality(int inWindow, int[] outModalKind, int[] outUnavailableWindow); +public static final native int GetWindowPort(int wHandle); +public static final native void GetWindowStructureWidths(int intWindow, Rect outRect); +public static final native int HandleControlSetCursor(int control, Point localPoint, int modifiers, boolean[] cursorWasSet); +public static final native int HIComboBoxAppendTextItem(int inComboBox, int inText, int[] outIndex); +public static final native int HIComboBoxCopyTextItemAtIndex(int inComboBox, int inIndex, int[] outString); +public static final native int HIComboBoxCreate(CGRect boundsRect, int text, ControlFontStyleRec style, int list, int inAttributes, int[] outComboBox); +public static final native int HIComboBoxGetItemCount(int inComboBox); +public static final native int HIComboBoxInsertTextItemAtIndex(int inComboBox, int inIndex, int inText); +public static final native int HIComboBoxRemoveItemAtIndex(int inComboBox, int inIndex); +public static final native int HIObjectCopyClassID(int inObject); +public static final native int HIObjectCreate(int inClassID, int inConstructData, int[] outObject); +public static final native int HIObjectRegisterSubclass(int inClassID, int inBaseClassID, int inOptions, int inConstructProc, int inNumEvents, int[] inEventList, int inConstructData, int[] outClassRef); +public static final native int HIViewAddSubview(int parent, int child); +public static final native int HIViewClick(int inView, int inEvent); +public static final native int HIViewConvertPoint(CGPoint ioPoint, int inSourceView, int inDestView); +public static final native int HIViewFindByID(int inStartView, int inID, int[] outControl); +public static final native int HIViewGetFirstSubview(int inView); +public static final native int HIViewGetLastSubview(int inView); +public static final native int HIViewGetNextView(int inView); +public static final native int HIViewGetFrame(int inView, CGRect outRect); +public static final native int HIViewGetRoot(int wHandle); +public static final native int HIViewGetSizeConstraints(int inView, CGRect outMinSize, CGRect outMaxSize); +public static final native int HIViewGetSubviewHit(int inView, CGPoint inPoint, boolean inDeep, int[] outView); +public static final native int HIViewGetViewForMouseEvent(int inView, int inEvent, int[] outView); +public static final native boolean HIViewIsVisible(int inView); +public static final native int HIViewRemoveFromSuperview(int inView); +public static final native int HIViewSetDrawingEnabled(int inView, boolean isEnabled); +public static final native int HIViewSetFrame(int inView, CGRect inRect); +public static final native int HIViewSetNeedsDisplay(int inView, boolean inNeedsDisplay); +public static final native int HIViewSetNeedsDisplayInRegion(int inView, int inRgn, boolean inNeedsDisplay); +public static final native int HIViewSetVisible(int inView, boolean inVisible); +public static final native int HIViewSetZOrder(int inView, int inOp, int inOther); +public static final native int HIViewSimulateClick(int inView, short inPartToClick, int modifiers, short[] outPartClicked); +public static final native short HandleControlClick(int cHandle, Point where, int modifiers, int actionUPP); +public static final native short HiWord(int doubleWord); +public static final native void HideWindow(int wHandle); +public static final native void HiliteMenu(short menuID); +public static final native void HLock(int h); +public static final native int HMGetTagDelay (int [] outDelay); +public static final native int HMHideTag (); +public static final native int HMSetTagDelay (int inDelay); +public static final native void HMInstallControlContentCallback(int inControl, int inContentUPP); +public static final native void HUnlock(int h); +public static final native int InitContextualMenus(); +public static final native void InitCursor(); +public static final native int InitDataBrowserCallbacks(DataBrowserCallbacks callbacks); +public static final native int InitDataBrowserCustomCallbacks(DataBrowserCustomCallbacks callbacks); +public static final native void InsertMenu(int mHandle, short beforeID); +public static final native int InsertMenuItemTextWithCFString(int mHandle, int sHandle, short index, int attributes, int commandID); +public static final native int InstallEventHandler(int inTarget, int inHandler, int inNumTypes, int[] inList, int inUserData, int[] outRef); +public static final native int InstallEventLoopTimer(int inEventLoop, double inFireDelay, double inInterval, int inTimerProc, int inTimerData, int[] outTimer); +public static final native void InvalWindowRect(int wHandle, Rect bounds); +public static final native void InvalWindowRgn(int wHandle, int rgnHandle); +public static final native void InvertRect(Rect r); +public static final native void InvertRgn(int rgnHandle); +public static final native boolean IsControlActive(int inControl); +public static final native boolean IsControlEnabled(int cHandle); +public static final native boolean IsControlVisible(int cHandle); +public static final native boolean IsDataBrowserItemSelected(int cHandle, int itemID); +public static final native boolean IsMenuCommandEnabled(int mHandle, int commandId); +public static final native boolean IsMenuItemEnabled(int mHandle, short index); +public static final native boolean IsValidControlHandle(int cHandle); +public static final native boolean IsValidMenu(int mHandle); +public static final native boolean IsValidWindowPtr(int grafPort); +public static final native boolean IsWindowActive(int window); +public static final native boolean IsWindowCollapsed(int window); +public static final native boolean IsWindowVisible(int window); +public static final native void KillPoly(int polyHandle); +public static final native void LineTo(short h, short v); +public static final native short LoWord(int doubleWord); +public static final native int LockPortBits(int portHandle); +public static final native int MenuSelect(Point mHandle); +public static final native void MoveControl(int theControl, short h, short v); +public static final native void MoveTo(short h, short v); +public static final native void MoveWindow(int wHandle, short h, short v, boolean toFront); +public static final native int NavCreateChooseFolderDialog(NavDialogCreationOptions inOptions, int inEventProc, int inFilterProc, int inClientData, int[] outDialog); +public static final native int NavCreateGetFileDialog(NavDialogCreationOptions inOptions, int inTypeList, int inEventProc, int inPreviewProc, int inFilterProc, int inClientData, int[] outDialog); +public static final native int NavCreatePutFileDialog(NavDialogCreationOptions inOptions, int inFileType, int inFileCreator, int inEventProc, int inClientData, int[] outDialog); +public static final native void NavDialogDispose(int dialogHandle); +public static final native int NavDialogGetSaveFileName(int dialogHandle); +public static final native int NavDialogGetUserAction(int dialogHandle); +public static final native int NavDialogRun(int dialogHandle); +public static final native int NavDialogSetSaveFileName(int dialogHandle, int fileNameHandle); +public static final native int NavGetDefaultDialogCreationOptions(NavDialogCreationOptions outOptions); +public static final native int NavDialogGetReply(int inDialog, NavReplyRecord outReply); +public static final native int NewControl(int owningWindow, Rect boundsRect, byte[] controlTitle, boolean initiallyVisible, short initialValue, short minimumValue, short maximumValue, short procID, int controlReference); +public static final native int NewGWorldFromPtr(int[] offscreenGWorld, int PixelFormat, Rect boundsRect, int cTable, int aGDevice, int flags, int newBuffer, int rowBytes); +public static final native int NewHandle(int size); +public static final native int NewHandleClear(int size); +public static final native int NewPtr(int size); +public static final native int NewPtrClear(int size); +public static final native int NewRgn(); +public static final native void OffsetRect(Rect rect, short dh, short dv); +public static final native void OffsetRgn(int rgnHandle, short dh, short dv); +public static final native int OpenDataBrowserContainer(int cHandle, int container); +public static final native int OpenPoly(); +public static final native void PaintOval(Rect bounds); +public static final native void PaintPoly(int polyHandle); +public static final native void PaintRect(Rect bounds); +public static final native void PaintRoundRect(Rect bounds, short ovalWidth, short ovalHeight); +public static final native void PenSize(short h, short v); +public static final native int PickColor(ColorPickerInfo theColorInfo); +public static final native int PopUpMenuSelect(int mHandle, short top, short left, short popUpItem); +public static final native int PostEvent(short eventNum, int eventMsg); +public static final native int PostEventToQueue(int inQueue, int inEvent, short inPriority); +public static final native boolean PtInRect(Point pt, Rect r); +public static final native boolean PtInRgn(Point pt, int rgnHandle); +public static final native int PutScrapFlavor(int scrap, int flavorType, int flavorFlags, int flavorSize, byte[] flavorData); +public static final native int QDBeginCGContext(int inPort, int[] outContext); +public static final native int QDEndCGContext(int inPort, int[] inoutContext); +public static final native void QDFlushPortBuffer(int port, int rgnHandle); +public static final native void QDGlobalToLocalPoint(int port, Point point); +public static final native void QDLocalToGlobalPoint(int port, Point point); +public static final native void QDSetPatternOrigin(Point point); +public static final native int QDSwapTextFlags(int flags); +public static final native void RGBBackColor(RGBColor color); +public static final native void RGBForeColor(RGBColor color); +public static final native int ReceiveNextEvent(int inNumTypes, int[] inList, double inTimeout, boolean inPullEvent, int[] outEvent); +public static final native boolean RectInRgn(Rect rect, int rgnHandle); +public static final native void RectRgn(int rgnHandle, Rect left); +public static final native int RegisterAppearanceClient(); +public static final native void ReleaseEvent(int theEvent); +public static final native int ReleaseMenu(int mHandle); +public static final native int ReleaseWindowGroup (int inGroup); +public static final native int RemoveControlProperty(int control, int propertyCreator, int propertyTag); +public static final native int RemoveDataBrowserItems(int cHandle, int containerID, int numItems, int[] itemIDs, int preSortProperty); +public static final native int RemoveDataBrowserTableViewColumn(int browser, int column); +public static final native int RemoveEventHandler(int inHandlerRef); +public static final native int RemoveEventLoopTimer(int inTimer); +public static final native int RepositionWindow(int window, int parentWindow, int method); +public static final native int RetainMenu(int mHandle); +public static final native int RevealDataBrowserItem(int browser, int item, int property, byte options); +public static final native int RunStandardAlert(int dialogHandle, int modalFilterUPP, short[] itemHit); +public static final native void ScrollRect(Rect rect, short dh, short dv, int updateRgn); +public static final native boolean SectRect(Rect src1, Rect src2, Rect dstRect); +public static final native void SectRgn(int srcRgnA, int srcRgnB, int dstRgn); +public static final native void SelectWindow(int wHandle); +public static final native void SendBehind(int window, int behindWindow); +public static final native int SendEventToEventTarget(int theEvent, int theTarget); +public static final native int SetBevelButtonContentInfo(int inButton, ControlButtonContentInfo inContent); +public static final native void SetClip(int rgnHandle); +public static final native void SetControl32BitMaximum(int cHandle, int maximum); +public static final native void SetControl32BitMinimum(int cHandle, int minimum); +public static final native void SetControl32BitValue(int cHandle, int value); +public static final native void SetControlAction(int cHandle, int actionProc); +public static final native void SetControlBounds(int cHandle, Rect bounds); +public static final native int SetControlData(int inControl, int inPart, int inTagName, int inSize, ControlButtonContentInfo inData); +public static final native int SetControlData(int inControl, int inPart, int inTagName, int inSize, ControlTabInfoRecV1 inData); +public static final native int SetControlData(int inControl, int inPart, int inTagName, int inSize, Rect inData); +public static final native int SetControlData(int inControl, int inPart, int inTagName, int inSize, short[] inData); +public static final native int SetControlData(int inControl, int inPart, int inTagName, int inSize, int[] inData); +public static final native int SetControlData(int inControl, int inPart, int inTagName, int inSize, int inData); +public static final native int SetControlData(int inControl, int inPart, int inTagName, int inSize, byte[] inData); +public static final native int SetControlFontStyle(int inControl, ControlFontStyleRec inStyle); +public static final native void SetControlPopupMenuHandle(int cHandle, int popupMenuHandle); +public static final native int SetControlProperty(int control, int propertyCreator, int propertyTag, int propertySize, int[] propertyData); +public static final native void SetControlReference(int cHandle, int data); +public static final native int SetControlTitleWithCFString(int cHandle, int sHandle); +public static final native void SetControlViewSize(int cHandle, int viewSize); +public static final native void SetCursor(int cursor); +public static final native int SetDataBrowserCallbacks(int browser, DataBrowserCallbacks callbacks); +public static final native int SetDataBrowserCustomCallbacks(int browser, DataBrowserCustomCallbacks callbacks); +public static final native int SetDataBrowserHasScrollBars(int cHandle, boolean hScroll, boolean vScroll); +public static final native int SetDataBrowserItemDataBooleanValue(int itemRef, boolean data); +public static final native int SetDataBrowserItemDataButtonValue(int itemRef, short themeButtonValue); +public static final native int SetDataBrowserItemDataIcon(int itemRef, int iconRef); +public static final native int SetDataBrowserItemDataItemID(int itemRef, int itemID); +public static final native int SetDataBrowserItemDataText(int itemRef, int sHandle); +public static final native int SetDataBrowserListViewDisclosureColumn(int cHandle, int colID, boolean b); +public static final native int SetDataBrowserListViewHeaderBtnHeight(int cHandle, short height); +public static final native int SetDataBrowserListViewHeaderDesc(int browser, int column, DataBrowserListViewHeaderDesc desc); +public static final native int SetDataBrowserScrollPosition(int cHandle, int top, int left); +public static final native int SetDataBrowserSelectedItems(int cHandle, int numItems, int[] items, int operation); +public static final native int SetDataBrowserSelectionFlags(int cHandle, int selectionFlags); +public static final native int SetDataBrowserTableViewColumnPosition(int browser, int column, int position); +public static final native int SetDataBrowserTableViewHiliteStyle(int browser, int hiliteStyle); +public static final native int SetDataBrowserTableViewItemRow(int browser, int item, int row); +public static final native int SetDataBrowserTableViewNamedColumnWidth(int browser, int column, short width); +public static final native int SetDataBrowserTarget(int cHandle, int rootID); +public static final native int SetEventLoopTimerNextFireTime(int inTimer, double inNextFire); +public static final native int SetEventParameter(int inEvent, int inName, int inType, int inSize, char[] inDataPtr); +public static final native int SetFontInfoForSelection(int iStyleType, int iNumStyles, int iStyles, int iFPEventTarget); +public static final native int SetFrontProcess(int[] psn); +public static final native void SetGWorld(int portHandle, int gdHandle); +public static final native int SetKeyboardFocus(int wHandle, int cHandle, short inPart); +public static final native int SetMenuCommandMark(int mHandle, int commandId, char mark); +public static final native int SetMenuFont(int mHandle, short fontID, short size); +public static final native int SetMenuItemCommandKey(int mHandle, short index, boolean virtualKey, char key); +public static final native int SetMenuItemHierarchicalMenu(int mHandle, short index, int hierMenuHandle); +public static final native int SetMenuItemIconHandle(int mHandle, short item, byte iconType, int iconHandle); +public static final native int SetMenuItemKeyGlyph(int mHandle, short index, short glyph); +public static final native int SetMenuItemModifiers(int mHandle, short index, byte modifiers); +public static final native int SetMenuItemRefCon(int mHandle, short index, int refCon); +public static final native int SetMenuItemTextWithCFString(int mHandle, short index, int sHandle); +public static final native int SetMenuTitleWithCFString(int mHandle, int sHandle); +public static final native void SetOrigin(short h, short v); +public static final native void SetPort(int pHandle); +public static final native void SetPortBounds(int port, Rect rect); +public static final native void SetPortWindowPort(int wHandle); +public static final native void SetPt(Point p, short h, short v); +public static final native void SetRect(Rect r, short left, short top, short right, short bottom); +public static final native void SetRectRgn(int rgnHandle, short left, short top, short right, short bottom); +public static final native int SetRootMenu(int mHandle); +public static final native int SetThemeBackground(short inBrush, short depth, boolean isColorDevice); +public static final native int SetThemeCursor(int themeCursor); +public static final native int SetThemeDrawingState(int state, boolean disposeNow); +public static final native int SetThemeWindowBackground(int wHandle, short brush, boolean update); +public static final native int SetUpControlBackground(int cHandle, short depth, boolean isColorDevice); +public static final native void SetWRefCon(int wHandle, int data); +public static final native int SetWindowActivationScope(int wHandle, int scope); +public static final native void SetWindowBounds(int window, int regionCode, Rect globalBounds); +public static final native int SetWindowDefaultButton(int wHandle, int cHandle); +public static final native int SetWindowGroup(int inWindow, int inNewGroup); +public static final native int SetWindowGroupOwner(int inGroup, int inWindow); +public static final native int SetWindowGroupParent(int inGroup, int inNewGroup); +public static final native int SetWindowModality(int inWindow, int inModalKind, int inUnavailableWindow); +public static final native int SetWindowTitleWithCFString(int wHandle, int sHandle); +public static final native void ShowWindow(int wHandle); +public static final native void SizeControl(int cHandle, short w, short h); +public static final native void SizeWindow(int wHandle, short w, short h, boolean update); +public static final native boolean StillDown(); +public static final native int SyncCGContextOriginWithPort(int inContext, int port); +public static final native void SysBeep(short duration); +public static final native int TXNActivate(int txHandle, int frameID, boolean scrollBarState); +public static final native int TXNAdjustCursor (int iTXNObject, int ioCursorRgn); +public static final native void TXNClick(int iTXNObject, EventRecord iEvent); +public static final native int TXNCopy(int txHandle); +public static final native int TXNCut(int txHandle); +public static final native int TXNDataSize(int txHandle); +public static final native void TXNDeleteObject(int txHandle); +public static final native void TXNDraw(int txHandle, int gDevice); +public static final native int TXNEchoMode(int txHandle, char echoCharacter, int encoding, boolean on); +public static final native void TXNFocus(int txHandle, boolean becomingFocused); +public static final native int TXNGetData(int txHandle, int startOffset, int endOffset, int[] dataHandle); +public static final native int TXNGetLineCount(int txHandle, int[] lineTotal); +public static final native int TXNGetLineMetrics(int iTXNObject, int iLineNumber, int [] oLineWidth, int [] oLineHeight); +public static final native int TXNGetTXNObjectControls(int iTXNObject, int iControlCount, int [] iControlTags, int [] oControlData); +public static final native int TXNGetRectBounds(int iTXNObject, Rect oViewRect, TXNLongRect oDestinationRect, TXNLongRect oTextRect); +public static final native void TXNGetSelection(int txHandle, int[] startOffset, int[] endOffset); +public static final native void TXNGetViewRect (int iTXNObject, Rect oViewRect); +public static final native int TXNInitTextension(int iDefaultFonts, int iCountDefaultFonts, int iUsageFlags); +public static final native int TXNNewObject(int iFileSpec, int iWindw, Rect iFrame, int iFrameOptions, int iFrameType, int iFileType, int iPermanentEncoding, int [] oTXNObject, int[] oTXNFrameID, int iRefCpm); +public static final native int TXNOffsetToPoint(int txHandle, int offset, Point point); +public static final native int TXNPaste(int txHandle); +public static final native int TXNPointToOffset (int iTXNObject, Point iPoint, int [] oOffset); +public static final native void TXNSelectAll(int txHandle); +public static final native void TXNSetRectBounds(int iTXNObject, Rect iViewRect, TXNLongRect iDestinationRect, boolean iUpdate); +public static final native int TXNSetData(int iTXNObject, int iDataType, char[] iDataPtr, int iDataSize, int iStartOffset, int iEndOffset); +public static final native void TXNSetFrameBounds(int txHandle, int top, int left, int bottom, int right, int frameID); +public static final native int TXNSetSelection(int txHandle, int startOffset, int endOffset); +public static final native int TXNSetTXNObjectControls(int iTXNObject, boolean iClearAll, int iControlCount, int[] iControlTags, int[] iControlData); +public static final native void TXNShowSelection(int txHandle, boolean showEnd); +public static final native short TestControl(int control, Point point); +public static final native void TextFace(short face); +public static final native void TextFont(short fontID); +public static final native void TextMode(short mode); +public static final native void TextSize(short size); +public static final native short TextWidth(byte[] textBuf, short firstByte, short byteCount); +public static final native int TrackMouseLocationWithOptions(int inPort, int inOptions, double inTime, Point outPt, int [] outModifiers, short[] outResult); +public static final native void UnionRect(Rect srcA, Rect srcB, Rect dst); +public static final native void UnionRgn(int srcRgnA, int srcRgnB, int dstRgn); +public static final native int UnlockPortBits(int portHandle); +public static final native void UpdateControls(int wHandle, int rgnHandle); +public static final native int UpdateDataBrowserItems(int cHandle, int container, int numItems, int[] items, int preSortProperty, int propertyID); +public static final native int ZoomWindowIdeal(int inWindow, short inPartCode, Point ioIdealSize); +public static final native void memcpy(ATSTrapezoid dest, int src, int n); +public static final native void memcpy(byte[] dest, int src, int n); +public static final native void memcpy(char[] dest, int src, int n); +public static final native void memcpy(int[] dest, int src, int n); +public static final native void memcpy(int dest, int[] src, int n); +public static final native void memcpy(int dest, PixMap src, int n); +public static final native void memcpy(int dest, Cursor src, int n); +public static final native void memcpy(GDevice dest, int src, int n); +public static final native void memcpy(PixMap dest, int src, int n); +public static final native void memcpy(FontSelectionQDStyle dest, int src, int n); +public static final native void memcpy(HMHelpContentRec dest, int src, int n); +public static final native void memcpy(int dest, HMHelpContentRec src, int n); +public static final native void memcpy(int dest, BitMap src, int n); +public static final native void memcpy(int dest, char[] src, int n); +public static final native void memcpy(int dest, int src, int n); +public static final native void memcpy(int dest, byte[] src, int n); +public static final native void memcpy(int dest, FontSelectionQDStyle src, int n); +public static final native void memcpy(Rect dest, int src, int n); +public static final native void memcpy(int dest, Rect src, int n); +public static final native void memset(int dest, int value, int size); + +public static final native int HIViewSetBoundsOrigin(int inView, float inX, float inY); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/PixMap.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/PixMap.java new file mode 100644 index 0000000000..0fa142f86c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/PixMap.java @@ -0,0 +1,24 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class PixMap extends BitMap { + public short pmVersion; + public short packType; + public int packSize; + public int hRes; + public int vRes; + public short pixelType; + public short pixelSize; + public short cmpCount; + public short cmpSize; + public int pixelFormat; + public int pmTable; + public int pmExt; + public static final int sizeof = 50; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Point.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Point.java new file mode 100644 index 0000000000..9c8d4a40eb --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Point.java @@ -0,0 +1,14 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class Point { + public short v; + public short h; + public static final int sizeof = 4; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/RGBColor.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/RGBColor.java new file mode 100644 index 0000000000..ca209234da --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/RGBColor.java @@ -0,0 +1,15 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class RGBColor { + public short red; + public short green; + public short blue; + public static final int sizeof = 6; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Rect.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Rect.java new file mode 100644 index 0000000000..f5fe5ad2f6 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/Rect.java @@ -0,0 +1,16 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class Rect { + public short top; + public short left; + public short bottom; + public short right; + public static final int sizeof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/TXNLongRect.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/TXNLongRect.java new file mode 100644 index 0000000000..34de625010 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/TXNLongRect.java @@ -0,0 +1,16 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class TXNLongRect { + public int top; + public int left; + public int bottom; + public int right; + public static final int sizeof = 16; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ThemeButtonDrawInfo.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ThemeButtonDrawInfo.java new file mode 100644 index 0000000000..89fd3f6ca2 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/ThemeButtonDrawInfo.java @@ -0,0 +1,15 @@ +package org.eclipse.swt.internal.carbon; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +public class ThemeButtonDrawInfo { + public int state; + public short value; + public short adornment; + public static final int sizof = 8; +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Color.java index 9c7d65633b..eb319268e1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Color.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Color.java @@ -7,6 +7,7 @@ package org.eclipse.swt.graphics; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.*; /** @@ -23,26 +24,20 @@ import org.eclipse.swt.*; * @see RGB */ public final class Color { - /** * the handle to the OS color resource * (Warning: This field is platform dependent) */ - public int handle; + public float[] handle; /** * The device where this color was created. */ Device device; - - // AW - private static final int DISPOSED = 0x01; - private static final int SYSTEM = 0x02; - private int fFlags; - // AW - + Color() { } + /** * Constructs a new instance of this class given a device and the * desired red, green and blue values expressed as ints in the range @@ -67,9 +62,10 @@ Color() { * * @see #dispose */ -public Color (Device device, int red, int green, int blue) { +public Color(Device device, int red, int green, int blue) { init(device, red, green, blue); } + /** * Constructs a new instance of this class given a device and an * <code>RGB</code> describing the desired red, green and blue values. @@ -92,24 +88,23 @@ public Color (Device device, int red, int green, int blue) { * * @see #dispose */ -public Color (Device device, RGB rgb) { +public Color(Device device, RGB rgb) { if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); init(device, rgb.red, rgb.green, rgb.blue); } + /** * Disposes of the operating system resources associated with * the color. Applications must dispose of all colors which * they allocate. */ public void dispose() { - if ((fFlags & SYSTEM) != 0) { - System.out.println("Color.dispose: attempt to dispose system color; ignored"); - return; - } - if (device != null && device.isDisposed()) return; + if (handle == null) return; + if (device.isDisposed()) return; device = null; - fFlags |= DISPOSED; + handle = null; } + /** * Compares the argument to the receiver, and returns true * if they represent the <em>same</em> object using a class @@ -120,12 +115,16 @@ public void dispose() { * * @see #hashCode */ -public boolean equals (Object object) { +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 == color.handle; + float[] rgbColor = color.handle; + if (handle == rgbColor) return true; + return device == color.device && handle[0] == rgbColor[0] && + handle[1] == rgbColor[1] && handle[2] == rgbColor[2]; } + /** * Returns the amount of blue in the color, from 0 to 255. * @@ -135,10 +134,11 @@ public boolean equals (Object object) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public int getBlue () { +public int getBlue() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return handle & 0xFF; + return (int)(handle[2] * 255); } + /** * Returns the amount of green in the color, from 0 to 255. * @@ -148,10 +148,11 @@ public int getBlue () { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public int getGreen () { +public int getGreen() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return (handle >> 8) & 0xFF; + return (int)(handle[1] * 255); } + /** * Returns the amount of red in the color, from 0 to 255. * @@ -161,10 +162,26 @@ public int getGreen () { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public int getRed () { +public int getRed() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return (handle >> 16) & 0xFF; + return (int)(handle[0] * 255); +} + +/** + * Returns an integer hash code for the receiver. Any two + * objects which 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 (isDisposed()) return 0; + return (int)(handle[0] * 255) ^ (int)(handle[1] * 255) ^ (int)(handle[2] * 255); } + /** * Returns an <code>RGB</code> representing the receiver. * @@ -174,22 +191,32 @@ public int getRed () { */ public RGB getRGB () { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return new RGB((handle >> 16) & 0xFF, (handle >> 8) & 0xFF, (handle >> 0) & 0xFF); + return new RGB(getRed(), getGreen(), getBlue()); } -/** - * Returns an integer hash code for the receiver. Any two - * objects which return <code>true</code> when passed to - * <code>equals</code> must return the same value for this - * method. - * - * @return the receiver's hash + +/** + * Invokes platform specific functionality to allocate a new color. + * <p> + * <b>IMPORTANT:</b> This method is <em>not</em> part of the public + * API for <code>Color</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> * - * @see #equals + * @param device the device on which to allocate the color + * @param handle the handle for the color + * + * @private */ -public int hashCode () { - if (isDisposed()) return 0; - return handle; +public static Color carbon_new(Device device, float[] rgbColor) { + if (device == null) device = Device.getDevice(); + Color color = new Color(); + color.handle = rgbColor; + color.device = device; + return color; } + void init(Device device, int red, int green, int blue) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); @@ -199,9 +226,14 @@ void init(Device device, int red, int green, int blue) { (blue > 255) || (blue < 0)) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - this.device= device; - handle= ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | (blue & 0xFF); + float[] rgbColor = new float[4]; + rgbColor[0] = red / 255f; + rgbColor[1] = green / 255f; + rgbColor[2] = blue / 255f; + rgbColor[3] = 1; + handle = rgbColor; } + /** * Returns <code>true</code> if the color has been disposed, * and <code>false</code> otherwise. @@ -213,17 +245,9 @@ void init(Device device, int red, int green, int blue) { * @return <code>true</code> when the color is disposed and <code>false</code> otherwise */ public boolean isDisposed() { - return (fFlags & DISPOSED) != 0; -} -public static Color carbon_new(Device device, int packed, boolean system) { - if (device == null) device = Device.getDevice(); - Color color = new Color(); - color.device = device; - color.handle = packed; - if (system) - color.fFlags |= SYSTEM; - return color; + return handle == null; } + /** * Returns a string containing a concise, human-readable * description of the receiver. @@ -234,4 +258,5 @@ public String toString () { if (isDisposed()) return "Color {*DISPOSED*}"; return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}"; } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java index b6138e90e2..976c6f32e6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java @@ -7,9 +7,8 @@ package org.eclipse.swt.graphics; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.*; -import org.eclipse.swt.internal.carbon.OS; -import org.eclipse.swt.widgets.Display; /** * Instances of this class manage operating system resources that @@ -35,26 +34,66 @@ import org.eclipse.swt.widgets.Display; * Note: Only one of the above styles may be specified. * </p> */ + public final class Cursor { + /** * the handle to the OS cursor resource * (Warning: This field is platform dependent) */ public int handle; - + /** - * The device where this Cursor was created. + * the device where this cursor was created */ Device device; - // AW - private boolean fDispose; + /** + * data and mask used to create a Resize NS Cursor + */ + static final short [] SIZENS_SOURCE = new short[] { + (short)0x0000, + (short)0x0180, + (short)0x03C0, + (short)0x07E0, + (short)0x0180, + (short)0x0180, + (short)0x0180, + (short)0x7FFE, + (short)0x7FFE, + (short)0x0180, + (short)0x0180, + (short)0x0180, + (short)0x07E0, + (short)0x03C0, + (short)0x0180, + (short)0x0000, + }; + static final short [] SIZENS_MASK = new short[] { + (short)0x0180, + (short)0x03C0, + (short)0x07E0, + (short)0x0FF0, + (short)0x0FF0, + (short)0x03C0, + (short)0xFFFF, + (short)0xFFFF, + (short)0xFFFF, + (short)0xFFFF, + (short)0x03C0, + (short)0x0FF0, + (short)0x0FF0, + (short)0x07E0, + (short)0x03C0, + (short)0x0180, + }; - private static int NO_CURSOR; - // AW - -Cursor () { +/** + * Prevents uninitialized instances from being created outside the package. + */ +Cursor() { } + /** * Constructs a new cursor given a device and a style * constant describing the desired cursor appearance. @@ -96,58 +135,48 @@ Cursor () { * @see SWT#CURSOR_NO * @see SWT#CURSOR_HAND */ -public Cursor (Device device, int style) { +public Cursor(Device device, int style) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.device = device; - - handle = OS.kThemeArrowCursor; // the default cursor - switch (style) { - case SWT.CURSOR_ARROW: - handle= OS.kThemeArrowCursor; - break; - case SWT.CURSOR_WAIT: - handle= OS.kThemeSpinningCursor; - break; - case SWT.CURSOR_APPSTARTING: - handle= OS.kThemeWatchCursor; - break; - case SWT.CURSOR_HAND: - handle= OS.kThemeOpenHandCursor; - break; - case SWT.CURSOR_CROSS: - handle= OS.kThemeCrossCursor; - break; - case SWT.CURSOR_HELP: break; - case SWT.CURSOR_SIZEALL: break; - case SWT.CURSOR_SIZENESW: break; - case SWT.CURSOR_SIZENS: break; - case SWT.CURSOR_SIZENWSE: break; - case SWT.CURSOR_SIZEWE: break; - case SWT.CURSOR_SIZEN: break; - case SWT.CURSOR_SIZES: break; - case SWT.CURSOR_SIZEE: break; - case SWT.CURSOR_SIZEW: break; - case SWT.CURSOR_SIZENE: break; - case SWT.CURSOR_SIZESE: break; - case SWT.CURSOR_SIZESW: break; - case SWT.CURSOR_SIZENW: break; - case SWT.CURSOR_UPARROW: break; - case SWT.CURSOR_IBEAM: - handle= OS.kThemeIBeamCursor; - break; - case SWT.CURSOR_NO: - if (NO_CURSOR == 0) { - short[] data= new short[16]; - NO_CURSOR= OS.NewCursor((short) 0, (short)0, data, data); + case SWT.CURSOR_HAND: handle = OS.kThemePointingHandCursor; break; + case SWT.CURSOR_ARROW: handle = OS.kThemeArrowCursor; break; + case SWT.CURSOR_WAIT: handle = OS.kThemeSpinningCursor; break; + case SWT.CURSOR_CROSS: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_APPSTARTING: handle = OS.kThemeWatchCursor; break; + case SWT.CURSOR_HELP: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZEALL: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZENESW: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZENS: { + org.eclipse.swt.internal.carbon.Cursor cursor = new org.eclipse.swt.internal.carbon.Cursor(); + cursor.data = SIZENS_SOURCE; + cursor.mask = SIZENS_MASK; + cursor.hotSpot_h = 7; + cursor.hotSpot_v = 7; + handle = OS.NewPtr(org.eclipse.swt.internal.carbon.Cursor.sizeof); + if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); + OS.memcpy(handle, cursor, org.eclipse.swt.internal.carbon.Cursor.sizeof); + break; } - handle = NO_CURSOR; - break; - default: - SWT.error(SWT.ERROR_INVALID_ARGUMENT); + case SWT.CURSOR_SIZENWSE: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZEWE: handle = OS.kThemeResizeLeftRightCursor; break; + case SWT.CURSOR_SIZEN: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZES: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZEE: handle = OS.kThemeResizeRightCursor; break; + case SWT.CURSOR_SIZEW: handle = OS.kThemeResizeLeftCursor; break; + case SWT.CURSOR_SIZENE: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZESE: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZESW: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_SIZENW: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_UPARROW: handle = OS.kThemeCrossCursor; break; + case SWT.CURSOR_IBEAM: handle = OS.kThemeIBeamCursor; break; + case SWT.CURSOR_NO: handle = OS.kThemeNotAllowedCursor; break; + default: + SWT.error(SWT.ERROR_INVALID_ARGUMENT); } } + /** * Constructs a new cursor given a device, image and mask * data describing the desired cursor appearance, and the x @@ -180,14 +209,14 @@ public Cursor (Device device, int style) { * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li> * </ul> */ -public Cursor (Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) { +public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.device = device; if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (mask == null) { if (source.getTransparencyType() != SWT.TRANSPARENCY_MASK) { - SWT.error(SWT.ERROR_INVALID_ARGUMENT); + SWT.error(SWT.ERROR_NULL_ARGUMENT); } mask = source.getTransparencyMask(); } @@ -195,7 +224,7 @@ public Cursor (Device device, ImageData source, ImageData mask, int hotspotX, in if (mask.width != source.width || mask.height != source.height) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - /* Check depths */ + /* Check color depths */ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (source.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); /* Check the hotspots */ @@ -203,51 +232,56 @@ public Cursor (Device device, ImageData source, ImageData mask, int hotspotX, in hotspotY >= source.height || hotspotY < 0) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - - int w= Math.min(16, source.width); - int h= Math.min(16, source.height); - - short[] data= new short[16]; - short[] msk= new short[16]; - - for (int y= 0; y < h; y++) { - short d= 0; - short m= 0; - for (int x= 0; x < w; x++) { + /* Create the cursor */ + org.eclipse.swt.internal.carbon.Cursor cursor = new org.eclipse.swt.internal.carbon.Cursor(); + int width = Math.min(16, source.width); + int height = Math.min(16, source.height); + short[] srcData = cursor.data; + short[] maskData = cursor.mask; + for (int y= 0; y < height; y++) { + short d = 0, m = 0; + for (int x= 0; x < width; x++) { int bit= 1 >> x; - if (source.getPixel(x, y) != 0) - d |= bit; - if (mask.getPixel(x, y) != 0) - m |= bit; + if (source.getPixel(x, y) != 0) d |= bit; + if (mask.getPixel(x, y) != 0) m |= bit; } - data[y]= d; - msk[y]= m; + srcData[y] = d; + maskData[y] = m; } - - OS.NewCursor((short) hotspotX, (short)hotspotY, data, msk); + cursor.hotSpot_h = (short)Math.min(16, hotspotX); + cursor.hotSpot_v = (short)Math.min(16, hotspotY); + handle = OS.NewPtr(org.eclipse.swt.internal.carbon.Cursor.sizeof); if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); - fDispose= true; + OS.memcpy(handle, cursor, org.eclipse.swt.internal.carbon.Cursor.sizeof); } -//public static Cursor carbon_new(Device device, int handle) { -// if (device == null) device = Device.getDevice(); -// Cursor cursor = new Cursor(); -// cursor.device = device; -// cursor.handle = handle; -// return cursor; -//} + /** * Disposes of the operating system resources associated with * the cursor. Applications must dispose of all cursors which * they allocate. */ public void dispose () { - if (handle == 0) return; + if (handle == -1) return; if (device.isDisposed()) return; - if (fDispose) - OS.DisposePtr(handle); - device = null; + switch (handle) { + case OS.kThemePointingHandCursor: + case OS.kThemeArrowCursor: + case OS.kThemeSpinningCursor: + case OS.kThemeCrossCursor: + case OS.kThemeWatchCursor: + case OS.kThemeIBeamCursor: + case OS.kThemeNotAllowedCursor: + case OS.kThemeResizeLeftRightCursor: + case OS.kThemeResizeLeftCursor: + case OS.kThemeResizeRightCursor: + break; + default: + OS.DisposePtr(handle); + } handle = -1; + device = null; } + /** * Compares the argument to the receiver, and returns true * if they represent the <em>same</em> object using a class @@ -261,9 +295,10 @@ public void dispose () { public boolean equals (Object object) { if (object == this) return true; if (!(object instanceof Cursor)) return false; - Cursor cursor = (Cursor)object; + Cursor cursor = (Cursor) object; return device == cursor.device && handle == cursor.handle; } + /** * Returns an integer hash code for the receiver. Any two * objects which return <code>true</code> when passed to @@ -277,6 +312,7 @@ public boolean equals (Object object) { public int hashCode () { return handle; } + /** * Returns <code>true</code> if the cursor has been disposed, * and <code>false</code> otherwise. @@ -290,6 +326,7 @@ public int hashCode () { public boolean isDisposed() { return handle == -1; } + /** * Returns a string containing a concise, human-readable * description of the receiver. @@ -301,35 +338,27 @@ public String toString () { return "Cursor {" + handle + "}"; } -//////////////////////////////////////////////////////// -// Mac stuff -//////////////////////////////////////////////////////// - - /** - * Method install. - */ - public void install(Display display) { - if (handle != display.fCurrentCursor) { - display.fCurrentCursor= handle; - switch (handle) { - - case -1: // disposed - break; - - case OS.kThemeArrowCursor: - case OS.kThemeSpinningCursor: - case OS.kThemeWatchCursor: - case OS.kThemeOpenHandCursor: - case OS.kThemeCrossCursor: - case OS.kThemeIBeamCursor: - OS.SetThemeCursor(handle); - break; - - default: - display.setCursor(handle); - break; - } - } - } +/** + * Invokes platform specific functionality to allocate a new cursor. + * <p> + * <b>IMPORTANT:</b> This method is <em>not</em> part of the public + * API for <code>Cursor</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 device the device on which to allocate the color + * @param handle the handle for the cursor + * + * @private + */ +public static Cursor carbon_new(Device device, int handle) { + if (device == null) device = Device.getDevice(); + Cursor cursor = new Cursor(); + cursor.handle = handle; + cursor.device = device; + return cursor; +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Device.java index 364a404b74..eaeb77d8fb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Device.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Device.java @@ -7,8 +7,9 @@ package org.eclipse.swt.graphics; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.*; import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.*; +import org.eclipse.swt.*; /** * This class is the abstract superclass of all device objects, @@ -18,34 +19,30 @@ import org.eclipse.swt.internal.carbon.*; */ public abstract class Device implements Drawable { - /** - * the handle to the GDevice - * (Warning: This field is platform dependent) - */ - public int fGDeviceHandle; - /* Debugging */ public static boolean DEBUG; boolean debug = DEBUG; - public boolean tracking = DEBUG; + boolean tracking = DEBUG; Error [] errors; Object [] objects; - - /* System Colors */ + + /* Disposed flag */ + boolean disposed, warnings; + + int colorspace; + + /* + * The following colors are listed in the Windows + * Programmer's Reference as the colors in the default + * palette. + */ Color COLOR_BLACK, COLOR_DARK_RED, COLOR_DARK_GREEN, COLOR_DARK_YELLOW, COLOR_DARK_BLUE; Color COLOR_DARK_MAGENTA, COLOR_DARK_CYAN, COLOR_GRAY, COLOR_DARK_GRAY, COLOR_RED; Color COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE; - - /* System Font */ - MacFont systemFont; - // AW - int fScreenDepth; - // AW + /* System Font */ + Font systemFont; - /* Warning and Error Handlers */ - boolean warnings = true; - /* * TEMPORARY CODE. When a graphics object is * created and the device parameter is null, @@ -66,8 +63,8 @@ public abstract class Device implements Drawable { } catch (Throwable e) {} } -/* -* TEMPORARY CODE +/* +* TEMPORARY CODE. */ static Device getDevice () { if (DeviceFinder != null) DeviceFinder.run(); @@ -90,8 +87,8 @@ static Device getDevice () { */ public Device(DeviceData data) { if (data != null) { - tracking = data.tracking; debug = data.debug; + tracking = data.tracking; } create (data); init (); @@ -99,23 +96,15 @@ public Device(DeviceData data) { errors = new Error [128]; objects = new Object [128]; } - - /* Initialize the system font slot */ - Font font = getSystemFont (); - //FontData fd = font.getFontData ()[0]; - systemFont = font.handle; } protected void checkDevice () { - if (fGDeviceHandle == 0) SWT.error (SWT.ERROR_DEVICE_DISPOSED); + if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED); } protected void create (DeviceData data) { } -protected void destroy () { -} - /** * Disposes of the operating system resources associated with * the receiver. After this method has been invoked, the receiver @@ -131,7 +120,7 @@ public void dispose () { checkDevice (); release (); destroy (); - fGDeviceHandle= 0; + disposed = true; if (tracking) { objects = null; errors = null; @@ -148,6 +137,9 @@ void dispose_Object (Object object) { } } +protected void destroy () { +} + /** * Returns a rectangle describing the receiver's size and location. * @@ -159,52 +151,14 @@ void dispose_Object (Object object) { */ public Rectangle getBounds () { checkDevice (); - - MacRect bounds= new MacRect(); - if (fGDeviceHandle != 0) { - int pm= OS.getgdPMap(fGDeviceHandle); - if (pm != 0) - OS.GetPixBounds(pm, bounds.getData()); - } - return bounds.toRectangle(); -} - -/** - * 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 (); - - MacRect bounds= new MacRect(); - int gdh= OS.GetMainDevice(); - OS.GetAvailableWindowPositioningBounds(gdh, bounds.getData()); - return bounds.toRectangle(); -} - -/** - * 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 (); - return fScreenDepth; + int gdevice = OS.GetMainDevice(); + int[] ptr = new int[1]; + OS.memcpy(ptr, gdevice, 4); + GDevice device = new GDevice(); + OS.memcpy(device, ptr[0], GDevice.sizeof); + Rect rect = new Rect(); + OS.GetPixBounds(device.gdPMap, rect); + return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } /** @@ -221,7 +175,7 @@ public int getDepth () { * @see DeviceData */ public DeviceData getDeviceData () { - checkDevice (); + checkDevice(); DeviceData data = new DeviceData (); data.debug = debug; data.tracking = tracking; @@ -244,6 +198,49 @@ public DeviceData getDeviceData () { } /** + * 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 (); + int gdevice = OS.GetMainDevice(); + Rect rect = new Rect(); + OS.GetAvailableWindowPositioningBounds(gdevice, rect); + return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); +} + +/** + * 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 (); + int gdevice = OS.GetMainDevice(); + int[] ptr = new int[1]; + OS.memcpy(ptr, gdevice, 4); + GDevice device = new GDevice(); + OS.memcpy(device, ptr[0], GDevice.sizeof); + int depth = OS.GetPixDepth(device.gdPMap); + return depth; +} + +/** * 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. @@ -256,28 +253,15 @@ public DeviceData getDeviceData () { */ public Point getDPI () { checkDevice (); - /* AW - int xScreenNum = OS.XDefaultScreen (xDisplay); - int width = OS.XDisplayWidth (xDisplay, xScreenNum); - int height = OS.XDisplayHeight (xDisplay, xScreenNum); - int mmX = OS.XDisplayWidthMM (xDisplay, xScreenNum); - int mmY = OS.XDisplayHeightMM (xDisplay, xScreenNum); - */ - /* 0.03937 mm/inch */ - /* AW - double inchesX = mmX * 0.03937; - double inchesY = mmY * 0.03937; - int x = (int)((width / inchesX) + 0.5); - int y = (int)((height / inchesY) + 0.5); - return new Point (x, y); - */ - - if (fGDeviceHandle != 0) { - int pm= OS.getgdPMap(fGDeviceHandle); - if (pm != 0) - return new Point(OS.getPixHRes(pm) >> 16, OS.getPixVRes(pm) >> 16); - } - return new Point(72, 72); + int gdevice = OS.GetMainDevice(); + int[] ptr = new int[1]; + OS.memcpy(ptr, gdevice, 4); + GDevice device = new GDevice(); + OS.memcpy(device, ptr[0], GDevice.sizeof); + OS.memcpy(ptr, device.gdPMap, 4); + PixMap pixmap = new PixMap(); + OS.memcpy(pixmap, ptr[0], PixMap.sizeof); + return new Point (pixmap.hRes >> 16, pixmap.vRes >> 16); } /** @@ -293,52 +277,53 @@ public Point getDPI () { * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public FontData [] getFontList (String faceName, boolean scalable) { +public FontData[] getFontList (String faceName, boolean scalable) { checkDevice (); - /* AW - String xlfd; - if (faceName == null) { - xlfd = "-*-*-*-*-*-*-*-*-*-*-*-*-*-*"; - } else { - int dashIndex = faceName.indexOf('-'); - if (dashIndex < 0) { - xlfd = "-*-" + faceName + "-*-*-*-*-*-*-*-*-*-*-*-*"; - } else { - xlfd = "-" + faceName + "-*-*-*-*-*-*-*-*-*-*-*-*"; + //NOT DONE - scalable + int nFds = 0; + FontData[] fds = new FontData[4]; + + int[] font = new int[1]; + short[] fontFamily = new short[1]; + short[] style = new short[1]; + short[] size = new short[1]; + byte[] buffer = new byte[256]; + int familyIter = OS.NewPtr(16 * 4); + int fontIter = OS.NewPtr(16 * 4); + OS.FMCreateFontFamilyIterator(0, 0, 0, familyIter); + while (OS.FMGetNextFontFamily(familyIter, fontFamily) != OS.kFMIterationCompleted) { + OS.FMGetFontFamilyName(fontFamily[0], buffer); + int length = buffer[0] & 0xFF; + char[] chars = new char[length]; + for (int i=0; i<length; i++) { + chars[i]= (char)buffer[i+1]; } - } - */ - /* Use the character encoding for the default locale */ - /* AW - byte [] buffer1 = Converter.wcsToMbcs (null, xlfd, true); - int [] ret = new int [1]; - int listPtr = OS.XListFonts (xDisplay, buffer1, 65535, ret); - int ptr = listPtr; - int [] intBuf = new int [1]; - FontData [] fd = new FontData [ret [0]]; - int fdIndex = 0; - for (int i = 0; i < ret [0]; i++) { - OS.memmove (intBuf, ptr, 4); - int charPtr = intBuf [0]; - int length = OS.strlen (charPtr); - byte [] buffer2 = new byte [length]; - OS.memmove (buffer2, charPtr, length); - // Use the character encoding for the default locale - char [] chars = Converter.mbcsToWcs (null, buffer2); - FontData data = FontData.motif_new (new String (chars)); - boolean isScalable = data.averageWidth == 0 && data.pixels == 0 && data.points == 0; - if (isScalable == scalable) { - fd [fdIndex++] = data; + String name = new String(chars); + if (faceName == null || Compatibility.equalsIgnoreCase(faceName, name)) { + OS.FMCreateFontFamilyInstanceIterator(fontFamily[0], fontIter); + while (OS.FMGetNextFontFamilyInstance(fontIter, font, style, size) != OS.kFMIterationCompleted) { + int s = SWT.NORMAL; + if ((style[0] & OS.italic) != 0) s |= SWT.ITALIC; + if ((style[0] & OS.bold) != 0) s |= SWT.BOLD; + FontData data = new FontData(name, s, size[0]); + if (nFds == fds.length) { + FontData[] newFds = new FontData[fds.length + 4]; + System.arraycopy(fds, 0, newFds, 0, nFds); + fds = newFds; + } + fds[nFds++] = data; + } + OS.FMDisposeFontFamilyInstanceIterator(fontIter); } - ptr += 4; } - OS.XFreeFontNames (listPtr); - if (fdIndex == ret [0]) return fd; - FontData [] result = new FontData [fdIndex]; - System.arraycopy (fd, 0, result, 0, fdIndex); + OS.FMDisposeFontFamilyIterator(familyIter); + OS.DisposePtr(familyIter); + OS.DisposePtr(fontIter); + + if (nFds == fds.length) return fds; + FontData[] result = new FontData[nFds]; + System.arraycopy(fds, 0, result, 0, nFds); return result; - */ - return new FontData [0]; } /** @@ -361,9 +346,6 @@ public FontData [] getFontList (String faceName, boolean scalable) { */ public Color getSystemColor (int id) { checkDevice (); - /* AW - XColor xColor = null; - */ switch (id) { case SWT.COLOR_BLACK: return COLOR_BLACK; case SWT.COLOR_DARK_RED: return COLOR_DARK_RED; @@ -382,11 +364,7 @@ public Color getSystemColor (int id) { case SWT.COLOR_CYAN: return COLOR_CYAN; case SWT.COLOR_WHITE: return COLOR_WHITE; } - /* AW - if (xColor == null) return COLOR_BLACK; - return Color.motif_new (this, xColor); - */ - return Color.carbon_new(this, 0x000000, false); + return COLOR_BLACK; } /** @@ -411,7 +389,7 @@ public Color getSystemColor (int id) { */ public Font getSystemFont () { checkDevice (); - return Font.carbon_new (this, systemFont); + return systemFont; } /** @@ -431,30 +409,36 @@ public boolean getWarnings () { } protected void init () { - - fScreenDepth= getDeviceDepth(fGDeviceHandle); - - /* - * The following colors are listed in the Windows - * Programmer's Reference as the colors in the default - * palette. - */ - COLOR_BLACK = Color.carbon_new(this, 0x000000, true); - COLOR_DARK_RED = Color.carbon_new(this, 0x800000, true); - COLOR_DARK_GREEN = Color.carbon_new(this, 0x008000, true); - COLOR_DARK_YELLOW = Color.carbon_new(this, 0x808000, true); - COLOR_DARK_BLUE = Color.carbon_new(this, 0x000080, true); - COLOR_DARK_MAGENTA =Color.carbon_new(this, 0x800080, true); - COLOR_DARK_CYAN = Color.carbon_new(this, 0x008080, true); - COLOR_GRAY = Color.carbon_new(this, 0xC0C0C0, true); - COLOR_DARK_GRAY = Color.carbon_new(this, 0x808080, true); - COLOR_RED = Color.carbon_new(this, 0xFF0000, true); - COLOR_GREEN = Color.carbon_new(this, 0x00FF00, true); - COLOR_YELLOW = Color.carbon_new(this, 0xFFFF00, true); - COLOR_BLUE = Color.carbon_new(this, 0x0000FF, true); - COLOR_MAGENTA = Color.carbon_new(this, 0xFF00FF, true); - COLOR_CYAN = Color.carbon_new(this, 0x00FFFF, true); - COLOR_WHITE = Color.carbon_new(this, 0xFFFFFF, true); + colorspace = OS.CGColorSpaceCreateDeviceRGB(); + if (colorspace == 0) SWT.error(SWT.ERROR_NO_HANDLES); + + /* Create the standard colors */ + COLOR_BLACK = new Color (this, 0,0,0); + COLOR_DARK_RED = new Color (this, 0x80,0,0); + COLOR_DARK_GREEN = new Color (this, 0,0x80,0); + COLOR_DARK_YELLOW = new Color (this, 0x80,0x80,0); + COLOR_DARK_BLUE = new Color (this, 0,0,0x80); + COLOR_DARK_MAGENTA = new Color (this, 0x80,0,0x80); + COLOR_DARK_CYAN = new Color (this, 0,0x80,0x80); + COLOR_GRAY = new Color (this, 0xC0,0xC0,0xC0); + COLOR_DARK_GRAY = new Color (this, 0x80,0x80,0x80); + COLOR_RED = new Color (this, 0xFF,0,0); + COLOR_GREEN = new Color (this, 0,0xFF,0); + COLOR_YELLOW = new Color (this, 0xFF,0xFF,0); + COLOR_BLUE = new Color (this, 0,0,0xFF); + COLOR_MAGENTA = new Color (this, 0xFF,0,0xFF); + COLOR_CYAN = new Color (this, 0,0xFF,0xFF); + COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF); + + /* Initialize the system font slot */ + short id = OS.GetAppFont(); + short style = (short)0; + short size = OS.GetDefFontSize(); + int[] font = new int[1]; + if (OS.FMGetFontFromFontFamilyInstance(id, style, font, null) != 0) { + SWT.error(SWT.ERROR_NO_HANDLES); + } + systemFont = Font.carbon_new (this, font[0], id, style, size); } /** @@ -502,9 +486,9 @@ public abstract void internal_dispose_GC (int handle, GCData data); * @return <code>true</code> when the device is disposed and <code>false</code> otherwise */ public boolean isDisposed () { - return fGDeviceHandle == 0; + return disposed; } - + void new_Object (Object object) { for (int i=0; i<objects.length; i++) { if (objects [i] == null) { @@ -523,9 +507,12 @@ void new_Object (Object object) { errors = newErrors; } -protected void release () { - COLOR_BLACK = COLOR_DARK_RED = COLOR_DARK_GREEN = COLOR_DARK_YELLOW = - COLOR_DARK_BLUE = COLOR_DARK_MAGENTA = COLOR_DARK_CYAN = COLOR_GRAY = COLOR_DARK_GRAY = COLOR_RED = +protected void release () { + OS.CGColorSpaceRelease(colorspace); + colorspace = 0; + + COLOR_BLACK = COLOR_DARK_RED = COLOR_DARK_GREEN = COLOR_DARK_YELLOW = COLOR_DARK_BLUE = + COLOR_DARK_MAGENTA = COLOR_DARK_CYAN = COLOR_GRAY = COLOR_DARK_GRAY = COLOR_RED = COLOR_GREEN = COLOR_YELLOW = COLOR_BLUE = COLOR_MAGENTA = COLOR_CYAN = COLOR_WHITE = null; } @@ -544,19 +531,6 @@ protected void release () { public void setWarnings (boolean warnings) { checkDevice (); this.warnings = warnings; - if (debug) return; } -//////////////////////////////////////////////////////// -// Mac stuff -//////////////////////////////////////////////////////// - - static int getDeviceDepth(int gd) { - if (gd != 0) { - int pm= OS.getgdPMap(gd); - if (pm != 0) - return OS.GetPixDepth(pm); - } - return 32; - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Font.java index 0e2964df7f..d296c3ba7e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Font.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Font.java @@ -8,6 +8,7 @@ package org.eclipse.swt.graphics; */ import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.*; import org.eclipse.swt.*; /** @@ -24,21 +25,36 @@ import org.eclipse.swt.*; * @see FontData */ public final class Font { + + /** + * the handle to the OS font (a FMFont) + * (Warning: This field is platform dependent) + */ + public int handle; /** - * the handle to the OS font resource + * the id to the OS font (a FMFontFamily) * (Warning: This field is platform dependent) */ - public MacFont handle; + public short id; /** - * the device where this font was created + * the style to the OS font (a FMFontStyle) + * (Warning: This field is platform dependent) + */ + public short style; + + /** + * the size to the OS font + * (Warning: This field is platform dependent) + */ + public short size; + + /** + * The device where this image was created. */ Device device; -/** - * Prevents uninitialized instances from being created outside the package. - */ Font() { } @@ -60,17 +76,16 @@ Font() { * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li> * </ul> */ -public Font(Device device, FontData fd) { +public Font(Device display, FontData fd) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - init(device, fd); - if (device.tracking) device.new_Object(this); + if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + init(device, fd.getName(), fd.getHeight(), fd.getStyle()); } /** - * Constructs a new font given a device and an array - * of font data which describes the desired font's - * appearance. + * Constructs a new font given a device and font datas + * which describes the desired font's appearance. * <p> * You must dispose the font when it is no longer required. * </p> @@ -87,16 +102,15 @@ public Font(Device device, FontData fd) { * @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) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - init(device, fds[0]); - if (device.tracking) device.new_Object(this); + FontData fd = fds[0]; + if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + init(device,fd.getName(), fd.getHeight(), fd.getStyle()); } /** @@ -121,12 +135,10 @@ public Font(Device device, FontData[] fds) { * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li> * </ul> */ -public Font(Device device, String name, int height, int style) { +public Font(Device display, String name, int height, int style) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - init(device, new FontData (name, height, style)); - if (device.tracking) device.new_Object(this); + init(device, name, height, style); } /** @@ -135,9 +147,8 @@ public Font(Device device, String name, int height, int style) { * they allocate. */ public void dispose() { - if (handle == null) return; - handle = null; - if (device.tracking) device.dispose_Object(this); + handle = 0; + id = -1; device = null; } @@ -154,8 +165,7 @@ public void dispose() { public boolean equals(Object object) { if (object == this) return true; if (!(object instanceof Font)) return false; - Font font = (Font) object; - return device == font.device && handle.equals(font.handle); + return handle == ((Font)object).handle; } /** @@ -172,7 +182,46 @@ public boolean equals(Object object) { */ public FontData[] getFontData() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return new FontData[] { new FontData(handle.getName(), handle.getSize(), handle.getFace()) }; + byte[] buffer = new byte[256]; + OS.FMGetFontFamilyName(id, buffer); + int length = buffer[0] & 0xFF; + char[] chars = new char[length]; + for (int i=0; i<length; i++) { + chars[i]= (char)buffer[i+1]; + } + String name = new String(chars); + int style = SWT.NORMAL; + if ((this.style & OS.italic) != 0) style |= SWT.ITALIC; + if ((this.style & OS.bold) != 0) style |= SWT.BOLD; + FontData data = new FontData(name, size, style); + return new FontData[]{data}; +} + +/** + * Invokes platform specific functionality to allocate a new font. + * <p> + * <b>IMPORTANT:</b> This method is <em>not</em> part of the public + * API for <code>Font</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 device the device on which to allocate the color + * @param handle the handle for the font + * @param size the size for the font + * + * @private + */ +public static Font carbon_new(Device device, int handle, short id, short style, short size) { + if (device == null) device = Device.getDevice(); + Font font = new Font(); + font.handle = handle; + font.id = id; + font.style = style; + font.size = size; + font.device = device; + return font; } /** @@ -185,16 +234,30 @@ public FontData[] getFontData() { * * @see #equals */ -public int hashCode () { - if (handle != null) - return handle.hashCode(); - return 0; +public int hashCode() { + return handle; } -void init (Device device, FontData fd) { - if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - this.device = device; - handle= new MacFont(fd.fontFamily, fd.height, fd.style); +void init(Device device, String name, int height, int style) { + if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + byte[] buffer = new byte[256]; + int length = name.length(); + if (length > 255) length = 255; + buffer[0] = (byte)length; + for (int i=0; i<length; i++) { + buffer[i+1]= (byte)name.charAt(i); + } + this.id = OS.FMGetFontFamilyFromName(buffer); + if (this.id == OS.kInvalidFontFamily) this.id = OS.GetAppFont(); + if ((style & SWT.ITALIC) != 0) this.style |= OS.italic; + if ((style & SWT.BOLD) != 0) this.style |= OS.bold; + this.size = (short)height; + int[] font = new int[1]; + if (OS.FMGetFontFromFontFamilyInstance(id, this.style, font, null) != 0) { + SWT.error(SWT.ERROR_NO_HANDLES); + } + this.handle = font[0]; } /** @@ -208,7 +271,7 @@ void init (Device device, FontData fd) { * @return <code>true</code> when the font is disposed and <code>false</code> otherwise */ public boolean isDisposed() { - return handle == null; + return handle == 0; } /** @@ -222,27 +285,4 @@ public String toString () { return "Font {" + handle + "}"; } -/** - * Invokes platform specific functionality to allocate a new font. - * <p> - * <b>IMPORTANT:</b> This method is <em>not</em> part of the public - * API for <code>Font</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 device the device on which to allocate the color - * @param handle the handle for the font - * - * @private - */ -public static Font carbon_new(Device device, MacFont macFont) { - if (device == null) device = Device.getDevice(); - Font font = new Font(); - font.handle = macFont; - font.device = device; - return font; -} - } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontData.java index 67de546b13..11425279f3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontData.java @@ -8,7 +8,7 @@ package org.eclipse.swt.graphics; */ import org.eclipse.swt.*; - + /** * Instances of this class describe operating system fonts. * Only the public API of this type is platform independent. @@ -36,38 +36,36 @@ import org.eclipse.swt.*; */ public final class FontData { /** - * The font foundry. - * Warning: This field is platform dependent. - */ - public String foundry; - /** - * The font family. - * Warning: This field is platform dependent. + * the font name + * (Warning: This field is platform dependent) */ - public String fontFamily; + public String name; + /** * The height of the font data in points * (Warning: This field is platform dependent) */ public int height; + /** - * The font style. - * Warning: This field is platform dependent. + * the font style + * (Warning: This field is platform dependent) */ public int style; - - // AW for FontDialog - public String addStyle= "FontData.addStyle"; - public String weight= "FontData.weight"; - public String characterSetRegistry= "FontData.characterSetRegistry"; - public String characterSetName= "characterSetName"; - // AW end + + /** + * The locales of the font + * (Warning: These fields are platform dependent) + */ + String lang, country, variant; /** * Constructs a new un-initialized 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> @@ -89,31 +87,54 @@ public FontData () { */ public FontData(String string) { if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - //System.out.println("new FontData: " + string); + int start = 0; + int end = string.indexOf('|'); + if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + String version1 = string.substring(start, end); + + start = end + 1; + end = string.indexOf('|', start); + if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + String name = string.substring(start, end); - int start= 0; - int stop= string.indexOf("|"); - String name= string.substring(start, stop); - start= stop+1; - stop= string.indexOf("|", start); - int height= 0; + 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, stop)); - } catch (NumberFormatException ex) { + height = Integer.parseInt(string.substring(start, end)); + } catch (NumberFormatException e) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - start= stop+1; - int style= 0; + + 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)); - } catch (NumberFormatException ex) { + style = Integer.parseInt(string.substring(start, end)); + } catch (NumberFormatException e) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - - //System.out.println("**** <"+name+"><"+size+"><"+face+">"); - + + 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("CARBON") && version2.equals("1")) { + return; + } } + /** * Constructs a new font data given a font name, * the height of the desired font in points, @@ -128,12 +149,12 @@ public FontData(String string) { * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> * </ul> */ -public FontData (String name, int height, int style) { - //System.out.println("new FontData: " + name + " " + height + " " + style); +public FontData(String name, int height, int style) { setName(name); setHeight(height); setStyle(style); } + /** * Compares the argument to the receiver, and returns true * if they represent the <em>same</em> object using a class @@ -145,8 +166,12 @@ public FontData (String name, int height, int style) { * @see #hashCode */ public boolean equals (Object object) { - return (object == this) || ((object instanceof FontData) && toString().equals(((FontData)object).toString())); + 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. * @@ -157,6 +182,7 @@ public boolean equals (Object object) { public int getHeight() { return height; } + /** * Returns the name of the receiver. * On platforms that support font foundries, the return value will @@ -167,15 +193,9 @@ public int getHeight() { * @see #setName */ public String getName() { - StringBuffer buffer = new StringBuffer(); - if (foundry != null) { - buffer.append(foundry); - buffer.append("-"); - } - if (fontFamily != null) - buffer.append(fontFamily); - return buffer.toString(); + 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 @@ -188,6 +208,7 @@ public String getName() { public int getStyle() { return style; } + /** * Returns an integer hash code for the receiver. Any two * objects which return <code>true</code> when passed to @@ -199,11 +220,9 @@ public int getStyle() { * @see #equals */ public int hashCode () { - return toString().hashCode(); -} -public static FontData carbon_new(String xlfd) { - return new FontData(xlfd); + return name.hashCode() ^ height ^ style; } + /** * Sets the height of the receiver. The parameter is * specified in terms of points, where a point is one @@ -221,6 +240,44 @@ public void setHeight(int height) { if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); this.height = height; } + +/** + * Sets the locale of the receiver. + * <p> + * The locale determines which platform character set this + * font is going to use. Widgets and graphics operations that + * use this font will convert UNICODE strings to the platform + * character set of the specified locale. + * </p> + * <p> + * On platforms which there are multiple character sets for a + * given language/country locale, the variant portion of the + * locale will determine the character set. + * </p> + * + * @param locale the <code>String</code> representing a Locale object + * @see java.util.Locale#toString + */ +public void setLocale(String locale) { + lang = country = variant = null; + if (locale != null) { + char sep = '_'; + int length = locale.length(); + int firstSep, secondSep; + + firstSep = locale.indexOf(sep); + if (firstSep == -1) { + firstSep = secondSep = length; + } else { + secondSep = locale.indexOf(sep, firstSep + 1); + if (secondSep == -1) secondSep = length; + } + if (firstSep > 0) lang = locale.substring(0, firstSep); + if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep); + if (length > secondSep + 1) variant = locale.substring(secondSep + 1); + } +} + /** * Sets the name of the receiver. * <p> @@ -248,33 +305,9 @@ public void setHeight(int height) { */ public void setName(String name) { if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - int dash = name.indexOf('-'); - if (dash != -1) { - foundry = name.substring(0, dash); - fontFamily = name.substring(dash + 1); - } else { - fontFamily = name; - } -} -/** - * Sets the locale of the receiver. - * <p> - * The locale determines which platform character set this - * font is going to use. Widgets and graphics operations that - * use this font will convert UNICODE strings to the platform - * character set of the specified locale. - * </p> - * <p> - * On platforms which there are multiple character sets for a - * given language/country locale, the variant portion of the - * locale will determine the character set. - * </p> - * - * @param locale the <code>String</code> representing a Locale object - * @see java.util.Locale#toString - */ -public void setLocale(String locale) { + this.name = name; } + /** * Sets the style of the receiver to the argument which must * be a bitwise OR of one or more of the <code>SWT</code> @@ -285,8 +318,9 @@ public void setLocale(String locale) { * @see #getStyle */ public void setStyle(int style) { - this.style= style; + this.style = style; } + /** * Returns a string representation of the receiver which is suitable * for constructing an equivalent instance using the @@ -297,6 +331,16 @@ public void setStyle(int style) { * @see FontData */ public String toString() { - return getName() + "|" + getHeight() + "|" + getStyle(); + StringBuffer buffer = new StringBuffer(); + buffer.append("1|"); + buffer.append(getName()); + buffer.append("|"); + buffer.append(getHeight()); + buffer.append("|"); + buffer.append(getStyle()); + buffer.append("|"); + buffer.append("CARBON|1|"); + return buffer.toString(); } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontMetrics.java index d2db0bc331..5a65657044 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontMetrics.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/FontMetrics.java @@ -18,9 +18,10 @@ package org.eclipse.swt.graphics; */ public final class FontMetrics { int ascent, descent, averageCharWidth, leading, height; - + FontMetrics() { } + /** * Compares the argument to the receiver, and returns true * if they represent the <em>same</em> object using a class @@ -39,6 +40,7 @@ public boolean equals (Object object) { averageCharWidth == metrics.averageCharWidth && leading == metrics.leading && height == metrics.height; } + /** * Returns the ascent of the font described by the receiver. A * font's <em>ascent</em> is the distance from the baseline to the @@ -50,6 +52,7 @@ public boolean equals (Object object) { public int getAscent() { return ascent; } + /** * Returns the average character width, measured in pixels, * of the font described by the receiver. @@ -59,6 +62,7 @@ public int getAscent() { public int getAverageCharWidth() { return averageCharWidth; } + /** * Returns the descent of the font described by the receiver. A * font's <em>descent</em> is the distance from the baseline to the @@ -70,6 +74,7 @@ public int getAverageCharWidth() { public int getDescent() { return descent; } + /** * Returns the height of the font described by the receiver, * measured in pixels. A font's <em>height</em> is the sum of @@ -84,6 +89,7 @@ public int getDescent() { public int getHeight() { return height; } + /** * Returns the leading area of the font described by the * receiver. A font's <em>leading area</em> is the space @@ -94,6 +100,7 @@ public int getHeight() { public int getLeading() { return leading; } + /** * Returns an integer hash code for the receiver. Any two * objects which return <code>true</code> when passed to @@ -107,13 +114,5 @@ public int getLeading() { public int hashCode() { return ascent ^ descent ^ averageCharWidth ^ leading ^ height; } -public static FontMetrics carbon_new(int ascent, int descent, int averageCharWidth, int leading, int height) { - FontMetrics fontMetrics = new FontMetrics(); - fontMetrics.ascent = ascent; - fontMetrics.descent = descent; - fontMetrics.averageCharWidth = averageCharWidth; - fontMetrics.leading = leading; - fontMetrics.height = height; - return fontMetrics; -} + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java index 32fe654f7c..0489d2f174 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GC.java @@ -8,8 +8,9 @@ package org.eclipse.swt.graphics; */ import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.*; 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 @@ -29,27 +30,14 @@ public final class GC { * the handle to the OS device context * (Warning: This field is platform dependent) */ - public int handle; // a Mac CGrafPort + public int handle; Drawable drawable; GCData data; - - //---- AW - private MacRect fRect= new MacRect(); - private int[] fSavePort= new int[1]; - private int[] fSaveGWorld= new int[1]; - private int fSaveClip= OS.NewRgn(); - private boolean fIsFocused= false; - private int fLineWidth= 1; - private boolean fXorMode= false; - private int fDamageRgn; - private boolean fPendingClip; - - private int[] fContext= new int[1]; - //---- AW GC() { } + /** * Constructs a new instance of this class which has been * configured to draw on the specified drawable. Sets the @@ -71,49 +59,37 @@ GC() { * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li> * </ul> */ -public GC (Drawable drawable) { +public GC(Drawable drawable) { if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); GCData data = new GCData(); - int xGC = drawable.internal_new_GC(data); - init(drawable, data, xGC); + int gdkGC = drawable.internal_new_GC(data); + init(drawable, data, gdkGC); } -/** - * Copies a rectangular area of the receiver at the source - * position onto the receiver at the destination position. +/** + * Invokes platform specific functionality to allocate a new graphics context. + * <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> * - * @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 drawable the Drawable for the receiver. + * @param data the data for the receiver. * - * @exception SWTException <ul> - * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> - * </ul> + * @return a new <code>GC</code> + * + * @private */ -public void copyArea(int x, int y, int width, int height, int destX, int destY) { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (width <= 0 || height <= 0) return; - int deltaX = destX - x, deltaY = destY - y; - if (deltaX == 0 && deltaY == 0) return; - - Rectangle src= new Rectangle(x, y, width, height); - src= src.union(new Rectangle(destX, destY, width, height)); - MacRect r= new MacRect(src); - - try { - if (focus(true, null)) { - int rgn= OS.NewRgn(); - OS.ScrollRect(r.getData(), (short)deltaX, (short)deltaY, rgn); - OS.InvalWindowRgn(OS.GetWindowFromPort(handle), rgn); - OS.DisposeRgn(rgn); - } - } finally { - unfocus(true); - } +public static GC carbon_new(Drawable drawable, GCData data) { + GC gc = new GC(); + int context = drawable.internal_new_GC(data); + gc.init(drawable, data, context); + return gc; } + /** * Copies a rectangular area of the receiver at the specified * position into the image, which must be of type <code>SWT.BITMAP</code>. @@ -133,44 +109,154 @@ 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); - /* AW - Rectangle rect = image.getBounds(); - int xDisplay = data.display; - int xGC = OS.XCreateGC(xDisplay, image.pixmap, 0, null); - if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); - OS.XSetSubwindowMode (xDisplay, xGC, OS.IncludeInferiors); - OS.XCopyArea(xDisplay, data.drawable, image.pixmap, xGC, x, y, rect.width, rect.height, 0, 0); - OS.XFreeGC(xDisplay, xGC); - */ - System.out.println("GC.copyArea(Image): nyi"); + //NOT IMPLEMENTED } + +/** + * 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 srcX, int srcY, int width, int height, int destX, int destY) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (width <= 0 || height <= 0) return; + int deltaX = destX - srcX, deltaY = destY - srcY; + if (deltaX == 0 && deltaY == 0) return; + if (data.image != null) { + OS.CGContextSaveGState(handle); + OS.CGContextScaleCTM(handle, 1, -1); + OS.CGContextTranslateCTM(handle, 0, -(height + 2 * destY)); + CGRect rect = new CGRect(); + rect.x = destX; + rect.y = destY; + rect.width = width; + rect.height = height; + //NOT DONE - transparency + OS.CGContextDrawImage(handle, rect, data.image.handle); + OS.CGContextRestoreGState(handle); + return; + } + if (data.control != 0) { + int window = OS.GetControlOwner(data.control); + int port = OS.GetWindowPort(window); + + /* Calculate src and dest rectangles/regions */ + Rect rect = new Rect(); + OS.GetControlBounds(data.control, rect); + Rect srcRect = new Rect(); + OS.GetControlBounds(data.control, srcRect); + int left = srcRect.left + srcX; + int top = srcRect.top + srcY; + OS.SetRect(srcRect, (short)left, (short)top, (short)(left + width), (short)(top + height)); + int srcRgn = OS.NewRgn(); + OS.RectRgn(srcRgn, srcRect); + OS.SectRect(rect, srcRect, srcRect); + Rect destRect = new Rect (); + destRect.left = srcRect.left; + destRect.top = srcRect.top; + destRect.right = srcRect.right; + destRect.bottom = srcRect.bottom; + OS.OffsetRect(destRect, (short)deltaX, (short)deltaY); + int destRgn = OS.NewRgn(); + OS.RectRgn(destRgn, destRect); + + /* Copy bits with appropriated clipping region */ + if (!OS.EmptyRect(srcRect)) { + int clipRgn = data.visibleRgn; + if (data.clipRgn != 0) { + clipRgn = OS.NewRgn(); + OS.SectRgn(data.clipRgn, clipRgn, clipRgn); + } + + /* + * Feature in the Macintosh. ScrollRect() only copies bits + * that are inside the specified rectangle. This means that + * it is not possible to copy non overlaping bits without + * copying the bits in between the source and destination + * rectangles. The fix is to check if the source and + * destination rectangles are disjoint and use CopyBits() + * instead. + */ + boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY); + if (!disjoint && (deltaX == 0 || deltaY == 0)) { + int[] currentPort = new int[1]; + OS.GetPort(currentPort); + OS.SetPort(port); + int oldClip = OS.NewRgn(); + OS.GetClip(oldClip); + OS.SetClip(clipRgn); + OS.UnionRect(srcRect, destRect, rect); + OS.ScrollRect(rect, (short)deltaX, (short)deltaY, 0); + OS.SetClip(oldClip); + OS.DisposeRgn(oldClip); + OS.SetPort(currentPort[0]); + } else { + int portBitMap = OS.GetPortBitMapForCopyBits (port); + OS.CopyBits(portBitMap, portBitMap, srcRect, destRect, (short)OS.srcCopy, clipRgn); + OS.QDFlushPortBuffer(port, destRgn); + } + + if (clipRgn != data.visibleRgn) OS.DisposeRgn(clipRgn); + } + + /* Invalidate src and obscured areas */ + int invalRgn = OS.NewRgn(); + OS.DiffRgn(srcRgn, data.visibleRgn, invalRgn); + OS.OffsetRgn(invalRgn, (short)deltaX, (short)deltaY); + OS.DiffRgn(srcRgn, destRgn, srcRgn); + OS.UnionRgn(srcRgn, invalRgn, invalRgn); + OS.SectRgn(data.visibleRgn, invalRgn, invalRgn); + OS.InvalWindowRgn(window, invalRgn); + OS.DisposeRgn(invalRgn); + + /* Dispose src and dest regions */ + OS.DisposeRgn(destRgn); + OS.DisposeRgn(srcRgn); + } +} + /** * Disposes of the operating system resources associated with * the graphics context. Applications must dispose of all GCs * which they allocate. */ -public void dispose () { +public void dispose() { if (handle == 0) return; if (data.device.isDisposed()) return; - + /* Free resources */ int clipRgn = data.clipRgn; if (clipRgn != 0) OS.DisposeRgn(clipRgn); - Image image = data.image; - if (image != null) image.memGC = null; + if (image != null) { + image.memGC = null; +// if (image.transparentPixel != -1) image.createMask(); + } + int layout = data.layout; + if (layout != 0) OS.ATSUDisposeTextLayout(layout); + int style = data.style; + if (style != 0) OS.ATSUDisposeTextLayout(style); /* Dispose the GC */ drawable.internal_dispose_GC(handle, data); - data.clipRgn = 0; - data.font = null; + data.clipRgn = data.style = data.layout = 0; drawable = null; - data.device = null; data.image = null; data = null; handle = 0; } + /** * Draws the outline of a circular or elliptical arc * within the specified rectangular area. @@ -215,12 +301,16 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int end } if (width == 0 || height == 0 || endAngle == 0) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); - } - /* AW - OS.XDrawArc(data.display,data.drawable,handle,x,y,width,height,startAngle * 64 ,endAngle * 64); - */ - System.out.println("GC.drawArc"); + } + OS.CGContextBeginPath(handle); + OS.CGContextSaveGState(handle); + OS.CGContextTranslateCTM(handle, x + width / 2f, y + height / 2f); + OS.CGContextScaleCTM(handle, width / 2f, height / 2f); + OS.CGContextAddArc(handle, 0, 0, 1, -startAngle * (float)Math.PI / 180, -endAngle * (float)Math.PI / 180, true); + OS.CGContextRestoreGState(handle); + OS.CGContextStrokePath(handle); } + /** * Draws a rectangle, based on the specified arguments, which has * the appearance of the platform's <em>focus rectangle</em> if the @@ -238,40 +328,12 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int end * * @see #drawRectangle */ -public void drawFocus (int x, int y, int width, int height) { +public void drawFocus(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* - * When the drawable is not a widget, the highlight - * color is zero. - */ - /* AW - int highlightColor = 0; - int widget = OS.XtWindowToWidget (xDisplay, xDrawable); - if (widget != 0) { - int [] argList = {OS.XmNhighlightColor, 0}; - OS.XtGetValues (widget, argList, argList.length / 2); - highlightColor = argList [1]; - } - */ - - /* Draw the focus rectangle */ - if (width < 0) { - x = x + width; - width = -width; - } - if (height < 0) { - y = y + height; - height = -height; - } - /* AW - XGCValues values = new XGCValues (); - OS.XGetGCValues (xDisplay, handle, OS.GCForeground, values); - OS.XSetForeground (xDisplay, handle, highlightColor); - OS.XDrawRectangle (xDisplay, xDrawable, handle, x, y, width - 1, height - 1); - OS.XSetForeground (xDisplay, handle, values.foreground); - */ - //System.out.println("GC.drawFocus"); + //NOT DONE +// drawRectangle (x, y, width - 1, height - 1); } + /** * Draws the given image in the receiver at the specified * coordinates. @@ -297,6 +359,7 @@ public void drawImage(Image image, int x, int y) { 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 @@ -339,71 +402,52 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false); } -void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) { - MacRect bounds= new MacRect(); - OS.GetPixBounds(srcImage.pixmap, bounds.getData()); - int imgWidth = bounds.getWidth(); - int imgHeight = bounds.getHeight(); +void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) { + int imageHandle = srcImage.handle; + int imgWidth = OS.CGImageGetWidth(imageHandle); + int imgHeight = OS.CGImageGetHeight(imageHandle); 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 (srcImage.alpha == 0) // fully transparent - return; - - if (srcImage.pixmap == 0) - return; - int srcBits= OS.DerefHandle(srcImage.pixmap); - if (srcBits == 0) - return; - int destBits= OS.GetPortBitMapForCopyBits(handle); - if (destBits == 0) - return; - - try { - if (focus(true, null)) { - - MacRect ib= new MacRect(srcX, srcY, srcWidth, srcHeight); - fRect.set(destX, destY, destWidth, destHeight); - - OS.RGBBackColor((short)0xFFFF, (short)0xFFFF, (short)0xFFFF); - OS.RGBForeColor((short)0x0000, (short)0x0000, (short)0x0000); - - if (srcImage.alpha != -1 || srcImage.alphaData != null) { - - if (srcImage.alpha == 255) { // fully opaque - OS.CopyBits(srcBits, destBits, ib.getData(), fRect.getData(), (short)0, 0); - return; - } - - //OS.CopyDeepMask(srcBits, maskBits, destBits, ib.getData(), ib.getData(), fRect.getData(), (short)0, 0); - System.out.println("GC.drawImage: alpha drawing not nyi"); - - } else if (srcImage.transparentPixel != -1 || srcImage.mask != 0) { - /* Generate the mask if necessary. */ - if (srcImage.transparentPixel != -1) srcImage.createMask(); - - int maskBits= srcImage.mask != 0 ? OS.DerefHandle(srcImage.mask) : 0; - if (maskBits != 0) - OS.CopyMask(srcBits, maskBits, destBits, ib.getData(), ib.getData(), fRect.getData()); - - /* Destroy the image mask if there is a GC created on the image */ - if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask(); - - } else { - OS.CopyBits(srcBits, destBits, ib.getData(), fRect.getData(), (short)0, 0); - } - } - } finally { - unfocus(true); - } + OS.CGContextSaveGState(handle); + OS.CGContextScaleCTM(handle, 1, -1); + OS.CGContextTranslateCTM(handle, 0, -(destHeight + 2 * destY)); + CGRect rect = new CGRect(); + rect.x = destX; + rect.y = destY; + rect.width = destWidth; + rect.height = destHeight; + if (simple) { + OS.CGContextDrawImage(handle, rect, imageHandle); + } else { + int width = OS.CGImageGetWidth(imageHandle); + int height = OS.CGImageGetHeight(imageHandle); + int bpc = OS.CGImageGetBitsPerComponent(imageHandle); + int bpp = OS.CGImageGetBitsPerPixel(imageHandle); + int bpr = OS.CGImageGetBytesPerRow(imageHandle); + int colorspace = OS.CGImageGetColorSpace(imageHandle); + int alphaInfo = OS.CGImageGetAlphaInfo(imageHandle); + int data = srcImage.data + (srcY * bpr) + srcX * 4; + int provider = OS.CGDataProviderCreateWithData(0, data, srcHeight * bpr, 0); + if (provider == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int subImage = OS.CGImageCreate(srcWidth, srcHeight, bpc, bpp, bpr, colorspace, alphaInfo, provider, null, false, 0); + OS.CGDataProviderRelease(provider); + if (subImage == 0) SWT.error(SWT.ERROR_NO_HANDLES); + OS.CGContextDrawImage(handle, rect, subImage); + OS.CGImageRelease(subImage); + } + OS.CGContextRestoreGState(handle); } + /** * Draws a line, using the foreground color, between the points * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>). @@ -417,19 +461,14 @@ void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void drawLine (int x1, int y1, int x2, int y2) { +public void drawLine(int x1, int y1, int x2, int y2) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - try { - if (focus(true, null)) { - MacUtil.RGBForeColor(data.foreground); - OS.PenSize((short) fLineWidth, (short) fLineWidth); - OS.MoveTo((short)x1, (short)y1); - OS.LineTo((short)x2, (short)y2); - } - } finally { - unfocus(true); - } + OS.CGContextBeginPath(handle); + OS.CGContextMoveToPoint(handle, x1, y1); + OS.CGContextAddLineToPoint(handle, x2, y2); + OS.CGContextStrokePath(handle); } + /** * Draws the outline of an oval, using the foreground color, * within the specified rectangular area. @@ -461,17 +500,16 @@ public void drawOval(int x, int y, int width, int height) { y = y + height; height = -height; } - try { - if (focus(true, null)) { - MacUtil.RGBForeColor(data.foreground); - OS.PenSize((short) fLineWidth, (short) fLineWidth); - fRect.set(x, y, width+1, height+1); - OS.FrameOval(fRect.getData()); - } - } finally { - unfocus(true); - } + OS.CGContextBeginPath(handle); + OS.CGContextSaveGState(handle); + OS.CGContextTranslateCTM(handle, x + width / 2f, y + height / 2f); + OS.CGContextScaleCTM(handle, width / 2f, height / 2f); + OS.CGContextMoveToPoint(handle, 1, 0); + OS.CGContextAddArc(handle, 0, 0, 1, 0, (float)(2 *Math.PI), true); + OS.CGContextRestoreGState(handle); + OS.CGContextStrokePath(handle); } + /** * Draws the closed polygon which is defined by the specified array * of integer coordinates, using the receiver's foreground color. The array @@ -492,45 +530,16 @@ public void drawOval(int x, int y, int width, int height) { public void drawPolygon(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - - // Motif does not have a native drawPolygon() call. Instead we ensure - // that the first and last points are the same and call drawPolyline(). - - int length = pointArray.length; - - // Need at least 3 points to define the polygon. If 2 or fewer points - // passed in, it is either a line or point so just call drawPolyline(). - // Check what happens when XOR is implemented. We may not be able to - // do this optimization. - - if (length < 4) { - drawPolyline(pointArray); - return; - } - - // If first and last points are the same, the polygon is already closed. - // Just call drawPolyline(). - // - // Check what happens when XOR is implemented. We may not be able to - // do this optimization. - - if (pointArray[0] == pointArray[length - 2] && (pointArray[1] == pointArray[length - 1])) { - drawPolyline(pointArray); - return; + float[] points = new float[pointArray.length]; + for (int i=0; i<points.length; i++) { + points[i] = pointArray[i]; } - - // Grow the list of points by one element and make sure the first and last - // points are the same. This will close the polygon and we can use the - // drawPolyline() call. - - int newPoints[] = new int[length + 2]; - for (int i = 0; i < length ; i++) - newPoints[i] = pointArray[i]; - newPoints[length] = pointArray[0]; - newPoints[length + 1] = pointArray[1]; - - drawPolyline(newPoints); + OS.CGContextBeginPath(handle); + OS.CGContextAddLines(handle, points, points.length / 2); + OS.CGContextClosePath(handle); + OS.CGContextStrokePath(handle); } + /** * Draws the polyline which is defined by the specified array * of integer coordinates, using the receiver's foreground color. The array @@ -551,38 +560,15 @@ public void drawPolygon(int[] pointArray) { public void drawPolyline(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - /* AW - short[] xPoints = new short[pointArray.length]; - for (int i = 0; i<pointArray.length;i++) { - xPoints[i] = (short) pointArray[i]; + float[] points = new float[pointArray.length]; + for (int i=0; i<points.length; i++) { + points[i] = pointArray[i]; } - OS.XDrawLines(data.display,data.drawable,handle,xPoints,xPoints.length / 2, OS.CoordModeOrigin); - */ - - if (pointArray.length < 4) - return; - - int poly= 0; - try { - if (focus(true, null)) { - - poly= OS.OpenPoly(); - OS.MoveTo((short)pointArray[0], (short)pointArray[1]); - for (int i= 2; i < pointArray.length; i+= 2) - OS.LineTo((short)pointArray[i], (short)pointArray[i+1]); - OS.ClosePoly(); - - MacUtil.RGBForeColor(data.foreground); - OS.PenSize((short) fLineWidth, (short) fLineWidth); - OS.FramePoly(poly); - } - } finally { - unfocus(true); - } - - if (poly != 0) - OS.KillPoly(poly); + OS.CGContextBeginPath(handle); + OS.CGContextAddLines(handle, points, points.length / 2); + OS.CGContextStrokePath(handle); } + /** * Draws the outline of the rectangle specified by the arguments, * using the receiver's foreground color. The left and right edges @@ -598,7 +584,7 @@ public void drawPolyline(int[] pointArray) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void drawRectangle (int x, int y, int width, int height) { +public void drawRectangle(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0) { x = x + width; @@ -608,17 +594,14 @@ public void drawRectangle (int x, int y, int width, int height) { y = y + height; height = -height; } - try { - if (focus(true, null)) { - MacUtil.RGBForeColor(data.foreground); - OS.PenSize((short) fLineWidth, (short) fLineWidth); - fRect.set(x-fLineWidth/2, y-fLineWidth/2, width+fLineWidth, height+fLineWidth); - OS.FrameRect(fRect.getData()); - } - } finally { - unfocus(true); - } + CGRect rect = new CGRect(); + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + OS.CGContextStrokeRect(handle, rect); } + /** * Draws the outline of the specified rectangle, using the receiver's * foreground color. The left and right edges of the rectangle are at @@ -635,10 +618,11 @@ public void drawRectangle (int x, int y, int width, int height) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void drawRectangle (Rectangle rect) { +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 @@ -658,27 +642,28 @@ public void drawRectangle (Rectangle rect) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { +public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) { 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; - } - try { - if (focus(true, null)) { - MacUtil.RGBForeColor(data.foreground); - OS.PenSize((short) fLineWidth, (short) fLineWidth); - fRect.set(x, y, width+1, height+1); - OS.FrameRoundRect(fRect.getData(), (short)arcWidth, (short)arcHeight); - } - } finally { - unfocus(true); + if (arcWidth == 0 || arcHeight == 0) { + drawRectangle(x, y, width, height); + return; } + OS.CGContextBeginPath(handle); + OS.CGContextSaveGState(handle); + OS.CGContextTranslateCTM(handle, x, y); + OS.CGContextScaleCTM(handle, arcWidth, arcHeight); + float fw = width / (float)arcWidth; + float fh = height / (float)arcHeight; + OS.CGContextMoveToPoint(handle, fw, fh/2); + OS.CGContextAddArcToPoint(handle, fw, fh, fw/2, fh, 1); + OS.CGContextAddArcToPoint(handle, 0, fh, 0, fh/2, 1); + OS.CGContextAddArcToPoint(handle, 0, 0, fw/2, 0, 1); + OS.CGContextAddArcToPoint(handle, fw, 0, fw, fh/2, 1); + OS.CGContextClosePath(handle); + OS.CGContextRestoreGState(handle); + OS.CGContextStrokePath(handle); } + /** * Draws the given string, using the receiver's current font and * foreground color. No tab expansion or carriage return processing @@ -700,6 +685,7 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt 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 @@ -720,44 +706,26 @@ public void drawString (String string, int x, int y) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void drawString (String string, int x, int y, boolean isTransparent) { +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); - /* AW - byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true); - int xmString = OS.XmStringCreate (buffer, OS.XmFONTLIST_DEFAULT_TAG); - if (isTransparent) { - OS.XmStringDraw (data.display, data.drawable, data.fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null); - } else { - OS.XmStringDrawImage (data.display, data.drawable, data.fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null); - } -// OS.XmStringDrawUnderline (display, drawable, fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null, 0); - OS.XmStringFree (xmString); - */ - try { - if (focus(true, null)) { - installFont(); - MacUtil.RGBForeColor(data.foreground); - if (isTransparent) { - OS.TextMode(OS.srcOr); - } else { - if ((data.background & 0xff000000) == 0) { - MacUtil.RGBBackColor(data.background); - OS.TextMode(OS.srcCopy); - } else { - //System.out.println("GC.drawString: " + Integer.toHexString(data.background)); - OS.TextMode(OS.srcOr); - } - } - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - OS.MoveTo((short)x, (short)(y+fontInfo[0])); - OS.DrawText(string, data.font.fID, data.font.fSize, data.font.fFace); - } - } finally { - unfocus(true); - } + int length = string.length(); + if (length == 0) return; + OS.CGContextSaveGState(handle); + OS.CGContextScaleCTM(handle, 1, -1); + OS.CGContextTranslateCTM(handle, 0, -data.fontAscent); + OS.CGContextSetFillColor(handle, data.foreground); + char[] buffer = new char[length]; + string.getChars(0, length, buffer, 0); + int ptr = OS.NewPtr(length * 2); + OS.memcpy(ptr, buffer, length * 2); + OS.ATSUSetTextPointerLocation(data.layout, ptr, 0, length, length); + OS.ATSUSetRunStyle(data.layout, data.style, 0, length); + OS.ATSUDrawText(data.layout, 0, length, x << 16, -y << 16); + OS.DisposePtr(ptr); + OS.CGContextRestoreGState(handle); } + /** * Draws the given string, using the receiver's current font and * foreground color. Tab expansion and carriage return processing @@ -776,9 +744,10 @@ public void drawString (String string, int x, int y, boolean isTransparent) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void drawText (String string, int x, int y) { +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 @@ -799,11 +768,12 @@ public void drawText (String string, int x, int y) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void drawText (String string, int x, int y, boolean isTransparent) { +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 @@ -841,61 +811,8 @@ public void drawText (String string, int x, int y, boolean isTransparent) { 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); - - /* AW - if (data.renderTable == 0) createRenderTable(); - int renderTable = data.renderTable; - - char mnemonic=0; - int tableLength = 0; - Device device = data.device; - int[] parseTable = new int[2]; - char[] text = new char[string.length()]; - string.getChars(0, text.length, text, 0); - if ((flags & SWT.DRAW_DELIMITER) != 0) parseTable[tableLength++] = device.crMapping; - if ((flags & SWT.DRAW_TAB) != 0) parseTable[tableLength++] = device.tabMapping; - if ((flags & SWT.DRAW_MNEMONIC) != 0) mnemonic = stripMnemonic(text); - - String codePage = getCodePage(); - byte[] buffer = Converter.wcsToMbcs(codePage, text, true); - int xmString = OS.XmStringParseText(buffer, 0, OS.XmFONTLIST_DEFAULT_TAG, OS.XmCHARSET_TEXT, parseTable, tableLength, 0); - if (mnemonic != 0) { - byte [] buffer1 = Converter.wcsToMbcs(codePage, new char[]{mnemonic}, true); - int xmStringUnderline = OS.XmStringCreate (buffer1, OS.XmFONTLIST_DEFAULT_TAG); - OS.XmStringDrawUnderline(data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null, xmStringUnderline); - OS.XmStringFree(xmStringUnderline); - } else { - if ((flags & SWT.DRAW_TRANSPARENT) != 0) { - OS.XmStringDraw(data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null); - } else { - OS.XmStringDrawImage(data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null); - } - } - OS.XmStringFree(xmString); - */ - try { - if (focus(true, null)) { - installFont(); - MacUtil.RGBForeColor(data.foreground); - if ((flags & SWT.DRAW_TRANSPARENT) != 0) { - OS.TextMode(OS.srcOr); - } else { - if ((data.background & 0xff000000) == 0) { - MacUtil.RGBBackColor(data.background); - OS.TextMode(OS.srcCopy); - } else { - //System.out.println("GC.drawText: " + Integer.toHexString(data.background)); - OS.TextMode(OS.srcOr); - } - } - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - OS.MoveTo((short)x, (short)(y+fontInfo[0])); - OS.DrawText(string, data.font.fID, data.font.fSize, data.font.fFace); - } - } finally { - unfocus(true); - } + //NOT DONE + drawString(string, x, y); } /** @@ -908,11 +825,12 @@ public void drawText (String string, int x, int y, int flags) { * * @see #hashCode */ -public boolean equals (Object object) { +public boolean equals(Object object) { if (object == this) return true; if (!(object instanceof GC)) return false; return handle == ((GC)object).handle; } + /** * Fills the interior of a circular or elliptical arc within * the specified rectangular area, with the receiver's background @@ -961,14 +879,15 @@ public void fillArc(int x, int y, int width, int height, int startAngle, int end if (width == 0 || height == 0 || endAngle == 0) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - /* AW - XGCValues values = new XGCValues (); - OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values); - OS.XSetForeground (xDisplay, handle, values.background); - OS.XFillArc(xDisplay,data.drawable,handle,x,y,width,height,startAngle * 64 ,endAngle * 64); - OS.XSetForeground (xDisplay, handle, values.foreground); - */ - System.out.println("GC.fillArc"); + OS.CGContextBeginPath(handle); + OS.CGContextSaveGState(handle); + OS.CGContextTranslateCTM(handle, x + width / 2f, y + height / 2f); + OS.CGContextScaleCTM(handle, width / 2f, height / 2f); + OS.CGContextMoveToPoint(handle, 0, 0); + OS.CGContextAddArc(handle, 0, 0, 1, -startAngle * (float)Math.PI / 180, -endAngle * (float)Math.PI / 180, true); + OS.CGContextClosePath(handle); + OS.CGContextRestoreGState(handle); + OS.CGContextFillPath(handle); } /** @@ -995,110 +914,35 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if ((width == 0) || (height == 0)) return; - try { - if (! focus(true, null)) - return; - - /* AW - int xDisplay = data.display; - int xScreenNum = OS.XDefaultScreen(xDisplay); - XGCValues values = new XGCValues(); - */ - int fromColor, toColor; - /* AW - OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values); - fromColor = values.foreground; - toColor = values.background; - */ - fromColor = data.foreground; - 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 = fromColor; - fromColor = toColor; - toColor = t; - } - - if (fromColor == toColor) { - /* AW - OS.XFillRectangle(xDisplay, data.drawable, handle, x, y, width, height); - */ - MacUtil.RGBForeColor(data.foreground); - fRect.set(x, y, width, height); - OS.PaintRect(fRect.getData()); - return; - } - /* X Window deals with a virtually limitless array of color formats - * but we only distinguish between paletted and direct modes - */ - /* AW - final int xScreen = OS.XDefaultScreenOfDisplay(xDisplay); - final int xVisual = OS.XDefaultVisual(xDisplay, xScreenNum); - Visual visual = new Visual(); - OS.memmove(visual, xVisual, visual.sizeof); - final int depth = OS.XDefaultDepthOfScreen(xScreen); - */ - - int depth= getCurrentScreenDepth(); - final boolean directColor = (depth > 8); - - // This code is intentionally commented since elsewhere in SWT we - // assume that depth <= 8 means we are in a paletted mode though - // this is not always the case. - //final boolean directColor = (visual.c_class == OS.TrueColor) || (visual.c_class == OS.DirectColor); - - /* AW - XColor xColor = new XColor(); - xColor.pixel = fromColor; - OS.XQueryColor(xDisplay, data.colormap, xColor); - final RGB fromRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8); - xColor.pixel = toColor; - OS.XQueryColor(xDisplay, data.colormap, xColor); - final RGB toRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8); - */ - - RGB fromRGB = Color.carbon_new(data.device, fromColor, false).getRGB(); - RGB toRGB = Color.carbon_new(data.device, toColor, false).getRGB(); - - final int redBits, greenBits, blueBits; - if (directColor) { - // RGB mapped display - redBits = getChannelWidth(0x00ff0000 /* AW visual.red_mask */); - greenBits = getChannelWidth(0x0000ff00 /* AW visual.green_mask */); - blueBits = getChannelWidth(0x000000ff /* AW visual.blue_mask */); - } else { - // Index display - redBits = greenBits = blueBits = 0; - } - - ImageData.fillGradientRectangle(this, data.device, - x, y, width, height, vertical, fromRGB, toRGB, - redBits, greenBits, blueBits); - - } finally { - unfocus(true); - } -} + /* Rewrite this to use GdkPixbuf */ -/** - * Computes the required channel width (depth) from a mask. - */ -static int getChannelWidth(int mask) { - int width = 0; - while (mask != 0) { - width += (mask & 1); - mask >>>= 1; + RGB backgroundRGB, foregroundRGB; + backgroundRGB = getBackground().getRGB(); + foregroundRGB = getForeground().getRGB(); + + RGB fromRGB, toRGB; + fromRGB = foregroundRGB; + toRGB = backgroundRGB; + 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) { + fromRGB = backgroundRGB; + toRGB = foregroundRGB; + } + if (fromRGB == toRGB) { + fillRectangle(x, y, width, height); + return; } - return width; + ImageData.fillGradientRectangle(this, data.device, + x, y, width, height, vertical, fromRGB, toRGB, + 8, 8, 8); } /** @@ -1117,7 +961,7 @@ static int getChannelWidth(int mask) { * * @see #drawOval */ -public void fillOval (int x, int y, int width, int height) { +public void fillOval(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0) { x = x + width; @@ -1127,20 +971,17 @@ public void fillOval (int x, int y, int width, int height) { y = y + height; height = -height; } - try { - if (focus(true, null)) { - if ((data.background & 0xff000000) == 0) { - MacUtil.RGBForeColor(data.background); - fRect.set(x, y, width, height); - OS.PaintOval(fRect.getData()); - } else { - // System.out.println("GC.fillOval: " + Integer.toHexString(data.background)); - } - } - } finally { - unfocus(true); - } + OS.CGContextBeginPath(handle); + OS.CGContextSaveGState(handle); + OS.CGContextTranslateCTM(handle, x + width / 2f, y + height / 2f); + OS.CGContextScaleCTM(handle, width / 2f, height / 2f); + OS.CGContextMoveToPoint(handle, 1, 0); + OS.CGContextAddArc(handle, 0, 0, 1, 0, (float)(Math.PI * 2), false); + OS.CGContextClosePath(handle); + OS.CGContextRestoreGState(handle); + OS.CGContextFillPath(handle); } + /** * Fills the interior of the closed polygon which is defined by the * specified array of integer coordinates, using the receiver's @@ -1163,37 +1004,16 @@ public void fillOval (int x, int y, int width, int height) { public void fillPolygon(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - - /* AW - short[] xPoints = new short[pointArray.length]; - for (int i = 0; i<pointArray.length;i++) { - xPoints[i] = (short) pointArray[i]; - } - int xDisplay = data.display; - XGCValues values = new XGCValues (); - OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values); - OS.XSetForeground (xDisplay, handle, values.background); - OS.XFillPolygon(xDisplay, data.drawable, handle,xPoints, xPoints.length / 2, OS.Complex, OS.CoordModeOrigin); - OS.XSetForeground (xDisplay, handle, values.foreground); - */ - int poly= 0; - try { - if (focus(true, null)) { - poly= OS.OpenPoly(); - OS.MoveTo((short)pointArray[0], (short)pointArray[1]); - for (int i= 2; i < pointArray.length; i+= 2) - OS.LineTo((short)pointArray[i], (short)pointArray[i+1]); - OS.ClosePoly(); - - MacUtil.RGBForeColor(data.background); - OS.PaintPoly(poly); - } - } finally { - unfocus(true); + float[] points = new float[pointArray.length]; + for (int i=0; i<points.length; i++) { + points[i] = pointArray[i]; } - if (poly != 0) - OS.KillPoly(poly); + OS.CGContextBeginPath(handle); + OS.CGContextAddLines(handle, points, points.length / 2); + OS.CGContextClosePath(handle); + OS.CGContextFillPath(handle); } + /** * Fills the interior of the rectangle specified by the arguments, * using the receiver's background color. @@ -1209,7 +1029,7 @@ public void fillPolygon(int[] pointArray) { * * @see #drawRectangle */ -public void fillRectangle (int x, int y, int width, int height) { +public void fillRectangle(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0) { x = x + width; @@ -1219,27 +1039,14 @@ public void fillRectangle (int x, int y, int width, int height) { y = y + height; height = -height; } - try { - if (focus(true, null)) { - fRect.set(x, y, width, height); - if ((data.background & 0xFF000000) == 0) { - MacUtil.RGBForeColor(data.background); - OS.PaintRect(fRect.getData()); - } else { - short depth= getCurrentScreenDepth(); - int[] state= new int[1]; - OS.GetThemeDrawingState(state); - //OS.SetThemeBackground(OS.kThemeBrushDialogBackgroundActive, depth, true); - if (data.controlHandle != 0) - OS.SetUpControlBackground(data.controlHandle, depth, true); - OS.EraseRect(fRect.getData()); - OS.SetThemeDrawingState(state[0], true); - } - } - } finally { - unfocus(true); - } + CGRect rect = new CGRect(); + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + OS.CGContextFillRect(handle, rect); } + /** * Fills the interior of the specified rectangle, using the receiver's * background color. @@ -1255,10 +1062,12 @@ public void fillRectangle (int x, int y, int width, int height) { * * @see #drawRectangle */ -public void fillRectangle (Rectangle rect) { +public void fillRectangle(Rectangle rect) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); 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. @@ -1276,22 +1085,28 @@ public void fillRectangle (Rectangle rect) { * * @see #drawRoundRectangle */ -public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { +public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - try { - if (focus(true, null)) { - if ((data.background & 0xff000000) == 0) { - MacUtil.RGBForeColor(data.background); - fRect.set(x, y, width, height); - OS.PaintRoundRect(fRect.getData(), (short)arcWidth, (short)arcHeight); - } else { - // System.out.println("GC.fillRoundRectangle: " + Integer.toHexString(data.background)); - } - } - } finally { - unfocus(true); + if (arcWidth == 0 || arcHeight == 0) { + fillRectangle(x, y, width, height); + return; } + OS.CGContextBeginPath(handle); + OS.CGContextSaveGState(handle); + OS.CGContextTranslateCTM(handle, x, y); + OS.CGContextScaleCTM(handle, arcWidth, arcHeight); + float fw = width / (float)arcWidth; + float fh = height / (float)arcHeight; + OS.CGContextMoveToPoint(handle, fw, fh/2); + OS.CGContextAddArcToPoint(handle, fw, fh, fw/2, fh, 1); + OS.CGContextAddArcToPoint(handle, 0, fh, 0, fh/2, 1); + OS.CGContextAddArcToPoint(handle, 0, 0, fw/2, 0, 1); + OS.CGContextAddArcToPoint(handle, fw, 0, fw, fh/2, 1); + OS.CGContextClosePath(handle); + OS.CGContextRestoreGState(handle); + OS.CGContextFillPath(handle); } + /** * Returns the <em>advance width</em> of the specified character in * the font which is currently selected into the receiver. @@ -1307,16 +1122,12 @@ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidt * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public int getAdvanceWidth(char ch) { +public int getAdvanceWidth(char ch) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - try { - focus(false, null); - installFont(); - return OS.CharWidth((byte) ch); - } finally { - unfocus(false); - } + //NOT DONE + return stringExtent(new String(new char[]{ch})).x; } + /** * Returns the background color. * @@ -1328,16 +1139,9 @@ public int getAdvanceWidth(char ch) { */ public Color getBackground() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* AW - int xDisplay = data.display; - XGCValues values = new XGCValues(); - OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values); - XColor xColor = new XColor(); - xColor.pixel = values.background; - OS.XQueryColor(xDisplay,data.colormap,xColor); - */ - return Color.carbon_new(data.device, data.background, false); + return Color.carbon_new (data.device, data.background); } + /** * Returns the width of the specified character in the font * selected into the receiver. @@ -1356,9 +1160,10 @@ public Color getBackground() { */ public int getCharWidth(char ch) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - System.out.println("GC.getCharWidth"); - return 0; + //NOT DONE + return stringExtent(new String(new char[]{ch})).x; } + /** * Returns the bounding rectangle of the receiver's clipping * region. If no clipping region is set, the return value @@ -1373,33 +1178,28 @@ public int getCharWidth(char ch) { */ public Rectangle getClipping() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* AW - int clipRgn = data.clipRgn; - if (clipRgn == 0) { - int[] width = new int[1]; int[] height = new int[1]; - int[] unused = new int[1]; - OS.XGetGeometry(data.display, data.drawable, unused, unused, unused, width, height, unused, unused); - return new Rectangle(0, 0, width[0], height[0]); - } - XRectangle rect = new XRectangle(); - OS.XClipBox(clipRgn, rect); - return new Rectangle(rect.x, rect.y, rect.width, rect.height); - */ - MacRect bounds= new MacRect(); if (data.clipRgn == 0) { - if (data.controlHandle != 0) { - OS.GetControlBounds(data.controlHandle, bounds.getData()); - return new Rectangle(0, 0, bounds.getWidth(), bounds.getHeight()); + int width = 0, height = 0; + if (data.control != 0) { + Rect bounds = new Rect(); + OS.GetControlBounds(data.control, bounds); + width = bounds.right - bounds.left; + height = bounds.bottom - bounds.top; } if (data.image != null) { - return data.image.getBounds(); - } - System.out.println("GC.getClipping(): should not happen"); - return new Rectangle(0, 0, 100, 100); + int image = data.image.handle; + width = OS.CGImageGetWidth(image); + height = OS.CGImageGetHeight(image); + } + return new Rectangle(0, 0, width, height); } - OS.GetRegionBounds(data.clipRgn, bounds.getData()); - return bounds.toRectangle(); + Rect bounds = new Rect(); + OS.GetRegionBounds(data.clipRgn, bounds); + int width = bounds.right - bounds.left; + int height = bounds.bottom - bounds.top; + return new Rectangle(bounds.left, bounds.top, width, height); } + /** * Sets the region managed by the argument to the current * clipping region of the receiver. @@ -1413,38 +1213,28 @@ public Rectangle getClipping() { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void getClipping(Region region) { +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.handle == 0) - region.handle= OS.NewRgn(); - if (data.clipRgn == 0) { - if (data.controlHandle != 0) { - OS.GetControlRegion(data.controlHandle, OS.kWindowContentRgn, region.handle); - } else - System.out.println("GC.getClipping(Region): nyi"); - } else { - OS.CopyRgn(data.clipRgn, region.handle); - } - - /* AW - if (clipRgn == 0) { - int[] width = new int[1]; int[] height = new int[1]; - int[] unused = new int[1]; - OS.XGetGeometry(data.display, data.drawable, unused, unused, unused, width, height, unused, unused); - OS.XSubtractRegion (hRegion, hRegion, hRegion); - XRectangle rect = new XRectangle(); - rect.x = 0; rect.y = 0; - rect.width = (short)width[0]; rect.height = (short)height[0]; - OS.XUnionRectWithRegion(rect, hRegion, hRegion); + int width = 0, height = 0; + if (data.control != 0) { + Rect bounds = new Rect(); + OS.GetControlBounds(data.control, bounds); + width = bounds.right - bounds.left; + height = bounds.bottom - bounds.top; + } + if (data.image != null) { + int image = data.image.handle; + width = OS.CGImageGetWidth(image); + height = OS.CGImageGetHeight(image); + } + OS.SetRectRgn(region.handle, (short) 0, (short) 0, (short) width, (short) height); return; } - OS.XSubtractRegion (hRegion, hRegion, hRegion); - OS.XUnionRegion (clipRgn, hRegion, hRegion); - */ + OS.CopyRgn(data.clipRgn, region.handle); } + /** * Returns the font currently being used by the receiver * to draw and measure text. @@ -1455,21 +1245,11 @@ public void getClipping(Region region) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public Font getFont () { +public Font getFont() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return Font.carbon_new(data.device, data.font); -} -int getFontHeight () { - try { - focus(false, null); - installFont(); - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - return fontInfo[0] + fontInfo[1]; - } finally { - unfocus(false); - } + return data.font; } + /** * Returns a FontMetrics which contains information * about the font currently being used by the receiver @@ -1483,19 +1263,21 @@ int getFontHeight () { */ public FontMetrics getFontMetrics() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - - try { - focus(false, null); - installFont(); - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - String s= "abcdefghijklmnopqrstuvwxyz"; - int width= OS.TextWidth(s, data.font.fID, data.font.fSize, data.font.fFace) / 26; - return FontMetrics.carbon_new(fontInfo[0], fontInfo[1], width, fontInfo[3], fontInfo[0]+fontInfo[1]); - } finally { - unfocus(false); - } + Font font = data.font; + FontInfo info = new FontInfo(); + OS.FetchFontInfo(font.id, font.size, font.style, info); + FontMetrics fm = new FontMetrics(); + fm.ascent = info.ascent; + fm.descent = info.descent; + fm.leading = info.leading; + /* This code is intentionaly comment. Not right for fixed width fonts. */ + //fm.averageCharWidth = info.widMax / 3; + String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + fm.averageCharWidth = stringExtent(s).x / s.length(); + fm.height = fm.ascent + fm.descent; + return fm; } + /** * Returns the receiver's foreground color. * @@ -1505,19 +1287,11 @@ public FontMetrics getFontMetrics() { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public Color getForeground() { - if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* AW - int xDisplay = data.display; - XGCValues values = new XGCValues(); - OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values); - XColor xColor = new XColor(); - xColor.pixel = values.foreground; - OS.XQueryColor(xDisplay,data.colormap,xColor); - return Color.motif_new(data.device, xColor); - */ - return Color.carbon_new(data.device, data.foreground, false); +public Color getForeground() { + if (handle == 0) SWT.error(SWT.ERROR_WIDGET_DISPOSED); + return Color.carbon_new(data.device, data.foreground); } + /** * Returns the receiver's line style, which will be one * of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>, @@ -1534,6 +1308,7 @@ 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, @@ -1548,13 +1323,9 @@ public int getLineStyle() { */ public int getLineWidth() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* AW - XGCValues values = new XGCValues(); - OS.XGetGCValues(data.display, handle, OS.GCLineWidth, values); - return values.line_width; - */ - return fLineWidth; + return data.lineWidth; } + /** * Returns <code>true</code> if this GC is drawing in the mode * where the resulting color in the destination is the @@ -1571,13 +1342,9 @@ public int getLineWidth() { */ public boolean getXORMode() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* AW - XGCValues values = new XGCValues (); - OS.XGetGCValues (data.display, handle, OS.GCFunction, values); - return values.function == OS.GXxor; - */ - return fXorMode; + return data.xorMode; } + /** * Returns an integer hash code for the receiver. Any two * objects which return <code>true</code> when passed to @@ -1592,17 +1359,36 @@ public boolean getXORMode() { * * @see #equals */ -public int hashCode () { +public int hashCode() { return handle; } -void init(Drawable drawable, GCData data, int xGC) { - /* AW - int xDisplay = data.display; - int foreground = data.foreground; - if (foreground != -1) OS.XSetForeground (xDisplay, xGC, foreground); - int background = data.background; - if (background != -1) OS.XSetBackground (xDisplay, xGC, background); - */ + +void init(Drawable drawable, GCData data, int context) { + int colorspace = data.device.colorspace; + OS.CGContextSetStrokeColorSpace(context, colorspace); + OS.CGContextSetFillColorSpace(context, colorspace); + float[] foreground = data.foreground; + if (foreground != null) OS.CGContextSetStrokeColor(context, foreground); + float[] background = data.background; + if (background != null) OS.CGContextSetFillColor(context, background); + + int[] buffer = new int[1]; + OS.ATSUCreateTextLayout(buffer); + if (buffer[0] == 0) SWT.error(SWT.ERROR_NO_HANDLES); + data.layout = buffer[0]; + OS.ATSUCreateStyle(buffer); + if (buffer[0] == 0) SWT.error(SWT.ERROR_NO_HANDLES); + data.style = buffer[0]; + + int ptr = OS.NewPtr(4); + buffer[0] = context; + OS.memcpy(ptr, buffer, 4); + int[] tags = new int[]{OS.kATSUCGContextTag}; + int[] sizes = new int[]{4}; + int[] values = new int[]{ptr}; + OS.ATSUSetLayoutControls(data.layout, tags.length, tags, sizes, values); + OS.DisposePtr(ptr); + Image image = data.image; if (image != null) { image.memGC = this; @@ -1611,14 +1397,16 @@ void init(Drawable drawable, GCData data, int xGC) { * the image. Destroy it so that it is regenerated when * necessary. */ - if (image.transparentPixel != -1) image.destroyMask(); +// if (image.transparentPixel != -1) image.destroyMask(); } this.drawable = drawable; this.data = data; - if (xGC == 0) - SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - handle = xGC; + handle = context; + + Font font = data.font; + if (font != null) setFont(font); } + /** * Returns <code>true</code> if the receiver has a clipping * region set into it, and <code>false</code> otherwise. @@ -1635,9 +1423,9 @@ void init(Drawable drawable, GCData data, int xGC) { */ public boolean isClipped() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - System.out.println("GC.isClipped: nyi"); return data.clipRgn != 0; } + /** * Returns <code>true</code> if the GC has been disposed, * and <code>false</code> otherwise. @@ -1651,12 +1439,7 @@ public boolean isClipped() { public boolean isDisposed() { return handle == 0; } -public static GC macosx_new(Drawable drawable, GCData data) { - GC gc = new GC(); - int xGC = drawable.internal_new_GC(data); - gc.init(drawable, data, xGC); - return gc; -} + /** * Sets the background color. The background color is used * for fill operations and as the background color when text @@ -1672,12 +1455,14 @@ public static GC macosx_new(Drawable drawable, GCData data) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void setBackground (Color color) { +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; + data.background = color.handle; + OS.CGContextSetFillColor(handle, color.handle); } + /** * Sets the area of the receiver which can be changed * by drawing operations to the rectangular area specified @@ -1692,13 +1477,13 @@ public void setBackground (Color color) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void setClipping (int x, int y, int width, int height) { +public void setClipping(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (data.clipRgn == 0) - data.clipRgn = OS.NewRgn (); - OS.SetRectRgn(data.clipRgn, (short) x, (short) y, (short) (x+width), (short) (y+height)); - fPendingClip= true; + if (data.clipRgn == 0) data.clipRgn = OS.NewRgn(); + OS.SetRectRgn(data.clipRgn, (short)x, (short)y, (short)(x + width), (short)(y + height)); + setCGClipping(); } + /** * Sets the area of the receiver which can be changed * by drawing operations to the rectangular area specified @@ -1710,18 +1495,22 @@ public void setClipping (int x, int y, int width, int height) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void setClipping (Rectangle rect) { +public void setClipping(Rectangle r) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (rect == null) { + if (r == null) { if (data.clipRgn != 0) { OS.DisposeRgn(data.clipRgn); - data.clipRgn= 0; + data.clipRgn = 0; + } else { + return; } - fPendingClip= true; - return; + } else { + if (data.clipRgn == 0) data.clipRgn = OS.NewRgn(); + OS.SetRectRgn(data.clipRgn, (short)r.x, (short)r.y, (short)(r.x + r.width), (short)(r.y + r.height)); } - setClipping (rect.x, rect.y, rect.width, rect.height); + setCGClipping(); } + /** * Sets the area of the receiver which can be changed * by drawing operations to the region specified @@ -1733,20 +1522,59 @@ public void setClipping (Rectangle rect) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void setClipping (Region region) { +public void setClipping(Region region) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (region == null) { if (data.clipRgn != 0) { - OS.DisposeRgn (data.clipRgn); + OS.DisposeRgn(data.clipRgn); data.clipRgn = 0; + } else { + return; } } else { - if (data.clipRgn == 0) - data.clipRgn = OS.NewRgn(); + if (data.clipRgn == 0) data.clipRgn = OS.NewRgn(); OS.CopyRgn(region.handle, data.clipRgn); } - fPendingClip= true; + setCGClipping(); +} + +void setCGClipping () { + if (data.control == 0) { + OS.CGContextScaleCTM(handle, 1, -1); + if (data.clipRgn != 0) { + OS.ClipCGContextToRegion(handle, new Rect(), data.clipRgn); + } else { + int rgn = OS.NewRgn(); + OS.SetRectRgn(rgn, (short)-32768, (short)-32768, (short)32767, (short)32767); + OS.ClipCGContextToRegion(handle, new Rect(), rgn); + OS.DisposeRgn(rgn); + } + OS.CGContextScaleCTM(handle, 1, -1); + return; + } + int window = OS.GetControlOwner(data.control); + int port = OS.GetWindowPort(window); + Rect rect = new Rect(); + OS.GetControlBounds(data.control, rect); + Rect portRect = new Rect(); + OS.GetPortBounds(port, portRect); + int portHeight = portRect.bottom - portRect.top; + OS.CGContextTranslateCTM(handle, -rect.left, portHeight - rect.top); + OS.CGContextScaleCTM(handle, 1, -1); + if (data.clipRgn != 0) { + int rgn = OS.NewRgn(); + OS.CopyRgn(data.clipRgn, rgn); + OS.OffsetRgn(rgn, rect.left, rect.top); + OS.SectRgn(data.visibleRgn, rgn, rgn); + OS.ClipCGContextToRegion(handle, portRect, rgn); + OS.DisposeRgn(rgn); + } else { + OS.ClipCGContextToRegion(handle, portRect, data.visibleRgn); + } + OS.CGContextScaleCTM(handle, 1, -1); + OS.CGContextTranslateCTM(handle, rect.left, -portHeight + rect.top); } + /** * Sets the font which will be used by the receiver * to draw and measure text to the argument. If the @@ -1762,15 +1590,27 @@ public void setClipping (Region region) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void setFont (Font font) { +public void setFont(Font font) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (font == null) { - data.font = data.device.systemFont; - } else { - if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - data.font = font.handle; - } + if (font == null) font = data.device.systemFont; + if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + data.font = font; + int ptr = OS.NewPtr(16); + OS.memcpy(ptr, new int[]{font.handle}, 4); + OS.memcpy(ptr + 4, new int[]{font.size << 16}, 4); + OS.memcpy(ptr + 8, new byte[]{(font.style & OS.bold) != 0 ? (byte)1 : 0}, 1); + OS.memcpy(ptr + 9, new byte[]{(font.style & OS.italic) != 0 ? (byte)1 : 0}, 1); + int[] tags = new int[]{OS.kATSUFontTag, OS.kATSUSizeTag, OS.kATSUQDBoldfaceTag, OS.kATSUQDItalicTag}; + int[] sizes = new int[]{4, 4, 1, 1}; + int[] values = new int[]{ptr, ptr + 4, ptr + 8, ptr + 9}; + OS.ATSUSetAttributes(data.style, tags.length, tags, sizes, values); + OS.DisposePtr(ptr); + FontInfo info = new FontInfo(); + OS.FetchFontInfo(font.id, font.size, font.style, info); + data.fontAscent = info.ascent; + data.fontDescent = info.descent; } + /** * Sets the foreground color. The foreground color is used * for drawing operations including when text is drawn. @@ -1785,12 +1625,14 @@ public void setFont (Font font) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void setForeground (Color color) { +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; + data.foreground = color.handle; + OS.CGContextSetStrokeColor(handle, color.handle); } + /** * 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>, @@ -1805,32 +1647,28 @@ public void setForeground (Color color) { */ public void setLineStyle(int lineStyle) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* AW - int xDisplay = data.display; switch (lineStyle) { case SWT.LINE_SOLID: - data.lineStyle = lineStyle; - OS.XSetLineAttributes(xDisplay, handle, 0, OS.LineSolid, OS.CapButt, OS.JoinMiter); - return; + OS.CGContextSetLineDash(handle, 0, null, 0); + break; case SWT.LINE_DASH: - OS.XSetDashes(xDisplay,handle,0, new byte[] {6, 2},2); + OS.CGContextSetLineDash(handle, 0, new float[]{18, 6}, 2); break; case SWT.LINE_DOT: - OS.XSetDashes(xDisplay,handle,0, new byte[] {3, 1},2); + OS.CGContextSetLineDash(handle, 0, new float[]{3, 3}, 2); break; case SWT.LINE_DASHDOT: - OS.XSetDashes(xDisplay,handle,0, new byte[] {6, 2, 3, 1},4); + OS.CGContextSetLineDash(handle, 0, new float[]{9, 6, 3, 6}, 4); break; case SWT.LINE_DASHDOTDOT: - OS.XSetDashes(xDisplay,handle,0, new byte[] {6, 2, 3, 1, 3, 1},6); + OS.CGContextSetLineDash(handle, 0, new float[]{9, 3, 3, 3, 3, 3}, 6); break; default: SWT.error(SWT.ERROR_INVALID_ARGUMENT); } data.lineStyle = lineStyle; - OS.XSetLineAttributes(xDisplay, handle, 0, OS.LineDoubleDash, OS.CapButt, OS.JoinMiter); - */ } + /** * Sets the width that will be used when drawing lines * for all of the figure drawing operations (that is, @@ -1845,17 +1683,10 @@ public void setLineStyle(int lineStyle) { */ public void setLineWidth(int width) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (data.lineStyle == SWT.LINE_SOLID) { - /* AW - OS.XSetLineAttributes(data.display, handle, width, OS.LineSolid, OS.CapButt, OS.JoinMiter); - */ - } else { - /* AW - OS.XSetLineAttributes(data.display, handle, width, OS.LineDoubleDash, OS.CapButt, OS.JoinMiter); - */ - } - fLineWidth= width; + data.lineWidth = width; + OS.CGContextSetLineWidth(handle, width); } + /** * If the argument is <code>true</code>, puts the receiver * in a drawing mode where the resulting color in the destination @@ -1872,14 +1703,10 @@ public void setLineWidth(int width) { */ public void setXORMode(boolean xor) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - /* AW - if (xor) - OS.XSetFunction(data.display, handle, OS.GXxor); - else - OS.XSetFunction(data.display, handle, OS.GXcopy); - */ - fXorMode= xor; + //NOT DONE + data.xorMode = xor; } + /** * Returns the extent of the given string. No tab * expansion or carriage return processing will be performed. @@ -1899,29 +1726,28 @@ public void setXORMode(boolean xor) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public Point stringExtent(String string) { +public Point stringExtent(String string) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (string.length () == 0) return new Point(0, getFontHeight()); - /* AW - byte[] buffer = Converter.wcsToMbcs(getCodePage (), string, true); - int xmString = OS.XmStringCreate(buffer, OS.XmFONTLIST_DEFAULT_TAG); - int fontList = data.fontList; - int width = OS.XmStringWidth(fontList, xmString); - int height = OS.XmStringHeight(fontList, xmString); - OS.XmStringFree(xmString); - */ - try { - focus(false, null); - installFont(); - int width= OS.TextWidth(string, data.font.fID, data.font.fSize, data.font.fFace); - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - return new Point(width, fontInfo[0] + fontInfo[1]); - } finally { - unfocus(false); - } + int length = string.length(); + if (length == 0) return new Point(0, data.fontAscent + data.fontDescent); + char[] buffer = new char[length]; + string.getChars(0, length, buffer, 0); + int ptr1 = OS.NewPtr(length * 2); + OS.memcpy(ptr1, buffer, length * 2); + OS.ATSUSetTextPointerLocation(data.layout, ptr1, 0, length, length); + OS.ATSUSetRunStyle(data.layout, data.style, 0, length); + int ptr2 = OS.NewPtr(ATSTrapezoid.sizeof); + OS.ATSUGetGlyphBounds(data.layout, 0, 0, 0, length, (short)OS.kATSUseDeviceOrigins, 1, ptr2, null); + OS.DisposePtr(ptr1); + ATSTrapezoid trapezoid = new ATSTrapezoid(); + OS.memcpy(trapezoid, ptr2, ATSTrapezoid.sizeof); + OS.DisposePtr(ptr2); + int width = (trapezoid.upperRight_x >> 16) - (trapezoid.upperLeft_x >> 16); + int height = (trapezoid.lowerRight_y >> 16) - (trapezoid.upperRight_y >> 16); + return new Point(width, height); } + /** * Returns the extent of the given string. Tab expansion and * carriage return processing are performed. @@ -1944,6 +1770,7 @@ public Point stringExtent(String string) { 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 @@ -1978,39 +1805,10 @@ public Point textExtent(String string) { 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 (string.length () == 0) return new Point(0, getFontHeight()); - - /* AW - if (data.renderTable == 0) createRenderTable(); - int renderTable = data.renderTable; - - int tableLength = 0; - Device device = data.device; - int[] parseTable = new int[2]; - char[] text = new char[string.length()]; - string.getChars(0, text.length, text, 0); - if ((flags & SWT.DRAW_DELIMITER) != 0) parseTable[tableLength++] = device.crMapping; - if ((flags & SWT.DRAW_TAB) != 0) parseTable[tableLength++] = device.tabMapping; - if ((flags & SWT.DRAW_MNEMONIC) != 0) stripMnemonic(text); - - byte[] buffer = Converter.wcsToMbcs(getCodePage(), text, true); - int xmString = OS.XmStringParseText(buffer, 0, OS.XmFONTLIST_DEFAULT_TAG, OS.XmCHARSET_TEXT, parseTable, tableLength, 0); - int width = OS.XmStringWidth(renderTable, xmString); - int height = OS.XmStringHeight(renderTable, xmString); - OS.XmStringFree(xmString); - return new Point(width, height); - */ - try { - focus(false, null); - installFont(); - int width= OS.TextWidth(string, data.font.fID, data.font.fSize, data.font.fFace); - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - return new Point(width, fontInfo[0] + fontInfo[1]); - } finally { - unfocus(false); - } + //NOT DONE + return stringExtent(string); } + /** * Returns a string containing a concise, human-readable * description of the receiver. @@ -2022,146 +1820,4 @@ public String toString () { return "GC {" + handle + "}"; } -//---- Mac Stuff - - public void installFont() { - if (data != null && data.font != null) - data.font.installInGrafPort(); - } - - private boolean focus(boolean doClip, MacRect bounds) { - - if (fIsFocused && !fPendingClip) { - return true; - } - - // save global state - OS.GetGWorld(fSavePort, fSaveGWorld); - OS.SetGWorld(handle, fSaveGWorld[0]); - - if (!doClip) - return true; - - int dx= 0, dy= 0; - - // set origin of port using drawable bounds - if (data.controlHandle != 0) { - OS.GetControlBounds(data.controlHandle, fRect.getData()); - dx= fRect.getX(); - dy= fRect.getY(); - OS.SetOrigin((short)-dx, (short)-dy); - MacPoint p= new MacPoint(-dx, -dy); - OS.QDSetPatternOrigin(p.getData()); - } - // save clip region - OS.GetClip(fSaveClip); - - // calculate new clip based on the controls bound and GC clipping region - if (data.controlHandle != 0) { - - int result= OS.NewRgn(); - MacUtil.getVisibleRegion(data.controlHandle, result, true); - OS.OffsetRgn(result, (short)-dx, (short)-dy); - - // clip against damage - if (fDamageRgn != 0) { - int dRgn= OS.NewRgn(); - OS.CopyRgn(fDamageRgn, dRgn); - OS.OffsetRgn(dRgn, (short)-dx, (short)-dy); - OS.SectRgn(result, dRgn, result); - } - - // clip against GC clipping region - if (data.clipRgn != 0) { - OS.SectRgn(result, data.clipRgn, result); - } - - OS.SetClip(result); - if (bounds != null) - OS.GetRegionBounds(result, bounds.getData()); - OS.DisposeRgn(result); - - } else { - // clip against GC clipping region - if (data.clipRgn != 0) { - OS.SetClip(data.clipRgn); - if (bounds != null) - OS.GetRegionBounds(data.clipRgn, bounds.getData()); - } else { - if (bounds != null) - bounds.set(0, 0, 0x8fff, 0x8fff); - } - } - fPendingClip= false; - - return true; - } - - private void unfocus(boolean doClip) { - - if (fIsFocused) - return; - - if (doClip) { - // restore clipping and origin of port - OS.SetClip(fSaveClip); - OS.SetOrigin((short)0, (short)0); - } - - // restore globals - OS.SetGWorld(fSavePort[0], fSaveGWorld[0]); - } - - public Rectangle carbon_focus(int damageRgn) { - OS.LockPortBits(handle); - fDamageRgn= damageRgn; - MacRect bounds= new MacRect(); - focus(true, bounds); - fIsFocused= true; - return bounds.toRectangle(); - } - - public void carbon_unfocus() { - fIsFocused= false; - unfocus(true); - fDamageRgn= 0; - OS.UnlockPortBits(handle); - } - - private short getCurrentScreenDepth() { - int gd= OS.GetGDevice(); - if (gd != 0) { - int pm= OS.getgdPMap(gd); - if (pm != 0) - return OS.GetPixDepth(pm); - } - return 32; - } - - // new Core Graphic stuff - - public int carbon_CG_focus() { - - if (OS.QDBeginCGContext(handle, fContext) != OS.kNoErr) - return 0; - - int context= fContext[0]; - - MacRect b= new MacRect(); - OS.GetPortBounds(handle, b.getData()); - - int clip= OS.NewRgn(); - OS.GetPortClipRegion(handle, clip); - OS.ClipCGContextToRegion(context, b.getData(), clip); - OS.DisposeRgn(clip); - - OS.CGContextTranslateCTM(context, 0, b.getHeight()); - OS.CGContextScaleCTM(context, 1, -1); - return context; - } - - public void carbon_CG_unfocus() { - OS.QDEndCGContext(handle, fContext); - } - } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GCData.java index 7a55e63e21..ffb114a13f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GCData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/GCData.java @@ -8,8 +8,7 @@ package org.eclipse.swt.graphics; */ import org.eclipse.swt.*; - -import org.eclipse.swt.internal.carbon.MacFont; +import org.eclipse.swt.internal.carbon.Rect; /** * Instances of this class are descriptions of GCs in terms @@ -26,12 +25,20 @@ import org.eclipse.swt.internal.carbon.MacFont; public final class GCData { public Device device; public Image image; - public int foreground = -1; - public int background = -1; - public MacFont font; + public float[] foreground; + public float[] background; public int clipRgn; + public int lineWidth = 1; public int lineStyle = SWT.LINE_SOLID; - // AW - public int controlHandle; - // AW + public boolean xorMode; + + public Font font; + public int fontAscent; + public int fontDescent; + public int layout; + public int style; + + public int paintEvent; + public int visibleRgn; + public int control; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Image.java index 5beca7ab0e..cfd6c8f8bb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Image.java @@ -6,11 +6,11 @@ package org.eclipse.swt.graphics; * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html */ - + import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.*; import java.io.*; - + /** * Instances of this class are graphics which have been prepared * for display on a specific device. That is, they are ready @@ -58,37 +58,37 @@ import java.io.*; * @see ImageData * @see ImageLoader */ -public final class Image implements Drawable { - +public final class Image implements Drawable{ + /** * specifies whether the receiver is a bitmap or an icon * (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>) */ public int type; - + /** - * The handle to the OS pixmap resource. + * The handle to the OS image resource. * Warning: This field is platform dependent. */ - public int pixmap; + public int handle; /** - * The handle to the OS mask resource. + * The data to the OS image resource. * Warning: This field is platform dependent. */ - public int mask; + public int data; /** * The device where this image was created. */ Device device; - + /** * specifies the transparent pixel * (Warning: This field is platform dependent) */ int transparentPixel = -1; - + /** * The GC the image is currently selected in. * Warning: This field is platform dependent. @@ -100,13 +100,13 @@ public final class Image implements Drawable { * Warning: This field is platform dependent. */ byte[] alphaData; - + /** * The global alpha value to be used for every pixel. * Warning: This field is platform dependent. */ int alpha = -1; - + /** * Specifies the default scanline padding. * Warning: This field is platform dependent. @@ -115,6 +115,7 @@ public final class Image implements Drawable { Image() { } + /** * Constructs an empty instance of this class with the * specified width and height. The result may be drawn upon @@ -145,9 +146,12 @@ Image() { * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> * </ul> */ -public Image(Device device, int width, int height) { +public Image(Device display, int width, int height) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); init(device, width, height); } + /** * Constructs a new instance of this class based on the * provided image, with an appearance that varies depending @@ -182,253 +186,121 @@ public Image(Device device, int width, int height) { public Image(Device device, Image srcImage, int flag) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - this.device = device; if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - + switch (flag) { + case SWT.IMAGE_COPY: + case SWT.IMAGE_DISABLE: + case SWT.IMAGE_GRAY: + break; + default: + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + this.device = device; this.type = srcImage.type; - this.mask = 0; - - MacRect bounds= new MacRect(); - OS.GetPixBounds(srcImage.pixmap, bounds.getData()); - int width = bounds.getWidth(); - int height = bounds.getHeight(); - /* Don't create the mask here if flag is SWT.IMAGE_GRAY. See below.*/ - if (flag != SWT.IMAGE_GRAY && srcImage.mask != 0) { - /* Generate the mask if necessary. */ - if (srcImage.transparentPixel != -1) srcImage.createMask(); - this.mask = duplicate(srcImage.mask); - /* Destroy the image mask if the there is a GC created on the image */ - if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask(); - } - - switch (flag) { - - case SWT.IMAGE_COPY: - this.pixmap = duplicate(srcImage.pixmap); + /* Get source image size */ + int width = OS.CGImageGetWidth(srcImage.handle); + int height = OS.CGImageGetHeight(srcImage.handle); + int bpr = OS.CGImageGetBytesPerRow(srcImage.handle); + int bpc = OS.CGImageGetBitsPerComponent(srcImage.handle); + int bpp = OS.CGImageGetBitsPerPixel(srcImage.handle); + int colorspace = OS.CGImageGetColorSpace(srcImage.handle); + int alphaInfo = OS.kCGImageAlphaNoneSkipFirst; + + /* Copy transparent pixel and alpha data when necessary */ + if (flag != SWT.IMAGE_DISABLE) { + alphaInfo = OS.CGImageGetAlphaInfo(srcImage.handle); transparentPixel = srcImage.transparentPixel; alpha = srcImage.alpha; if (srcImage.alphaData != null) { alphaData = new byte[srcImage.alphaData.length]; System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length); } - return; - - case SWT.IMAGE_DISABLE: - /* Get src image data */ - int srcDepth= getDepth(srcImage.pixmap); - int srcBitsPerPixel= srcDepth; - - if (srcBitsPerPixel == 1) { - /* - * Nothing we can reasonably do here except copy - * the bitmap; we can't make it a higher color depth. - * Short-circuit the rest of the code and return. - */ - pixmap = duplicate(srcImage.pixmap); - return; - } - - int srcRowBytes= rowBytes(width, srcDepth); - byte[] srcData = new byte[srcRowBytes * height]; - copyPixMapData(srcImage.pixmap, srcData); - - /* Create destination image */ - int destPixmap = createPixMap(width, height, srcDepth); - int destBitsPerPixel= srcDepth; - byte[] destData = new byte[srcRowBytes * height]; - - /* Find the colors to map to */ - Color zeroColor = device.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); - Color oneColor = device.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); - int zeroPixel= 0; - int onePixel= 1; - setColorTable(destPixmap, new Color[] { zeroColor, oneColor }); + } - switch (srcBitsPerPixel) { - case 1: - // should not happen; see above - return; - case 4: - //SWT.error(SWT.ERROR_NOT_IMPLEMENTED); - pixmap = duplicate(srcImage.pixmap); - break; - case 8: - int index = 0; - int srcPixel, r, g, b; - - int[] colors= new int[256]; - for (int i= 0; i < 256; i++) - colors[i]= -1; - - short[] colorTable= getColorTable(srcImage.pixmap); - - for (int y = 0; y < height; y++) { - for (int x = 0; x < srcRowBytes; x++) { - srcPixel = srcData[index + x] & 0xFF; - /* Get the RGB values of srcPixel */ - int color= colors[srcPixel]; - if (color == -1) - colors[srcPixel]= color= getRGB(colorTable, srcPixel); - r = (color >> 16) & 0xFF; - g = (color >> 8) & 0xFF; - b = (color) & 0xFF; - /* See if the rgb maps to 0 or 1 */ - if ((r * r + g * g + b * b) < 98304) { - /* Map down to 0 */ - destData[index + x] = (byte)zeroPixel; - } else { - /* Map up to 1 */ - destData[index + x] = (byte)onePixel; - } - } - index += srcRowBytes; - } - break; - case 16: - index = 0; - /* Get masks */ - int redMask = getRedMask(16); - int greenMask = getGreenMask(16); - int blueMask = getBlueMask(16); - /* Calculate mask shifts */ - int rShift = 24 - getOffsetForMask(16, redMask, true); - int gShift = 24 - getOffsetForMask(16, greenMask, true); - int bShift = 24 - getOffsetForMask(16, blueMask, true); - byte zeroLow = (byte)(zeroPixel & 0xFF); - byte zeroHigh = (byte)((zeroPixel >> 8) & 0xFF); - byte oneLow = (byte)(onePixel & 0xFF); - byte oneHigh = (byte)((onePixel >> 8) & 0xFF); - for (int y = 0; y < height; y++) { - int xIndex = 0; - for (int x = 0; x < srcRowBytes; x += 2) { - int ix= index + xIndex; - srcPixel = ((srcData[ix + 1] & 0xFF) << 8) | (srcData[ix] & 0xFF); - r = (srcPixel & redMask) << rShift >> 16; - g = (srcPixel & greenMask) << gShift >> 16; - b = (srcPixel & blueMask) << bShift >> 16; - /* See if the rgb maps to 0 or 1 */ - if ((r * r + g * g + b * b) < 98304) { - /* Map down to 0 */ - destData[ix] = zeroLow; - destData[ix + 1] = zeroHigh; - } else { - /* Map up to 1 */ - destData[ix] = oneLow; - destData[ix + 1] = oneHigh; - } - xIndex += srcBitsPerPixel / 8; - } - index += srcRowBytes; - } - break; - case 24: - case 32: - index = 0; - /* Get masks */ - redMask = getRedMask(srcBitsPerPixel); - greenMask = getGreenMask(srcBitsPerPixel); - blueMask = getBlueMask(srcBitsPerPixel); - /* Calculate mask shifts */ - rShift = getOffsetForMask(srcBitsPerPixel, redMask, true); - gShift = getOffsetForMask(srcBitsPerPixel, greenMask, true); - bShift = getOffsetForMask(srcBitsPerPixel, blueMask, true); - byte zeroR = (byte)zeroColor.getRed(); - byte zeroG = (byte)zeroColor.getGreen(); - byte zeroB = (byte)zeroColor.getBlue(); - byte oneR = (byte)oneColor.getRed(); - byte oneG = (byte)oneColor.getGreen(); - byte oneB = (byte)oneColor.getBlue(); - for (int y = 0; y < height; y++) { - int xIndex = 0; - for (int x = 0; x < width; x++) { - int i= index + xIndex; - r = srcData[i + rShift] & 0xFF; - g = srcData[i + gShift] & 0xFF; - b = srcData[i + bShift] & 0xFF; - /* See if the rgb maps to 0 or 1 */ - if ((r * r + g * g + b * b) < 98304) { - /* Map down to 0 */ - destData[i + rShift] = zeroR; - destData[i + gShift] = zeroG; - destData[i + bShift] = zeroB; + /* Create the image */ + int dataSize = height * bpr; + data = OS.NewPtr(dataSize); + if (data == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int provider = OS.CGDataProviderCreateWithData(0, data, dataSize, 0); + if (provider == 0) { + OS.DisposePtr(data); + SWT.error(SWT.ERROR_NO_HANDLES); + } + handle = OS.CGImageCreate(width, height, bpc, bpp, bpr, colorspace, alphaInfo, provider, null, false, 0); + OS.CGDataProviderRelease(provider); + if (handle == 0) { + OS.DisposePtr(data); + SWT.error(SWT.ERROR_NO_HANDLES); + } + + OS.memcpy(data, srcImage.data, dataSize); + if (flag == SWT.IMAGE_COPY) return; + + /* Apply transformation */ + switch (flag) { + case SWT.IMAGE_DISABLE: { + Color zeroColor = device.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); + RGB zeroRGB = zeroColor.getRGB(); + byte zeroRed = (byte)zeroRGB.red; + byte zeroGreen = (byte)zeroRGB.green; + byte zeroBlue = (byte)zeroRGB.blue; + Color oneColor = device.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); + RGB oneRGB = oneColor.getRGB(); + byte oneRed = (byte)oneRGB.red; + byte oneGreen = (byte)oneRGB.green; + byte oneBlue = (byte)oneRGB.blue; + byte[] line = new byte[bpr]; + for (int y=0; y<height; y++) { + OS.memcpy(line, data + (y * bpr), bpr); + int offset = 0; + for (int x=0; x<width; x++) { + int red = line[offset+1] & 0xFF; + int green = line[offset+2] & 0xFF; + int blue = line[offset+3] & 0xFF; + int intensity = red * red + green * green + blue * blue; + if (intensity < 98304) { + line[offset+1] = zeroRed; + line[offset+2] = zeroGreen; + line[offset+3] = zeroBlue; } else { - /* Map up to 1 */ - destData[i + rShift] = oneR; - destData[i + gShift] = oneG; - destData[i + bShift] = oneB; + line[offset+1] = oneRed; + line[offset+2] = oneGreen; + line[offset+3] = oneBlue; } - xIndex += destBitsPerPixel / 8; + offset += 4; } - index += srcRowBytes; + OS.memcpy(data + (y * bpr), line, bpr); } break; - default: - SWT.error(SWT.ERROR_INVALID_IMAGE); } - setPixMapData(destPixmap, destData); - this.pixmap = destPixmap; - return; - - case SWT.IMAGE_GRAY: - ImageData data = srcImage.getImageData(); - PaletteData palette = data.palette; - ImageData newData = data; - if (palette.isDirect) { - /* 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(width, height, 8, new PaletteData(rgbs)); - newData.maskData = data.maskData; - newData.maskPad = data.maskPad; - /* Convert the pixels. */ - int[] scanline = new int[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 < height; y++) { - int offset = y * newData.bytesPerLine; - data.getPixels(0, y, width, scanline, 0); - for (int x= 0; x < width; x++) { - int pixel = scanline[x]; - int red = pixel & redMask; - red = (redShift < 0) ? red >>> -redShift : red << redShift; - int green = pixel & greenMask; - green = (greenShift < 0) ? green >>> -greenShift : green << greenShift; - int blue = pixel & blueMask; - blue = (blueShift < 0) ? blue >>> -blueShift : blue << blueShift; - newData.data[offset++] = - (byte)((red+red+green+green+green+green+green+blue) >> 3); + case SWT.IMAGE_GRAY: { + byte[] line = new byte[bpr]; + for (int y=0; y<height; y++) { + OS.memcpy(line, data + (y * bpr), bpr); + int offset = 0; + for (int x=0; x<width; x++) { + int red = line[offset+1] & 0xFF; + int green = line[offset+2] & 0xFF; + int blue = line[offset+3] & 0xFF; + byte intensity = (byte)((red+red+green+green+green+green+green+blue) >> 3); + line[offset+1] = line[offset+2] = line[offset+3] = intensity; + offset += 4; } + OS.memcpy(data + (y * bpr), line, bpr); } - } else { - /* 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; - } + transparentPixel = srcImage.transparentPixel; + alpha = srcImage.alpha; + if (srcImage.alphaData != null) { + alphaData = new byte[srcImage.alphaData.length]; + System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length); } - newData.palette = new PaletteData(rgbs); + break; } - init (device, newData); - break; - - default: - SWT.error(SWT.ERROR_INVALID_ARGUMENT); } } + /** * Constructs an empty instance of this class with the * width and height of the specified rectangle. The result @@ -459,10 +331,13 @@ public Image(Device device, Image srcImage, int flag) { * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> * </ul> */ -public Image(Device device, Rectangle bounds) { +public Image(Device display, Rectangle bounds) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); init(device, bounds.width, bounds.height); } + /** * Constructs an instance of this class from the given * <code>ImageData</code>. @@ -478,9 +353,12 @@ public Image(Device device, Rectangle bounds) { * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> * </ul> */ -public Image(Device device, ImageData image) { - init(device, image); +public Image(Device device, ImageData data) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + init(device, data); } + /** * Constructs an instance of this class, whose type is * <code>SWT.ICON</code>, from the two given <code>ImageData</code> @@ -510,7 +388,8 @@ public Image(Device device, ImageData image) { * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> * </ul> */ -public Image(Device device, ImageData source, ImageData mask) { +public Image(Device display, ImageData source, ImageData mask) { + if (device == null) device = Device.getDevice(); 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) { @@ -522,6 +401,7 @@ public Image(Device device, ImageData source, ImageData mask) { image.maskData = mask.data; init(device, image); } + /** * Constructs an instance of this class by loading its representation * from the specified input stream. Throws an error if an error @@ -555,8 +435,11 @@ public Image(Device device, ImageData source, ImageData mask) { * </ul> */ public Image(Device device, InputStream stream) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); init(device, new ImageData(stream)); } + /** * Constructs an instance of this class by loading its representation * from the file with the specified name. Throws an error if an error @@ -582,60 +465,27 @@ public Image(Device device, InputStream stream) { * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> * </ul> */ -public Image(Device device, String filename) { +public Image(Device display, String filename) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); init(device, new ImageData(filename)); } -/** - * Create the receiver's mask if necessary. - */ -void createMask() { - if (mask != 0) return; - mask = createMaskImage(getImageData().getTransparencyMask()); -} -/** - * Creates a Quickdraw BitMap from a device-independent image of depth 1. - */ -private static int createMaskImage(ImageData image) { - if (image.depth != 1) return 0; - - int w= image.width; - int h= image.height; - int bitmap= createBitMap(w, h); - int rowBytes= rowBytes(w, 1); - byte[] data= new byte[rowBytes * h]; - ImageData.blit(ImageData.BLIT_SRC, - image.data, 1, image.bytesPerLine, image.getByteOrder(), 0, 0, w, h, null, null, null, - ImageData.ALPHA_OPAQUE, null, 0, 0, 0, - data, 1, rowBytes, ImageData.MSB_FIRST, 0, 0, w, h, null, null, null, - false, false); - - setPixMapData(bitmap, data); - - return bitmap; -} /** * Disposes of the operating system resources associated with * the image. Applications must dispose of all images which * they allocate. */ public void dispose () { - if (pixmap == 0) return; + if (handle == 0) return; if (device.isDisposed()) return; - if (pixmap != 0) disposeBitmapOrPixmap(pixmap); - if (mask != 0) disposeBitmapOrPixmap(mask); + OS.CGImageRelease(handle); + OS.DisposePtr(data); device = null; + data = handle = 0; memGC = null; - pixmap = mask = 0; -} -/** - * Destroy the receiver's mask if it exists. - */ -void destroyMask() { - if (mask == 0) return; - disposeBitmapOrPixmap(mask); - mask= 0; } + /** * Compares the argument to the receiver, and returns true * if they represent the <em>same</em> object using a class @@ -650,10 +500,10 @@ public boolean equals (Object object) { if (object == this) return true; if (!(object instanceof Image)) return false; Image image = (Image)object; - return device == image.device && pixmap == image.pixmap && - transparentPixel == image.transparentPixel && - mask == image.mask; + return device == image.device && handle == image.handle && + transparentPixel == image.transparentPixel; } + /** * Returns the color to which to map the transparent pixel, or null if * the receiver has no transparent pixel. @@ -675,17 +525,10 @@ public boolean equals (Object object) { public Color getBackground() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (transparentPixel == -1) return null; - /* AW - XColor xColor = new XColor(); - xColor.pixel = transparentPixel; - int xDisplay = device.xDisplay; - int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay)); - OS.XQueryColor(xDisplay, colormap, xColor); - return Color.motif_new(device, xColor); - */ - System.out.println("Image.getBackground: nyi"); - return null; + //NOT DONE + return null; } + /** * Returns the bounds of the receiver. The rectangle will always * have x and y values of 0, and the width and height of the @@ -698,12 +541,11 @@ public Color getBackground() { * <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li> * </ul> */ -public Rectangle getBounds () { +public Rectangle getBounds() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - MacRect bounds= new MacRect(); - OS.GetPixBounds(pixmap, bounds.getData()); - return bounds.toRectangle(); + return new Rectangle(0, 0, OS.CGImageGetWidth(handle), OS.CGImageGetHeight(handle)); } + /** * Returns an <code>ImageData</code> based on the receiver * Modifications made to this <code>ImageData</code> will not @@ -720,117 +562,40 @@ public Rectangle getBounds () { */ public ImageData getImageData() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle srcBounds = getBounds(); - int width = srcBounds.width; - int height = srcBounds.height; - int srcDepth= getDepth(pixmap); - /* Get the data for the source image. */ - int srcRowBytes= rowBytes(width, srcDepth); - int srcBitsPerPixel= srcDepth; - byte[] srcData = new byte[srcRowBytes * height]; - copyPixMapData(pixmap, srcData); - - /* Build the palette */ - PaletteData palette = null; - switch (srcDepth) { - case 1: - palette = new PaletteData(new RGB[] { - new RGB(0, 0, 0), - new RGB(255, 255, 255) - }); - break; - case 4: - short[] colorTable4= getColorTable(pixmap); - RGB[] rgbs4 = new RGB[ colorTable4.length/4 ]; - for (int i = 0; i < rgbs4.length; i++) { - int packed= getRGB(colorTable4, i); - rgbs4[i] = new RGB((packed >> 16) & 0xFF, (packed >> 8) & 0xFF, (packed >> 0) & 0xFF); - } - palette = new PaletteData(rgbs4); - break; - case 8: - /* Normalize the pixels in the source image data (by making the - * pixel values sequential starting at pixel 0). Reserve normalized - * pixel 0 so that it maps to real pixel 0. This assumes pixel 0 is - * always used in the image. - */ - byte[] normPixel = new byte[ 256 ]; - for (int index = 0; index < normPixel.length; index++) { - normPixel[ index ] = 0; - } - int numPixels = 1; - int index = 0; - for (int y = 0; y < height; y++) { - for (int x = 0; x < srcRowBytes; x++) { - int srcPixel = srcData[ index + x ] & 0xFF; - if (srcPixel != 0 && normPixel[ srcPixel ] == 0) { - normPixel[ srcPixel ] = (byte)numPixels++; - } - srcData[ index + x ] = normPixel[ srcPixel ]; - } - index += srcRowBytes; - } - - short[] colorTable= getColorTable(pixmap); - - /* Create a palette with only the RGB values used in the image. */ - RGB[] rgbs = new RGB[ numPixels ]; - for (int srcPixel = 0; srcPixel < normPixel.length; srcPixel++) { - // If the pixel value was used in the image, get its RGB values. - if (srcPixel == 0 || normPixel[ srcPixel ] != 0) { - int packed= getRGB(colorTable, srcPixel); - int rgbIndex = normPixel[ srcPixel ] & 0xFF; - rgbs[ rgbIndex ] = new RGB((packed >> 16) & 0xFF, (packed >> 8) & 0xFF, (packed >> 0) & 0xFF); - } - } - palette = new PaletteData(rgbs); - break; - case 16: - case 24: - case 32: - palette = new PaletteData(getRedMask(srcDepth), getGreenMask(srcDepth), getBlueMask(srcDepth)); - break; - default: - SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH); - } + int width = OS.CGImageGetWidth(handle); + int height = OS.CGImageGetHeight(handle); + int bpr = OS.CGImageGetBytesPerRow(handle); + int bpp = OS.CGImageGetBitsPerPixel(handle); + int dataSize = height * bpr; + byte[] srcData = new byte[dataSize]; + OS.memcpy(srcData, data, dataSize); - - ImageData data = new ImageData(width, height, srcDepth, palette); + PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF); + ImageData data = new ImageData(width, height, bpp, palette); data.data = srcData; - if (false && srcBitsPerPixel == 32) { - /* - * If bits per pixel is 32, scale the data down to 24, since we do not - * support 32-bit images - */ - byte[] oldData = data.data; - int bytesPerLine = (width * srcDepth + 7) / 8; - bytesPerLine = (bytesPerLine + 3) / 4 * 4; - byte[] newData = new byte[bytesPerLine * height]; - int destIndex = 0; - int srcIndex = 0; - - for (int y = 0; y < height; y++) { - destIndex = y * bytesPerLine; - srcIndex = y * srcRowBytes; - for (int x = 0; x < width; x++) { - newData[destIndex] = oldData[srcIndex + 1]; - newData[destIndex + 1] = oldData[srcIndex + 2]; - newData[destIndex + 2] = oldData[srcIndex + 3]; - srcIndex += 4; - destIndex += 3; + data.bytesPerLine = bpr; + + data.transparentPixel = transparentPixel; + if (transparentPixel == -1 && type == SWT.ICON) { + /* Get the icon mask data */ + int maskBpl = (((width + 7) / 8) + 3) / 4 * 4; + byte[] maskData = new byte[height * maskBpl]; + int offset = 0, maskOffset = 0; + for (int y = 0; y<height; y++) { + for (int x = 0; x<width; x++) { + if (srcData[offset] != 0) { + maskData[maskOffset + (x >> 3)] |= (1 << (7 - (x & 0x7))); + } else { + maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7))); + } + offset += 4; } + maskOffset += maskBpl; } - data.data = newData; - } - if (transparentPixel == -1 && type == SWT.ICON && mask != 0) { - /* Get the icon data */ + data.maskData = maskData; data.maskPad = 4; - int maskRowBytes= rowBytes(width, getDepth(mask)); - data.maskData = new byte[maskRowBytes * height]; - copyPixMapData(mask, data.maskData); } - data.transparentPixel = transparentPixel; data.alpha = alpha; if (alpha == -1 && alphaData != null) { data.alphaData = new byte[alphaData.length]; @@ -838,73 +603,34 @@ public ImageData getImageData() { } return data; } -/** - * Get the offset for the given mask. - * - * For 24 and 32-bit masks, the offset indicates which byte holds the - * data for the given mask (indexed from 0). - * For example, in 0x0000FF00, the byte offset is 1. + +/** + * Invokes platform specific functionality to allocate a new image. + * <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> * - * For 16-bit masks, the offset indicates which bit holds the most significant - * data for the given mask (indexed from 1). - * For example, in 0x7E0, the bit offset is 11. + * @param device the device on which to allocate the color + * @param type the type of the image (<code>SWT.BITMAP</code> or <code>SWT.ICON</code>) + * @param handle the OS handle for the image + * @param data the OS data for the image * - * The different semantics are necessary because 24- and 32-bit images - * have their color components aligned on byte boundaries, and 16-bit images - * do not. + * @private */ -static int getOffsetForMask(int bitspp, int mask, boolean msbFirst) { - if (bitspp % 8 != 0) { - System.err.println("Image.getOffsetForMask: error 1"); - return 0; - } - int poff= 0; - switch (mask) { - /* 24-bit and 32-bit masks */ - case 0x000000FF: - poff = 0; - break; - case 0x0000FF00: - poff = 1; - break; - case 0x00FF0000: - poff = 2; - break; - case 0xFF000000: - poff = 3; - break; - /* 16-bit masks */ - case 0x001F: - poff = 5; - break; - case 0x03E0: - poff = 10; - break; - case 0x07E0: - poff = 11; - break; - case 0x7C00: - poff = 15; - break; - case 0xF800: - poff = 16; - break; - default: - System.err.println("Image.getOffsetForMask: error 2"); - return 0; - } - if (bitspp == 16) { - return poff; - } - if (poff >= bitspp / 8) { - System.err.println("Image.getOffsetForMask: error 3"); - return 0; - } - if (msbFirst) { - poff = (bitspp/8 - 1) - poff; - } - return poff; +public static Image carbon_new(Device device, int type, int handle, int data) { + if (device == null) device = Device.getDevice(); + Image image = new Image(); + image.type = type; + image.handle = handle; + image.data = data; + image.device = device; + return image; } + /** * Returns an integer hash code for the receiver. Any two * objects which return <code>true</code> when passed to @@ -916,74 +642,140 @@ static int getOffsetForMask(int bitspp, int mask, boolean msbFirst) { * @see #equals */ public int hashCode () { - return pixmap; + return handle; } + void init(Device device, int width, int height) { - if (device == null) device = Device.getDevice(); - if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (width <= 0 || height <= 0) { + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } this.device = device; - /* Create the pixmap */ - if (width <= 0 | height <= 0) - SWT.error(SWT.ERROR_INVALID_ARGUMENT); - this.type = SWT.BITMAP; - this.pixmap = createPixMap(width, height, device.fScreenDepth); - /* Fill the bitmap with white */ - int[] offscreenGWorld= new int[1]; - OS.NewGWorldFromPtr(offscreenGWorld, pixmap); - int gw= offscreenGWorld[0]; - if (gw == 0) SWT.error (SWT.ERROR_NO_HANDLES); - - int[] savePort= new int[1]; - int[] saveGWorld= new int[1]; - OS.GetGWorld(savePort, saveGWorld); - OS.SetGWorld(gw, 0); - OS.EraseRect(new short[] { 0, 0, (short)height, (short)width } ); - OS.SetGWorld(savePort[0], saveGWorld[0]); - - OS.DisposeGWorld(gw); + /* Create the image */ + int bpr = width * 4; + int dataSize = height * bpr; + data = OS.NewPtr(dataSize); + if (data == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int provider = OS.CGDataProviderCreateWithData(0, data, dataSize, 0); + if (provider == 0) { + OS.DisposePtr(data); + SWT.error(SWT.ERROR_NO_HANDLES); + } + int colorspace = device.colorspace; + handle = OS.CGImageCreate(width, height, 8, 32, bpr, colorspace, OS.kCGImageAlphaNoneSkipFirst, provider, null, false, 0); + OS.CGDataProviderRelease(provider); + if (handle == 0) { + OS.DisposePtr(data); + SWT.error(SWT.ERROR_NO_HANDLES); + } + + /* Fill the image with white */ + int bpc = OS.CGImageGetBitsPerComponent(handle); + int context = OS.CGBitmapContextCreate(this.data, width, height, bpc, bpr, colorspace, OS.kCGImageAlphaNoneSkipFirst); + CGRect rect = new CGRect(); + rect.width = width; rect.height = height; + OS.CGContextSetRGBFillColor(context, 1, 1, 1, 1); + OS.CGContextFillRect(context, rect); + OS.CGContextRelease(context); } + void init(Device device, ImageData image) { - if (device == null) device = Device.getDevice(); - if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - this.device = device; if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - - int pixmap= createPixMap(image.width, image.height, image.depth); - - int[] transPixel= null; - if (image.transparentPixel != -1) transPixel= new int[]{ image.transparentPixel }; - - int error= putImage(image, transPixel, pixmap); - if (error != 0) { - disposeBitmapOrPixmap(pixmap); - SWT.error(error); - } - if (image.getTransparencyType() == SWT.TRANSPARENCY_MASK || image.transparentPixel != -1) { - if (image.transparentPixel != -1) transparentPixel = transPixel[0]; - int mask= createMaskImage(image.getTransparencyMask()); - if (mask == 0) { - disposeBitmapOrPixmap(pixmap); - SWT.error(error); + this.device = device; + int width = image.width; + int height = image.height; + + /* Create the image */ + int dataSize = width * height * 4; + data = OS.NewPtr(dataSize); + if (data == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int provider = OS.CGDataProviderCreateWithData(0, data, dataSize, 0); + if (provider == 0) { + OS.DisposePtr(data); + SWT.error(SWT.ERROR_NO_HANDLES); + } + int colorspace = device.colorspace; + int transparency = image.getTransparencyType(); + int alphaInfo = transparency == SWT.TRANSPARENCY_NONE ? OS.kCGImageAlphaNoneSkipFirst : OS.kCGImageAlphaFirst; + handle = OS.CGImageCreate(width, height, 8, 32, width * 4, colorspace, alphaInfo, provider, null, false, 0); + OS.CGDataProviderRelease(provider); + if (handle == 0) { + OS.DisposePtr(data); + SWT.error(SWT.ERROR_NO_HANDLES); + } + + /* Initialize data */ + int bpr = width * 4; + PaletteData palette = image.palette; + PaletteData newPalette = new PaletteData(0xFF0000, 0xFF00, 0xFF); + byte[] buffer = new byte[dataSize]; + if (palette.isDirect) { + ImageData.blit(ImageData.BLIT_SRC, + image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, palette.redMask, palette.greenMask, palette.blueMask, + ImageData.ALPHA_OPAQUE, null, 0, 0, 0, + buffer, 32, bpr, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF, + 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; } - this.mask = mask; - if (image.getTransparencyType() == SWT.TRANSPARENCY_MASK) { - this.type = SWT.ICON; - } else { - this.type = SWT.BITMAP; + ImageData.blit(ImageData.BLIT_SRC, + image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, srcReds, srcGreens, srcBlues, + ImageData.ALPHA_OPAQUE, null, 0, 0, 0, + buffer, 32, bpr, ImageData.MSB_FIRST, 0, 0, width, height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask, + false, false); + } + + /* Initialize transparency */ + if (transparency == SWT.TRANSPARENCY_MASK || image.transparentPixel != -1) { + this.type = image.transparentPixel != -1 ? SWT.BITMAP : SWT.ICON; + if (image.transparentPixel != -1) {} + ImageData maskImage = image.getTransparencyMask(); + byte[] maskData = maskImage.data; + int maskBpl = maskImage.bytesPerLine; + int offset = 0, maskOffset = 0; + for (int y = 0; y<height; y++) { + for (int x = 0; x<width; x++) { + buffer[offset] = ((maskData[maskOffset + (x >> 3)]) & (1 << (7 - (x & 0x7)))) != 0 ? (byte)0xff : 0; + offset += 4; + } + maskOffset += maskBpl; } } else { this.type = SWT.BITMAP; - this.mask = 0; - this.alpha = image.alpha; - if (image.alpha == -1 && image.alphaData != null) { + if (image.alpha != -1) { + this.alpha = image.alpha; + byte a = (byte)this.alpha; + for (int dataIndex=0; dataIndex<buffer.length; dataIndex+=4) { + buffer[dataIndex] = a; + } + } else if (image.alphaData != null) { this.alphaData = new byte[image.alphaData.length]; System.arraycopy(image.alphaData, 0, this.alphaData, 0, alphaData.length); + int offset = 0, alphaOffset = 0; + for (int y = 0; y<height; y++) { + for (int x = 0; x<width; x++) { + buffer[offset] = alphaData[alphaOffset]; + offset += 4; + alphaOffset += 1; + } + } } } - this.pixmap = pixmap; + + OS.memcpy(data, buffer, dataSize); } + /** * Invokes platform specific functionality to allocate a new GC handle. * <p> @@ -1000,23 +792,29 @@ void init(Device device, ImageData image) { * @private */ public int internal_new_GC (GCData data) { - if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (type != SWT.BITMAP || memGC != null) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - int[] offscreenGWorld = new int[1]; - OS.NewGWorldFromPtr(offscreenGWorld, pixmap); - int xGC = offscreenGWorld[0]; - if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES); + int width = OS.CGImageGetWidth(handle); + int height = OS.CGImageGetHeight(handle); + int bpc = OS.CGImageGetBitsPerComponent(handle); + int bpr = OS.CGImageGetBytesPerRow(handle); + int colorspace = OS.CGImageGetColorSpace(handle); + int context = OS.CGBitmapContextCreate(this.data, width, height, bpc, bpr, colorspace, OS.kCGImageAlphaNoneSkipFirst); + if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES); + OS.CGContextScaleCTM(context, 1, -1); + OS.CGContextTranslateCTM(context, 0, -height); if (data != null) { data.device = device; - data.image = this; + data.background = device.COLOR_WHITE.handle; + data.foreground = device.COLOR_BLACK.handle; data.font = device.systemFont; - data.foreground = 0x00000000; // black - data.background = 0x00ffffff; // white + data.image = this; } - return xGC; + return context; } + /** * Invokes platform specific functionality to dispose a GC handle. * <p> @@ -1032,10 +830,10 @@ public int internal_new_GC (GCData data) { * * @private */ -public void internal_dispose_GC (int gc, GCData data) { - if (gc != 0) - OS.DisposeGWorld(gc); +public void internal_dispose_GC (int context, GCData data) { + OS.CGContextRelease(context); } + /** * Returns <code>true</code> if the image has been disposed, * and <code>false</code> otherwise. @@ -1047,134 +845,9 @@ public void internal_dispose_GC (int gc, GCData data) { * @return <code>true</code> when the image is disposed and <code>false</code> otherwise */ public boolean isDisposed() { - return pixmap == 0; + return handle == 0; } -/** - * Put a device-independent image of any depth into a drawable of any depth, - */ -static int putImage(ImageData image, int[] transparentPixel, int drawable) { - - int srcX= 0, srcY= 0; - int srcWidth= image.width, srcHeight= image.height; - int destX= srcX, destY= srcY, destWidth= srcWidth, destHeight= srcHeight; - - PaletteData palette = image.palette; - if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) || - ((image.depth == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && palette.isDirect))) - return SWT.ERROR_UNSUPPORTED_DEPTH; - - boolean flipX = destWidth < 0; - boolean flipY = destHeight < 0; - if (flipX) { - destWidth = -destWidth; - destX = destX - destWidth; - } - if (flipY) { - destHeight = -destHeight; - destY = destY - destHeight; - } - - byte[] srcReds = null, srcGreens = null, srcBlues = null; - if (!palette.isDirect) { - RGB[] rgbs = palette.getRGBs(); - int length = rgbs.length; - srcReds = new byte[length]; - srcGreens = new byte[length]; - 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; - } - } - - byte[] destReds = null, destGreens = null, destBlues = null; - int destRedMask = 0, destGreenMask = 0, destBlueMask = 0; - final boolean screenDirect; - int destDepth= OS.GetPixDepth(drawable); - if (destDepth <= 8) { - destReds = new byte[srcReds.length]; - destGreens = new byte[srcGreens.length]; - destBlues = new byte[srcBlues.length]; - for (int i = 0; i < srcReds.length; i++) { - destReds[i] = srcReds[i]; - destGreens[i] = srcGreens[i]; - destBlues[i] = srcBlues[i]; - } - setColorTable(drawable, destReds, destGreens, destBlues); - screenDirect = false; - } else { - destRedMask = getRedMask(destDepth); - destGreenMask = getGreenMask(destDepth); - destBlueMask = getBlueMask(destDepth); - screenDirect = true; - } - if (transparentPixel != null) { - int transRed = 0, transGreen = 0, transBlue = 0; - if (palette.isDirect) { - RGB rgb = palette.getRGB(transparentPixel[0]); - transRed = rgb.red; - transGreen = rgb.green; - transBlue = rgb.blue; - } else { - RGB[] rgbs = palette.getRGBs(); - if (transparentPixel[0] < rgbs.length) { - RGB rgb = rgbs[transparentPixel[0]]; - transRed = rgb.red; - transGreen = rgb.green; - transBlue = rgb.blue; - } - } - transparentPixel[0] = ImageData.closestMatch(destDepth, (byte)transRed, (byte)transGreen, (byte)transBlue, - destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues); - } - - int destBitsPerPixel= destDepth; - - int dest_red_mask= getRedMask(destBitsPerPixel); - int dest_green_mask= getGreenMask(destBitsPerPixel); - int dest_blue_mask= getBlueMask(destBitsPerPixel); - - int destRowBytes= rowBytes(destWidth, destDepth); - int bufSize = destRowBytes * destHeight; - byte[] buf = new byte[bufSize]; - int srcOrder = image.getByteOrder(); - - if (palette.isDirect) { - if (screenDirect) { - ImageData.blit(ImageData.BLIT_SRC, - image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, - ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY, - buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, dest_red_mask, dest_green_mask, dest_blue_mask, - flipX, flipY); - } else { - ImageData.blit(ImageData.BLIT_SRC, - image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, - ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY, - buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues, - flipX, flipY); - } - } else { - if (screenDirect) { - ImageData.blit(ImageData.BLIT_SRC, - image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, - ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY, - buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, dest_red_mask, dest_green_mask, dest_blue_mask, - flipX, flipY); - } else { - ImageData.blit(ImageData.BLIT_SRC, - image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, - ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY, - buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues, - flipX, flipY); - } - } - setPixMapData(drawable, buf); - return 0; -} /** * Sets the color to which to map the transparent pixel. * <p> @@ -1214,29 +887,9 @@ public void setBackground(Color color) { if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (transparentPixel == -1) return; - /* Generate the mask if necessary. */ - if (mask == 0) createMask(); - /* AW - Rectangle bounds = getBounds(); - int[] unused = new int[1]; - int[] depth = new int[1]; - int xDisplay = device.xDisplay; - OS.XGetGeometry(xDisplay, pixmap, unused, unused, unused, unused, unused, unused, depth); - int drawable = OS.XDefaultRootWindow(xDisplay); - int tempPixmap = OS.XCreatePixmap(xDisplay, drawable, bounds.width, bounds.height, depth[0]); - int xGC = OS.XCreateGC(xDisplay, tempPixmap, 0, null); - OS.XSetForeground(xDisplay, xGC, color.handle.pixel); - OS.XFillRectangle(xDisplay, tempPixmap, xGC, 0, 0, bounds.width, bounds.height); - OS.XSetClipMask(xDisplay, xGC, mask); - OS.XCopyArea(xDisplay, pixmap, tempPixmap, xGC, 0, 0, bounds.width, bounds.height, 0, 0); - OS.XSetClipMask(xDisplay, xGC, OS.None); - OS.XCopyArea(xDisplay, tempPixmap, pixmap, xGC, 0, 0, bounds.width, bounds.height, 0, 0); - OS.XFreePixmap(xDisplay, tempPixmap); - OS.XFreeGC(xDisplay, xGC); - */ - /* Destroy the receiver's mask if the there is a GC created on it */ - if (memGC != null) destroyMask(); + //NOT DONE } + /** * Returns a string containing a concise, human-readable * description of the receiver. @@ -1245,360 +898,7 @@ public void setBackground(Color color) { */ public String toString () { if (isDisposed()) return "Image {*DISPOSED*}"; - return "Image {" + pixmap + "}"; + return "Image {" + handle + "}"; } -//////////////////////////////////////////////////////// -// Mac stuff -//////////////////////////////////////////////////////// - - private static int rowBytes(int width, int depth) { - if (depth == 24) - depth= 32; - return (((width*depth-1)/(8*DEFAULT_SCANLINE_PAD))+1)*DEFAULT_SCANLINE_PAD; - } - - private static int createBitMap(int width, int height) { - int rowBytes= rowBytes(width, 1); - if (rowBytes > 0x3fff) { - System.out.println("Image.createBitMap: rowBytes >= 0x4000"); - return 0; - } - int bitmap= newBitMap(width, height, rowBytes); - if (bitmap == 0) - SWT.error(SWT.ERROR_NO_HANDLES); - - initPixMapData(bitmap, rowBytes * height, 0); - - return bitmap; - } - - private static int createPixMap(int width, int height, int depth) { - int rowBytes= rowBytes(width, depth); - if (rowBytes > 0x3fff) { - System.out.println("Image.createPixMap: rowBytes >= 0x4000"); - return 0; - } - int pixmap= NewPixMap(width, height, depth, rowBytes); - if (pixmap == 0) - SWT.error(SWT.ERROR_NO_HANDLES); - - initPixMapData(pixmap, rowBytes * height, 0); - - return pixmap; - } - - private static int NewPixMap(int w, int h, int depth, int rowBytes) { - - int pixelType= 0, pixelSize= 0, cmpSize= 0, cmpCount= 0, pixelFormat= 0; - - if (depth == 24) - depth= 32; - - pixelFormat= depth; - pixelSize= depth; - - switch (depth) { - case 1: - case 2: - case 4: - case 8: - pixelType= OS.Indexed; - cmpSize= depth; - cmpCount= 1; - break; - - case 16: - pixelType= OS.RGBDirect; - cmpSize= 5; - cmpCount= 3; - break; - - case 32: - pixelType= OS.RGBDirect; - cmpSize= 8; - cmpCount= 3; - break; - - default: - break; - } - - return OS.NewPixMap((short)w, (short)h, (short)rowBytes, - (short)pixelType, (short)pixelSize, - (short)cmpSize, (short)cmpCount, (short)pixelFormat); - } - - public static void disposeBitmapOrPixmap(int handle) { - - if (handle == 0) - return; - if ((OS.getRowBytes(handle) & 0x8000) != 0) { // Pixmap - OS.DisposePixMap(handle); - return; - } - - int baseAddr= OS.getBaseAddr(handle); - if (baseAddr != 0) { - OS.DisposePtr(baseAddr); - OS.setBaseAddr(handle, 0); - } - - OS.DisposeHandle(handle); - } - - //private static int fgIconCount; - - public static int carbon_createCIcon(Image image) { - - if (image == null) - return 0; - - Rectangle r= image.getBounds(); - short w= (short)r.width; - short h= (short)r.height; - - - int mask= image.mask; - if (mask == 0) { - //System.out.println("---> CIcon: creating dummy mask"); - int rowBytes= rowBytes(w, 1); - mask= newBitMap(w, h, rowBytes); - initPixMapData(mask, rowBytes*h, 0xff); - } - - int pm= image.pixmap; - if (pm != 0 && getDepth(pm) > 8) { - - ImageData id= image.getImageData(); - - int depth= 8; - int bytesPerRow= rowBytes(w, depth); - byte[] data= new byte[bytesPerRow*h]; - - byte[] reds= new byte[256]; - byte[] greens= new byte[256]; - byte[] blues= new byte[256]; - - int[] values= new int[256]; - int i, fill= 0; - - boolean d16= id.depth == 16; - - for (int y= 0; y < h; y++) { - for (int x= 0; x < w; x++) { - int index= -1; - int value= id.getPixel(x, y); - for (i= 0; i < fill; i++) { - if (value == values[i]) { - index= i; - break; - } - } - if (i >= fill) { - index= fill++; - values[index]= value; - if (!d16) { - reds[index]= (byte)((value >> 16) & 0xFF); - greens[index]= (byte)((value >> 8) & 0xFF); - blues[index]= (byte)((value) & 0xFF); - } else { - reds[index]= (byte)(((value >> 10) & 0x1F) << 3); - greens[index]= (byte)(((value >> 5) & 0x1F) << 3); - blues[index]= (byte)(((value) & 0x1F) << 3); - } - } - if (index >= 0) - data[y*bytesPerRow+x]= (byte)index; - } - } - pm= NewPixMap(w, h, depth, bytesPerRow); - setColorTable(pm, reds, greens, blues); - setPixMapData(pm, data); - } else { - //System.out.println("---> CIcon: can use pixmap"); - } - - int icon= 0; - if (pm != 0 && mask != 0) { - icon= OS.NewCIcon(pm, mask); - //System.out.println("CIcons: " + fgIconCount++); - } - - if (mask != image.mask) - disposeBitmapOrPixmap(mask); - if (pm != image.pixmap) - disposeBitmapOrPixmap(pm); - - return icon; - } - - public static void disposeCIcon(int iconHandle) { - int iconData= OS.getCIconIconData(iconHandle); - if (iconData != 0) - OS.DisposeHandle(iconData); - - int colorTable= OS.getCIconColorTable(iconHandle); - if (colorTable != 0) - OS.DisposeHandle(colorTable); - - OS.DisposeHandle(iconHandle); - //fgIconCount--; - } - - private static void setColorTable(int pixmapHandle, byte[] red, byte[] green, byte[] blue) { - int n= Math.max(Math.max(red.length, green.length), blue.length); - short[] colorSpec= new short[n*4]; - int j= 0; - for (int i= 0; i < n; i++) { - colorSpec[j++]= (short) i; - colorSpec[j++]= (short) (red[i]*257); - colorSpec[j++]= (short) (green[i]*257); - colorSpec[j++]= (short) (blue[i]*257); - } - OS.setColorTable(pixmapHandle, colorSpec); - } - - private static void setColorTable(int pixmapHandle, Color[] table) { - int n= table.length; - short[] colorSpec= new short[n*4]; - int j= 0; - for (int i= 0; i < n; i++) { - colorSpec[j++]= (short) i; - colorSpec[j++]= (short) (table[i].getRed() * 257); - colorSpec[j++]= (short) (table[i].getGreen() * 257); - colorSpec[j++]= (short) (table[i].getBlue() * 257); - } - OS.setColorTable(pixmapHandle, colorSpec); - } - - private static int getDepth(int bitmapHandle) { - if ((OS.getRowBytes(bitmapHandle) & 0x8000) != 0) // Pixmap - return OS.GetPixDepth(bitmapHandle); - return 1; - } - - private static boolean isBitMap(int handle) { - return (OS.getRowBytes(handle) & 0x8000) == 0; - } - - private static int duplicate(int handle) { - int rowBytes= OS.getRowBytes(handle); - if ((rowBytes & 0x8000) == 0) { - MacRect bounds= new MacRect(); - OS.GetPixBounds(handle, bounds.getData()); - int copy= newBitMap(bounds.getWidth(), bounds.getHeight(), rowBytes); - int baseAddr= OS.getBaseAddr(handle); - if (baseAddr != 0) { - int size= OS.GetPtrSize(baseAddr); - int data= OS.NewPtr(size); - OS.memcpy(data, baseAddr, size); - OS.setBaseAddr(copy, data); - } - return copy; - } - return OS.duplicatePixMap(handle); - } - - private static int getRedMask(int depth) { - switch (depth) { - case 15: - case 16: - return 0x7C00; - case 24: - case 32: - return 0xff0000; - } - return -1; - } - - private static int getGreenMask(int depth) { - switch (depth) { - case 15: - case 16: - return 0x03E0; - case 24: - case 32: - return 0x00ff00; - } - return -1; - } - - private static int getBlueMask(int depth) { - switch (depth) { - case 15: - case 16: - return 0x001F; - case 24: - case 32: - return 0x0000ff; - } - return -1; - } - - private static void setPixMapData(int destPixMap, byte[] data) { - int addr= OS.getBaseAddr(destPixMap); - if (addr != 0) { - OS.DisposePtr(addr); - } - addr= OS.NewPtr(data.length); - OS.memcpy(addr, data, data.length); - OS.setBaseAddr(destPixMap, addr); - } - - private static void initPixMapData(int destPixMap, int size, int value) { - int addr= OS.getBaseAddr(destPixMap); - if (addr != 0) { - OS.DisposePtr(addr); - } - if (value != 0) { - addr= OS.NewPtr(size); - OS.memset(addr, value, size); - } else { - addr= OS.NewPtrClear(size); - } - OS.setBaseAddr(destPixMap, addr); - } - - private static void copyPixMapData(int srcPixMap, byte[] data) { - int baseAddr= OS.getBaseAddr(srcPixMap); - if (baseAddr != 0) { - int l= OS.GetPtrSize(baseAddr); - if (l == data.length) { - OS.memcpy(data, baseAddr, data.length); - } else { - System.err.println("Image.copyPixmapData: wrong lengths: " + l + " " + data.length); - } - } - } - - private static int newBitMap(int width, int height, int rowBytes) { - int bmh= OS.NewHandleClear(/* sizeof(BitMap) */ 14); - OS.setRowBytes(bmh, (short) rowBytes); - OS.setPixBounds(bmh, (short)0, (short)0, (short)height, (short)width); - return bmh; - } - - private static short[] getColorTable(int pixmapHandle) { - int n= OS.getColorTableSize(pixmapHandle); - if (n < 1) - return null; - short[] data= new short[n*4]; - OS.getColorTable(pixmapHandle, data); - return data; - } - - private static int getRGB(short[] colorTable, int pixel) { - if (colorTable == null) - return 0; - int base= pixel*4; - if (base + 3 >= colorTable.length) { - System.out.println("Image.getRGB: out of bounds"); - return 0; - } - int red= colorTable[base+1] >> 8; - int green= colorTable[base+2] >> 8; - int blue= colorTable[base+3] >> 8; - return (red << 16) + (green << 8) + blue; - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Region.java index a629cbf8ed..3eef9ffbdf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Region.java @@ -6,10 +6,10 @@ package org.eclipse.swt.graphics; * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html */ - + import org.eclipse.swt.internal.carbon.*; 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 @@ -26,6 +26,7 @@ public final class Region { * (Warning: This field is platform dependent) */ public int handle; + /** * Constructs a new empty region. * @@ -33,12 +34,14 @@ public final class Region { * <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li> * </ul> */ -public Region () { - handle= OS.NewRgn(); +public Region() { + handle = OS.NewRgn(); } -Region (int handle) { + +Region(int handle) { this.handle = handle; } + /** * Adds the given rectangle to the collection of rectangles * the receiver maintains to describe its area. @@ -53,15 +56,18 @@ Region (int handle) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void add (Rectangle rect) { +public void add(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - int rectRgn= OS.NewRgn(); - OS.RectRgn(rectRgn, new MacRect(rect).getData()); + int rectRgn = OS.NewRgn(); + Rect r = new Rect(); + OS.SetRect(r, (short)rect.x, (short)rect.y, (short)(rect.x + rect.width),(short)(rect.y + rect.height)); + OS.RectRgn(rectRgn, r); OS.UnionRgn(rectRgn, handle, handle); OS.DisposeRgn(rectRgn); } + /** * Adds all of the rectangles which make up the area covered * by the argument to the collection of rectangles the receiver @@ -77,12 +83,13 @@ public void add (Rectangle rect) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public void add (Region region) { +public void add(Region region) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - OS.UnionRgn(handle, region.handle, handle); + OS.UnionRgn(region.handle, handle, handle); } + /** * Returns <code>true</code> if the point specified by the * arguments is inside the area specified by the receiver, @@ -96,10 +103,13 @@ public void add (Region region) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public boolean contains (int x, int y) { +public boolean contains(int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return OS.PtInRgn(new MacPoint(x, y).getData(), handle); + org.eclipse.swt.internal.carbon.Point point = new org.eclipse.swt.internal.carbon.Point(); + OS.SetPt(point, (short)x, (short)y); + return OS.PtInRgn(point, handle); } + /** * Returns <code>true</code> if the given point is inside the * area specified by the receiver, and <code>false</code> @@ -115,7 +125,7 @@ public boolean contains (int x, int y) { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public boolean contains (Point pt) { +public boolean contains(Point pt) { if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); return contains(pt.x, pt.y); } @@ -124,10 +134,11 @@ public boolean contains (Point pt) { * the region. Applications must dispose of all regions which * they allocate. */ -public void dispose () { +public void dispose() { if (handle != 0) OS.DisposeRgn(handle); handle = 0; } + /** * Compares the argument to the receiver, and returns true * if they represent the <em>same</em> object using a class @@ -138,12 +149,13 @@ public void dispose () { * * @see #hashCode */ -public boolean equals (Object object) { +public boolean equals(Object object) { if (this == object) return true; if (!(object instanceof Region)) return false; Region region = (Region)object; return handle == region.handle; } + /** * Returns a rectangle which represents the rectangular * union of the collection of rectangles the receiver @@ -159,10 +171,17 @@ public boolean equals (Object object) { */ public Rectangle getBounds() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - MacRect bounds= new MacRect(); - OS.GetRegionBounds(handle, bounds.getData()); - return bounds.toRectangle(); + Rect bounds = new Rect(); + OS.GetRegionBounds(handle, bounds); + int width = bounds.right - bounds.left; + int height = bounds.bottom - bounds.top; + return new Rectangle(bounds.left, bounds.top, width, height); } + +public static Region carbon_new(int handle) { + return new Region(handle); +} + /** * Returns an integer hash code for the receiver. Any two * objects which return <code>true</code> when passed to @@ -173,9 +192,10 @@ public Rectangle getBounds() { * * @see #equals */ -public int hashCode () { +public int hashCode() { return handle; } + /** * Returns <code>true</code> if the rectangle described by the * arguments intersects with any of the rectangles the receiver @@ -195,8 +215,11 @@ public int hashCode () { */ public boolean intersects (int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return OS.RectInRgn(new MacRect(x, y, width, height).getData(), handle); + Rect rect = new Rect(); + OS.SetRect(rect, (short)x, (short)y, (short)(x + width),(short)(y + height)); + return OS.RectInRgn(rect, handle); } + /** * Returns <code>true</code> if the given rectangle intersects * with any of the rectangles the receiver mainains to describe @@ -214,10 +237,11 @@ public boolean intersects (int x, int y, int width, int height) { * * @see Rectangle#intersects */ -public boolean intersects (Rectangle rect) { +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. @@ -231,6 +255,7 @@ public boolean intersects (Rectangle rect) { 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 @@ -242,13 +267,11 @@ public boolean isDisposed() { * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ -public boolean isEmpty () { +public boolean isEmpty() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); return OS.EmptyRgn(handle); } -public static Region macosx_new(int rgnHandle) { - return new Region(rgnHandle); -} + /** * Returns a string containing a concise, human-readable * description of the receiver. diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java index 453dce3f6e..c890e69b9f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java @@ -7,113 +7,26 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.ControlFontStyleRec; +import org.eclipse.swt.internal.carbon.ControlButtonContentInfo; +import org.eclipse.swt.internal.carbon.CFRange; +import org.eclipse.swt.internal.carbon.Rect; + import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.internal.carbon.*; - -/** - * 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> - */ -public /*final*/ class Button extends Control { +import org.eclipse.swt.graphics.*; + +public class Button extends Control { + String text = ""; Image image; + int cIcon; + boolean isImage; - // AW - private boolean fImageMode; - private int fAlignment; - private int fCIconHandle; - private int fTopMargin; - private int fBottomMargin; - - private static final int MARGIN= 3; // correct value would be 6; however the shadow is only 2 - private static final int SPACE= 9; // min is 8 or may be 9 - private static final int TOP_MARGIN= 0; // - private static final int BOTTOM_MARGIN= 5; // - // AW - -/** - * 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#LEFT - * @see SWT#RIGHT - * @see SWT#CENTER - * @see Widget#checkSubclass - * @see Widget#getStyle - */ public Button (Composite parent, int style) { super (parent, checkStyle (style)); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the control is selected, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * <code>widgetSelected</code> is called when the control is selected. - * <code>widgetDefaultSelected</code> is not called. - * </p> - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #removeSelectionListener - * @see SelectionEvent - */ + public void addSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -121,6 +34,7 @@ public void addSelectionListener(SelectionListener listener) { addListener(SWT.Selection,typedListener); addListener(SWT.DefaultSelection,typedListener); } + static int checkStyle (int style) { style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0); if ((style & SWT.PUSH) != 0) { @@ -134,260 +48,190 @@ static int checkStyle (int style) { } return style; } -void click () { - short part= 10; - if ((style & SWT.CHECK) != 0 || (style & SWT.RADIO) != 0) - part= 11; - OS.HIViewSimulateClick(handle, part, 0, new short[1]); -} + public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); - int border = getBorderWidth (); - int width = border * 2, height = border * 2; + // NEEDS WORK - empty string if ((style & SWT.ARROW) != 0) { - Display display = getDisplay (); - width += display.scrolledMarginX; - height += display.scrolledMarginY; - if (wHint != SWT.DEFAULT) width = wHint + (border * 2); - if (hHint != SWT.DEFAULT) height = hHint + (border * 2); + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricDisclosureTriangleHeight, outMetric); + int width = outMetric [0], height = outMetric [0]; + if (wHint != SWT.DEFAULT) width = wHint; + if (hHint != SWT.DEFAULT) height = hHint; return new Point (width, height); } - /* AW - XtWidgetGeometry result = new XtWidgetGeometry (); - result.request_mode = OS.CWWidth | OS.CWHeight; - int [] argList2 = {OS.XmNrecomputeSize, 1}; - OS.XtSetValues(handle, argList2, argList2.length / 2); - OS.XtQueryGeometry (handle, null, result); - int [] argList3 = {OS.XmNrecomputeSize, 0}; - OS.XtSetValues(handle, argList3, argList3.length / 2); - */ - Point result= MacUtil.computeSize(handle); - if ((style & SWT.PUSH) != 0) { - if (image != null) { // is a Bevel button! - Rectangle bounds= image.getBounds(); - result.x= 4 + bounds.width + 4; - result.y= 4 + bounds.height + 4; - } else { - String s= getText(); - if (s != null && s.length() > 0) { - result.x= result.x - 2*SPACE + 2*MARGIN; - result.y= result.y + TOP_MARGIN + BOTTOM_MARGIN; + + int width = 0, height = 0; + + if (isImage && image != null) { + Rectangle bounds = image.getBounds(); + width = bounds.width; + height = bounds.height; + } else { + int [] ptr = new int [1]; + OS.CopyControlTitleAsCFString(handle, ptr); + if (ptr [0] != 0) { + if (font == null) { + org.eclipse.swt.internal.carbon.Point ioBounds = new org.eclipse.swt.internal.carbon.Point (); + short [] baseLine = new short [1]; + OS.GetThemeTextDimensions(ptr [0], (short)OS.kThemePushButtonFont, OS.kThemeStateActive, false, ioBounds, baseLine); + width = ioBounds.h; + height = ioBounds.v; + } else { + // NEEDS WORK - alternatively we could use GetThemeTextDimensions with OS.kThemeCurrentPortFont + int length = OS.CFStringGetLength (ptr [0]); + char [] buffer = new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (ptr [0], range, buffer); + String string = new String (buffer); + GC gc = new GC (this); + Point extent = gc.stringExtent (string); + gc.dispose (); + width = extent.x; + height = extent.y; } + OS.CFRelease (ptr [0]); + } else { + width = DEFAULT_WIDTH; + height = DEFAULT_HEIGHT; } } - width += result.x; - height += result.y; + + if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { + int [] outMetric = new int [1]; + int metric = ((style & SWT.CHECK) != 0) ? OS.kThemeMetricCheckBoxWidth : OS.kThemeMetricRadioButtonWidth; + OS.GetThemeMetric (metric, outMetric); + width += outMetric [0] + 3; // +3 for gap between button and text/image + height = Math.max(outMetric [0], height); + } else { + if ((style & SWT.FLAT) != 0 || (style & SWT.TOGGLE) != 0) { + width += 10; + height += 10; + } else { + width += 28; + height += 8; + } + } + + Rect inset = getInset (); + width += inset.left + inset.right; + height += inset.top + inset.bottom; + /* - * Feature in Motif. If a button's labelType is XmSTRING but it - * has no label set into it yet, recomputing the size will - * not take into account the height of the font, as we would - * like it to. Take care of this case. + * Feature in Mac OS X. Setting the width of a bevel button + * widget to less than 20 will fail. This means you can not + * make a button very small. By forcing the width to be greater + * than or equal to 20, the height of the button can be made + * very small, even 0. */ - /* AW - int [] argList = {OS.XmNlabelType, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - if (argList [1] == OS.XmSTRING) { - int [] argList1 = {OS.XmNlabelString, 0}; - OS.XtGetValues (handle, argList1, argList1.length / 2); - int xmString = argList1 [1]; - if (OS.XmStringEmpty (xmString)) height += getFontHeight (); - } - */ - if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) { - /* AW - int [] argList4 = new int [] {OS.XmNmarginLeft, 0, OS.XmNmarginRight, 0, OS.XmNmarginTop, 0, OS.XmNmarginBottom, 0}; - OS.XtGetValues (handle, argList4, argList4.length / 2); - if (wHint != SWT.DEFAULT) width = wHint + argList4 [1] + argList4 [3] + (border * 2); - if (hHint != SWT.DEFAULT) height = hHint + argList4 [5] + argList4 [7] + (border * 2); - */ - int left= 0; - int right= 0; - int top= 0; - int bottom= 0; - - if (wHint != SWT.DEFAULT) width = wHint + left + right; - if (hHint != SWT.DEFAULT) height = hHint + top + bottom; - } - - return new Point(width, height); + width = Math.max(20, width); + int border = (style & SWT.PUSH) != 0 ? 2 : 0; + 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 |= HANDLE; - /* AW - int borderWidth = (style & SWT.BORDER) != 0 ? 1 : 0; - */ - int parentHandle = parent.handle; - /* ARROW button */ +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + if ((style & SWT.ARROW) != 0) { - /* - int alignment = OS.XmARROW_UP; - if ((style & SWT.UP) != 0) alignment = OS.XmARROW_UP; - if ((style & SWT.DOWN) != 0) alignment = OS.XmARROW_DOWN; - if ((style & SWT.LEFT) != 0) alignment = OS.XmARROW_LEFT; - if ((style & SWT.RIGHT) != 0) alignment = OS.XmARROW_RIGHT; - int [] argList = { - OS.XmNtraversalOn, 0, - OS.XmNarrowDirection, alignment, - OS.XmNborderWidth, borderWidth, - OS.XmNancestorSensitive, 1, - }; - handle = OS.XmCreateArrowButton (parentHandle, null, argList, argList.length / 2); - */ - handle= MacUtil.newControl(parentHandle, (short)OS.kControlBevelButtonNormalBevelProc); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - int kThemeDisclosureRight = 0; - int kThemeDisclosureDown = 1; - int kThemeDisclosureLeft = 2; - int kThemeDisclosureButton = 6; - int kControlBevelButtonKindTag = ('b'<<24) + ('e'<<16) + ('b'<<8) + 'k'; - int orientation = kThemeDisclosureRight; - if ((style & SWT.UP) != 0) orientation = kThemeDisclosureRight; // NEEDS WORK - if ((style & SWT.DOWN) != 0) orientation = kThemeDisclosureDown; - if ((style & SWT.LEFT) != 0) orientation = kThemeDisclosureLeft; - OS.SetControlData (handle, OS.kControlEntireControl, kControlBevelButtonKindTag, new short [] {(short)(kThemeDisclosureButton)}); + int orientation = OS.kThemeDisclosureRight; + if ((style & SWT.UP) != 0) orientation = OS.kThemeDisclosureRight; // NEEDS WORK + if ((style & SWT.DOWN) != 0) orientation = OS.kThemeDisclosureDown; + if ((style & SWT.LEFT) != 0) orientation = OS.kThemeDisclosureLeft; + OS.CreateBevelButtonControl(window, null, 0, (short)0, (short)OS.kControlBehaviorPushbutton, 0, (short)0, (short)0, (short)0, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonKindTag, 2, new short [] {(short)(OS.kThemeDisclosureButton)}); OS.SetControl32BitMaximum (handle, 2); OS.SetControl32BitValue (handle, orientation); - /* AW - if ((style & SWT.FLAT) != 0) { - int [] argList1 = {OS.XmNshadowThickness, 1}; - OS.XtSetValues (handle, argList1, argList1.length / 2); - } - */ - return; } - - /* Compute alignment */ - /* AW - int alignment = OS.XmALIGNMENT_BEGINNING; - if ((style & SWT.CENTER) != 0) alignment = OS.XmALIGNMENT_CENTER; - if ((style & SWT.RIGHT) != 0) alignment = OS.XmALIGNMENT_END; - */ - - /* TOGGLE button */ + + if ((style & SWT.CHECK) != 0) { + //OS.CreateCheckBoxControl (window, null, 0, 0 /*initially off*/, true, outControl); + OS.CreateBevelButtonControl(window, null, 0, (short)0, (short)OS.kControlBehaviorToggles, 0, (short)0, (short)0, (short)0, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonKindTag, 2, new short [] {(short)OS.kThemeCheckBox}); + } + + if ((style & SWT.RADIO) != 0) { + //OS.CreateRadioButtonControl(window, null, 0, 0 /*initially off*/, true, outControl); + OS.CreateBevelButtonControl(window, null, 0, (short)0, (short)OS.kControlBehaviorToggles, 0, (short)0, (short)0, (short)0, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonKindTag, 2, new short [] {(short)OS.kThemeRadioButton}); + } + if ((style & SWT.TOGGLE) != 0) { - /* - * Bug in Motif. When XmNindicatorOn is set to false, - * Motif doesn't reset the shadow thickness to give a - * push button look. The fix is to set the shadow - * thickness when ever this resource is changed. - */ - /* AW - Display display = getDisplay (); - int thickness = display.buttonShadowThickness; - int [] argList = { - OS.XmNancestorSensitive, 1, - OS.XmNrecomputeSize, 0, - OS.XmNindicatorOn, 0, - OS.XmNshadowThickness, (style & SWT.FLAT) != 0 ? 1 : thickness, - OS.XmNalignment, alignment, - OS.XmNborderWidth, borderWidth, - }; - handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2); - */ - handle= MacUtil.newControl(parentHandle, (short)0, OS.kControlBehaviorToggles, (short)0, OS.kControlBevelButtonNormalBevelProc); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - setFont(defaultFont()); - return; + OS.CreateBevelButtonControl(window, null, 0, (short)OS.kControlBevelButtonNormalBevel, (short)OS.kControlBehaviorToggles, 0, (short)0, (short)0, (short)0, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + if ((style & SWT.FLAT) == 0 ) { + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonKindTag, 2, new short [] {(short)OS.kThemeRoundedBevelButton}); + } } - - /* CHECK or RADIO button */ - if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { - /* - * Bug in Motif. For some reason, a toggle button - * with XmNindicatorType XmONE_OF_MANY must have this - * value set at creation or the highlight color will - * not be correct. The fix is to set these values - * on create. - */ - /* AW - int indicatorType = OS.XmONE_OF_MANY; - if ((style & SWT.CHECK) != 0) indicatorType = OS.XmN_OF_MANY; - int [] argList = { - OS.XmNancestorSensitive, 1, - OS.XmNrecomputeSize, 0, - OS.XmNindicatorType, indicatorType, - OS.XmNalignment, alignment, - OS.XmNborderWidth, borderWidth, - }; - handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2); - */ - short type= (style & SWT.CHECK) != 0 - ? OS.kControlCheckBoxAutoToggleProc - : OS.kControlRadioButtonAutoToggleProc; - handle= MacUtil.newControl(parentHandle, (short)0, (short)0, (short)100, type); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - setFont(defaultFont()); - return; + + if ((style & SWT.PUSH) != 0) { + if ((style & SWT.FLAT) != 0) { + OS.CreateBevelButtonControl(window, null, 0, (short)2, (short)OS.kControlBehaviorPushbutton, 0, (short)0, (short)0, (short)0, outControl); + } else { + OS.CreatePushButtonControl (window, null, 0, outControl); + //OS.CreateBevelButtonControl(window, null, 0, (short)2, (short)OS.kControlBehaviorPushbutton, 0, (short)0, (short)0, (short)0, outControl); + } + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + if ((style & SWT.FLAT) == 0 ) { + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonKindTag, 2, new short [] {(short)OS.kThemePushButton}); + } } - /* PUSH button */ - /* AW - int [] argList = { - OS.XmNancestorSensitive, 1, - OS.XmNrecomputeSize, 0, - OS.XmNalignment, alignment, - OS.XmNborderWidth, borderWidth, - */ - short type= (style & SWT.FLAT) != 0 - ? OS.kControlBevelButtonNormalBevelProc - : OS.kControlPushButtonProc; - handle= MacUtil.newControl(parentHandle, type); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - setFont(defaultFont()); - /* AW - if ((style & SWT.FLAT) != 0) { - int [] argList1 = {OS.XmNshadowThickness, 1}; - OS.XtSetValues (handle, argList1, argList1.length / 2); + ControlFontStyleRec fontRec = new ControlFontStyleRec(); + fontRec.flags = (short) OS.kControlUseThemeFontIDMask; + fontRec.font = (short) defaultThemeFont (); + OS.SetControlFontStyle (handle, fontRec); + + if ((style & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) != 0) { + int textAlignment = 0; + int graphicAlignment = 0; + if ((style & SWT.LEFT) != 0) { + textAlignment = OS.kControlBevelButtonAlignTextFlushLeft; + graphicAlignment = OS.kControlBevelButtonAlignLeft; + } + if ((style & SWT.CENTER) != 0) { + textAlignment = OS.kControlBevelButtonAlignTextCenter; + graphicAlignment = OS.kControlBevelButtonAlignCenter; + } + if ((style & SWT.RIGHT) != 0) { + textAlignment = OS.kControlBevelButtonAlignTextFlushRight; + graphicAlignment = OS.kControlBevelButtonAlignRight; + } + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonTextAlignTag, 2, new short [] {(short)textAlignment}); + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonGraphicAlignTag, 2, new short [] {(short)graphicAlignment}); } - */ -} -int defaultBackground () { - return getDisplay ().buttonBackground; } -Font defaultFont () { - return getDisplay ().buttonFont; -} -int defaultForeground () { - return getDisplay ().buttonForeground; + +int defaultThemeFont () { + return OS.kThemePushButtonFont; } -/** - * 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(); - return fAlignment; -} -boolean getDefault () { - if ((style & SWT.PUSH) == 0) return false; - int[] control= new int[1]; - OS.GetWindowDefaultButton(OS.GetControlOwner(handle), control); - return control[0] == handle; + 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; } -/** - * 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; @@ -395,128 +239,73 @@ public Image getImage () { String getNameText () { return getText (); } -/** - * Returns <code>true</code> if the receiver is selected, - * and false otherwise. - * <p> - * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>, - * it is selected when it is checked. When it is of type <code>TOGGLE</code>, - * it is selected when it is pushed 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(); + checkWidget (); if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false; return OS.GetControl32BitValue(handle) != 0; } -/** - * Returns the receiver's text, which will be an empty - * string if it has never been set. - * - * @return the receiver's text - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public String getText () { - checkWidget(); - if ((style & SWT.ARROW) != 0) return ""; - int sHandle[]= new int[1]; - OS.GetControlTitleAsCFString(handle, sHandle); - return MacUtil.getStringAndRelease(sHandle[0]); -} -void hookEvents () { - super.hookEvents (); - /* AW - int callback = OS.XmNactivateCallback; - int windowProc = getDisplay ().windowProc; - if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) callback = OS.XmNvalueChangedCallback; - OS.XtAddCallback (handle, callback, windowProc, SWT.Selection); - */ - if (MacUtil.HIVIEW) { - Display display= getDisplay(); - OS.SetControlAction(handle, display.fControlActionProc); - } + checkWidget (); + return text; } -boolean mnemonicHit (char key) { - if (!setFocus ()) return false; - click (); - return true; -} -/* AW -boolean mnemonicMatch (char key) { - char mnemonic = findMnemonic (getText ()); - if (mnemonic == '\0') return false; - return Character.toUpperCase (key) == Character.toUpperCase (mnemonic); -} -*/ -int processFocusIn () { - super.processFocusIn (); - // widget could be disposed at this point - if (handle == 0) return 0; - if ((style & SWT.PUSH) == 0) return 0; - getShell ().setDefaultButton (this, false); - return 0; + +Rect getInset () { + if ((style & SWT.PUSH) == 0) return super.getInset(); + Display display = getDisplay (); + return display.buttonInset; } -int processFocusOut () { - super.processFocusOut (); - // widget could be disposed at this point - if (handle == 0) return 0; - if ((style & SWT.PUSH) == 0) return 0; - if (getDefault ()) { - getShell ().setDefaultButton (null, false); + +int kEventControlDraw (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlDraw (nextHandler, theEvent, userData); + if (isImage && image != null && (style & SWT.PUSH) != 0 && (style & SWT.FLAT) == 0) { + Rect rect = new Rect(); + OS.GetControlBounds (handle, rect); + int width = OS.CGImageGetWidth (image.handle); + int height = OS.CGImageGetHeight (image.handle); + int x = Math.max (0, (rect.right - rect.left - width) / 2); + int y = Math.max (0, (rect.bottom - rect.top - height) / 2); + GCData data = new GCData (); + data.paintEvent = theEvent; + GC gc = GC.carbon_new (this, data); + gc.drawImage (image, x, y); + gc.dispose (); + return OS.noErr; } - return 0; + return result; } -int processSelection (Object callData) { + +int kEventControlHit (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlHit (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; if ((style & SWT.RADIO) != 0) { - if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) selectRadio (); + if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) { + selectRadio (); + } } - return super.processSelection (callData); + postEvent (SWT.Selection); + return OS.eventNotHandledErr; } + +int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlSetFocusPart (nextHandler, theEvent, userData); + if ((style & SWT.PUSH) != 0) { + short [] part = new short [1]; + OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part); + menuShell ().setDefaultButton ((part [0] != 0) ? this : null, false); + } + return result; +} + void releaseWidget () { super.releaseWidget (); - /* - int [] argList = { - OS.XmNlabelPixmap, OS.XmUNSPECIFIED_PIXMAP, - OS.XmNlabelInsensitivePixmap, OS.XmUNSPECIFIED_PIXMAP, - }; - OS.XtSetValues (handle, argList, argList.length / 2); - */ - if (fCIconHandle != 0) { - if (handle != 0) - OS.SetBevelButtonContentInfo(handle, (short)0, 0); - Image.disposeCIcon(fCIconHandle); - fCIconHandle= 0; - } - image = null; + if (cIcon != 0) { + destroyCIcon (cIcon); + cIcon = 0; + } } -/** - * Removes the listener from the collection of listeners who will - * be notified when the control is selected. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ + public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -524,217 +313,158 @@ public void removeSelectionListener(SelectionListener listener) { 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 instanceof Button) { - Button button = (Button) child; - if ((button.getStyle () & SWT.RADIO) != 0) { - if (button.getSelection ()) { - button.setSelection (false); - button.postEvent (SWT.Selection); - } - } - } + 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) { - fAlignment= alignment; - System.out.println("Button.setAlignment: nyi"); + 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); + int orientation = OS.kThemeDisclosureRight; + if ((style & SWT.UP) != 0) orientation = OS.kThemeDisclosureRight; // NEEDS WORK + if ((style & SWT.DOWN) != 0) orientation = OS.kThemeDisclosureDown; + if ((style & SWT.LEFT) != 0) orientation = OS.kThemeDisclosureLeft; + OS.SetControl32BitValue (handle, orientation); return; } if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return; - fAlignment= alignment; - System.out.println("Button.setAlignment: nyi"); + style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER); + style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER); + int textAlignment = 0; + int graphicAlignment = 0; + if ((style & SWT.LEFT) != 0) { + textAlignment = OS.kControlBevelButtonAlignTextFlushLeft; + graphicAlignment = OS.kControlBevelButtonAlignLeft; + } + if ((style & SWT.CENTER) != 0) { + textAlignment = OS.kControlBevelButtonAlignTextCenter; + graphicAlignment = OS.kControlBevelButtonAlignCenter; + } + if ((style & SWT.RIGHT) != 0) { + textAlignment = OS.kControlBevelButtonAlignTextFlushRight; + graphicAlignment = OS.kControlBevelButtonAlignRight; + } + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonTextAlignTag, 2, new short [] {(short)textAlignment}); + OS.SetControlData (handle, OS.kControlEntireControl, OS.kControlBevelButtonGraphicAlignTag, 2, new short [] {(short)graphicAlignment}); + redraw (); } + +public void setBounds (int x, int y, int width, int height) { + checkWidget (); + /* Bug in MacOS X. When setting the height of a bevel button + * to a value less than 20, the button is drawn incorrectly. + * The fix is to force the height to be greater than or equal to 20. + */ + if ((style & SWT.ARROW) == 0) { + height = Math.max (20, height); + } + super.setBounds (x, y, width, height); +} + void setDefault (boolean value) { if ((style & SWT.PUSH) == 0) return; - if (getShell ().parent == null) return; - OS.SetWindowDefaultButton(OS.GetControlOwner(handle), value ? handle : 0); + int window = OS.GetControlOwner (handle); + OS.SetWindowDefaultButton (window, value ? handle : 0); } -/** - * 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.ARROW) != 0) return; + if (cIcon != 0) { + destroyCIcon(cIcon); + cIcon = 0; + } this.image = image; + isImage = true; - if (fCIconHandle != 0) { - Image.disposeCIcon(fCIconHandle); - fCIconHandle= 0; + if (image == null) { + setText (text); + return; } - - if (image != null) { - if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); - fCIconHandle= Image.carbon_createCIcon(image); - if (fCIconHandle != 0) - setMode(fCIconHandle); - } else - setMode(0); + + if (text.length () > 0) { + char [] buffer = new char [] {' '}; + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + OS.SetControlTitleWithCFString (handle, ptr); + OS.CFRelease (ptr); + } + + cIcon = createCIcon (image); + ControlButtonContentInfo inContent = new ControlButtonContentInfo (); + inContent.contentType = (short)OS.kControlContentCIconHandle; + inContent.iconRef = cIcon; + OS.SetBevelButtonContentInfo (handle, inContent); + redraw (); } -/** - * 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> - */ + +boolean setRadioSelection (boolean value){ + if ((style & SWT.RADIO) == 0) return false; + if (getSelection () != value) { + setSelection (value); + postEvent (SWT.Selection); + } + return true; +} + public void setSelection (boolean selected) { checkWidget(); if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return; - OS.SetControl32BitValue(handle, selected ? 1 : 0); + OS.SetControl32BitValue (handle, selected ? 1 : 0); } -/** - * Sets the receiver's text. - * <p> - * This method sets the button label. The label may include - * the mnemonic character but must not contain line delimiters. - * </p> - * - * @param string the new text - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the text is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); if ((style & SWT.ARROW) != 0) return; - - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(MacUtil.removeMnemonics(string)); - if (OS.SetControlTitleWithCFString(handle, sHandle) != OS.kNoErr) - error (SWT.ERROR_CANNOT_SET_TEXT); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } -} - -int traversalCode () { - int code = super.traversalCode (); - if ((style & SWT.PUSH) != 0) return code; - return code | SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS; -} - -//////////////////////////////////////////////////////// -// Mac stuff -//////////////////////////////////////////////////////// - -private void setMode(int icon) { - - if ((style & SWT.FLAT) != 0 || fImageMode) { - OS.SetBevelButtonContentInfo(handle, OS.kControlContentCIconHandle, icon); - redraw(); - return; + text = string; + if (isImage) { + ControlButtonContentInfo inContent = new ControlButtonContentInfo(); + inContent.contentType = (short)OS.kControlContentTextOnly; + OS.SetBevelButtonContentInfo(handle, inContent); } - - if ((style & SWT.PUSH) == 0) - return; // we only transmogrify push buttons - - fImageMode= true; - - int[] ph= new int[1]; - int rc= OS.GetSuperControl(handle, ph); - if (rc != OS.kNoErr) - System.out.println("Button.setMode: " + rc); - int parentHandle= ph[0]; - - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - - int index= MacUtil.indexOf(parentHandle, handle); - if (index < 0) - System.out.println("Button.setMode: can't find handle"); - Widget w= WidgetTable.get(handle); - WidgetTable.remove(handle); - OS.DisposeControl(handle); - - short type= icon != 0 ? OS.kControlBevelButtonNormalBevelProc : OS.kControlPushButtonProc; - - handle= MacUtil.newControl(parentHandle, index, (short)0, (short)0, (short)0, type); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - WidgetTable.put(handle, w); - - OS.SetControlBounds(handle, bounds.getData()); - OS.SetBevelButtonContentInfo(handle, OS.kControlContentCIconHandle, icon); -} - -/** - * Overridden from Control. - * x and y are relative to window! - */ -void handleResize(int hndl, MacRect bounds) { - fTopMargin= fBottomMargin= 0; - if ((style & SWT.PUSH) != 0 && image == null) { // for push buttons - Point result= MacUtil.computeSize(hndl); - int diff= bounds.getHeight()-result.y; - fTopMargin= diff/2; - fBottomMargin= diff-fTopMargin; - bounds.inset(MARGIN, fTopMargin, MARGIN, fBottomMargin); + isImage = false; + int length = text.length (); + String s = (length == 0) ? " ": text; + char [] buffer = new char [length]; + s.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} + j--; + } } - super.handleResize(hndl, bounds); -} - -void internalGetControlBounds(int hndl, MacRect bounds) { - super.internalGetControlBounds(hndl, bounds); - if ((style & SWT.PUSH) != 0 && image == null) - bounds.inset(-MARGIN, -fTopMargin, -MARGIN, -fBottomMargin); -} - -public void setFont (Font font) { - super.setFont(null); -} - -int sendKeyEvent(int type, MacEvent mEvent, Event event) { - return OS.CallNextEventHandler(mEvent.getNextHandler(), mEvent.getEventRef()); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + OS.SetControlTitleWithCFString (handle, ptr); + OS.CFRelease (ptr); + redraw (); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java index 052b37c308..9540a1408a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java @@ -7,200 +7,70 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.*; + 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 - */ public class Canvas extends Composite { Caret caret; Canvas () { /* Do nothing */ } -/** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * 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 Canvas (Composite parent, int style) { super (parent, 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 - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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; } -/* AW -short [] getIMECaretPos () { - if (caret == null) return super.getIMECaretPos (); - int width = caret.width; - if (width <= 0) width = 2; - return new short[]{(short) (caret.x + width), (short) (caret.y + caret.height)}; -} -*/ -int processFocusIn () { - int result = super.processFocusIn (); - if (caret != null) caret.setFocus (); - return result; -} -int processFocusOut () { - int result = super.processFocusOut (); - if (caret != null) caret.killFocus (); - return result; -} -int processPaint (Object callData) { +int kEventControlDraw (int nextHandler, int theEvent, int userData) { boolean isFocus = caret != null && caret.isFocusCaret (); if (isFocus) caret.killFocus (); - int result = super.processPaint (callData); + int result = super.kEventControlDraw (nextHandler, theEvent, userData); if (isFocus) caret.setFocus (); return result; } -void redrawWidget (int x, int y, int width, int height, boolean all) { - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - super.redrawWidget (x, y, width, height, all); - if (isFocus) caret.setFocus (); +int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlSetFocusPart (nextHandler, theEvent, userData); + if (caret != null) { + short [] part = new short [1]; + OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part); + if (part [0] != 0) { + caret.setFocus (); + } else { + caret.killFocus (); + } + } + return result; } void releaseWidget () { - if (caret != null) { - caret.releaseWidget (); - caret.releaseHandle (); - } + if (caret != null) caret.releaseResources (); caret = null; - super.releaseWidget(); + super.releaseWidget (); } -/** - * Scrolls a rectangular area of the receiver by first copying - * the source area to the destination and then causing the area - * of the source which is not covered by the destination to - * be repainted. Children that intersect the rectangle are - * optionally moved during the operation. In addition, outstanding - * paint events are flushed before the source area is copied to - * ensure that the contents of the canvas are drawn correctly. - * - * @param destX the x coordinate of the destination - * @param destY the y coordinate of the destination - * @param x the x coordinate of the source - * @param y the y coordinate of the source - * @param width the width of the area - * @param height the height of the area - * @param all <code>true</code>if children should be scrolled, and <code>false</code> otherwise - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ 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; - - /* Hide the caret */ boolean isFocus = caret != null && caret.isFocusCaret (); if (isFocus) caret.killFocus (); - - /* Flush outstanding exposes */ - getDisplay().update (); - - GC gc= new GC(this); - gc.copyArea(x, y, width, height, destX, destY); - gc.dispose(); - - /* Show the caret */ - if (isFocus) caret.setFocus (); -} -public void setBounds (int x, int y, int width, int height) { - checkWidget(); - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - super.setBounds (x, y, width, height); + update (); + GC gc = new GC (this); + gc.copyArea (x, y, width, height, destX, destY); + gc.dispose (); if (isFocus) caret.setFocus (); } -/** - * Sets the receiver's caret. - * <p> - * The caret for the control is automatically hidden - * and shown when the control is painted or resized, - * when focus is gained or lost and when an the control - * is scrolled. To avoid drawing on top of the caret, - * the programmer must hide and show the caret when - * drawing in the window any other time. - * </p> - * @param caret the new caret for the receiver, may be null - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setCaret (Caret caret) { checkWidget(); Caret newCaret = caret; @@ -215,36 +85,4 @@ public void setCaret (Caret caret) { } } -public void setFont (Font font) { - checkWidget(); - super.setFont (font); - if (caret != null) caret.setFont (font); -} - -public void setLocation (int x, int y) { - checkWidget(); - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - super.setLocation (x, y); - if (isFocus) caret.setFocus (); -} -public void setSize (int width, int height) { - checkWidget(); - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - super.setSize (width, height); - if (isFocus) caret.setFocus (); -} -void updateCaret () { - if (caret == null) return; - /* AW - if (!IsDBLocale) return; - short [] point = getIMECaretPos (); - int ptr = OS.XtMalloc (4); - OS.memmove (ptr, point, 4); - int[] argList = {OS.XmNspotLocation, ptr}; - OS.XmImSetValues (handle, argList, argList.length / 2); - if (ptr != 0) OS.XtFree (ptr); - */ -} -} +}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java index e4dd73c62a..7f13cb1678 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java @@ -7,83 +7,46 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.RGBColor; +import org.eclipse.swt.internal.carbon.Rect; + 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> - */ -public /*final*/ class Caret extends Widget { +public class Caret extends Widget { Canvas parent; - Image image; int x, y, width, height; - boolean moved, resized; boolean isVisible, isShowing; - int blinkRate = (OS.GetCaretTime() * 1000) / 60; - 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; + Image image; + public Caret (Canvas parent, int style) { super (parent, style); this.parent = parent; - createWidget (0); + createWidget (); } + boolean blinkCaret () { if (!isVisible) return true; if (!isShowing) return showCaret (); if (blinkRate == 0) return true; return hideCaret (); } -void createWidget (int index) { - super.createWidget (index); + +void createWidget () { + super.createWidget (); + Display display = parent.getDisplay (); + blinkRate = display.getCaretBlinkTime (); 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; int nWidth = width, nHeight = height; if (image != null) { Rectangle rect = image.getBounds (); @@ -91,127 +54,70 @@ boolean drawCaret () { nHeight = rect.height; } if (nWidth <= 0) nWidth = 2; - - int clipRgn= OS.NewRgn(); - MacUtil.getVisibleRegion(parent.handle, clipRgn, true); - - MacRect bounds= new MacRect(); - OS.GetControlBounds(parent.handle, bounds.getData()); - bounds= new MacRect(x+bounds.getX(), y+bounds.getY(), nWidth, nHeight); - - int caretRgn= OS.NewRgn(); - OS.RectRgn(caretRgn, bounds.getData()); - OS.SectRgn(caretRgn, clipRgn, caretRgn); - - if (!OS.EmptyRgn(caretRgn)) { - int port= OS.GetPort(); - OS.SetPortWindowPort(OS.GetControlOwner(handle)); - OS.InvertRgn(caretRgn); - OS.SetPort(port); - } - - OS.DisposeRgn(clipRgn); - OS.DisposeRgn(caretRgn); - + int parentHandle = parent.handle; + int window = OS.GetControlOwner (parentHandle); + int port = OS.GetWindowPort (window); + int [] currentPort = new int [1]; + OS.GetPort (currentPort); + OS.SetPort (port); + int oldClip = OS.NewRgn (); + int visibleRgn = getVisibleRegion (parentHandle); + OS.GetClip (oldClip); + OS.SetClip (visibleRgn); + Rect rect = new Rect (); + OS.GetControlBounds (parentHandle, rect); + int left = rect.left + x; + int top = rect.top + y; + OS.SetRect(rect, (short) left, (short) top, (short) (left + nWidth), (short) (top + nHeight)); + RGBColor color = new RGBColor (); + color.red = (short) 0xFFFF; + color.green = (short) 0xFFFF; + color.blue = (short) 0xFFFF; + OS.RGBBackColor (color); + OS.InvertRect (rect); + OS.SetClip (oldClip); + OS.DisposeRgn (visibleRgn); + OS.DisposeRgn (oldClip); + OS.SetPort (currentPort [0]); 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 (); - rect.x= x; - rect.y= y; - return rect; + return new Rectangle (x, y, rect.width, rect.height); } return new Rectangle (x, y, width, height); } -/** -* Gets the Display. -*/ + public Display getDisplay () { Composite parent = this.parent; if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getDisplay (); } -/** - * Returns the font that the receiver will use to paint textual information. - * - * @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) { @@ -220,284 +126,131 @@ public Point getSize () { } 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 () { - Display display = getDisplay (); - if (display.currentCaret != this) return false; 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; } + void killFocus () { Display display = getDisplay (); if (display.currentCaret != this) return; - if (isVisible) hideCaret (); display.setCurrentCaret (null); + if (isVisible) hideCaret (); } + void releaseChild () { super.releaseChild (); if (this == parent.getCaret ()) parent.setCaret (null); } + void releaseWidget () { super.releaseWidget (); Display display = getDisplay (); if (display.currentCaret == this) { - if (isVisible) hideCaret (); + 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(); - boolean samePosition, sameExtent; - samePosition = (this.x == x) && (this.y == y); - sameExtent = (this.width == width) && (this.height == height); - if ((samePosition) && (sameExtent)) return; - if (isShowing) hideCaret (); + if (this.x == x && this.y == y && this.width == width && this.height == height) return; + boolean isFocus = isFocusCaret (); + if (isFocus) hideCaret (); this.x = x; this.y = y; this.width = width; this.height = height; - if (sameExtent) { - moved = true; - if (isVisible ()) { - moved = false; - parent.updateCaret (); - } - } else { - resized = true; - if (isVisible ()) { - moved = false; - parent.updateCaret (); - resized = false; - } - } - if (isShowing) showCaret (); +// parent.updateCaret (); + if (isFocus) showCaret (); } -/** - * Sets the receiver's size and location to the rectangular - * area specified by the argument. The <code>x</code> and - * <code>y</code> fields of the rectangle are relative to - * the receiver's parent (or its display if its parent is null). - * - * @param rect the new bounds for the receiver - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setBounds (Rectangle rect) { checkWidget(); if (rect == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (rect.x, rect.y, rect.width, rect.height); } + void setFocus () { Display display = getDisplay (); if (display.currentCaret == this) return; display.setCurrentCaret (this); if (isVisible) showCaret (); } -/** - * Sets the font that the receiver will use to paint textual information - * to the font specified by the argument, or to the default font for that - * 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 font the new font (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); } - if (isShowing) hideCaret (); + boolean isFocus = isFocusCaret (); + if (isFocus) hideCaret (); this.image = image; - if (isShowing) showCaret (); + if (isFocus) 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 - * @param height the new height for the receiver - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the point is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setSize (Point size) { checkWidget(); if (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; - if (isVisible = visible) { + isVisible = visible; + if (!isFocusCaret ()) return; + if (isVisible) { showCaret (); } else { hideCaret (); } } + boolean showCaret () { - if (getDisplay ().currentCaret != this) return false; if (isShowing) return true; isShowing = true; return drawCaret (); } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ColorDialog.java index ad109e0de1..4a6ea63149 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ColorDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ColorDialog.java @@ -12,134 +12,61 @@ import org.eclipse.swt.widgets.*; import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.graphics.RGB; -/** - * Instances of this class allow the user to select a color - * from a predefined set of available colors. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>(none)</dd> - * <dt><b>Events:</b></dt> - * <dd>(none)</dd> - * </dl> - * <p> - * IMPORTANT: This class is intended to be subclassed <em>only</em> - * within the SWT implementation. - * </p> - */ -public /*final*/ class ColorDialog extends Dialog { - - private RGB rgb; - private short[] fColor= new short[3]; +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 (cannot be null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - * - * @see SWT - * @see Widget#checkSubclass - * @see Widget#getStyle - */ public ColorDialog(Shell parent) { - this(parent, SWT.NULL); + 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, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL); + super(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() { - MacPoint mp= new MacPoint(); - OS.GetGlobalMouse(mp.getData()); - - boolean[] success= new boolean[1]; - if (OS.PickColor(fColor, mp.getData(), MacUtil.Str255(title), success) == OS.kNoErr) { - if (success[0]) { - if (rgb == null) - rgb= new RGB(0, 0, 0); - rgb.red= (fColor[0] >> 8) & 0xff; - rgb.green= (fColor[1] >> 8) & 0xff; - rgb.blue= (fColor[2] >> 8) & 0xff; - } else - rgb= null; - } else - rgb= null; - +public RGB open() { + ColorPickerInfo info = new ColorPickerInfo (); + if (rgb != null) { + info.red = (short)(rgb.red * 257); + info.green = (short)(rgb.green * 257); + info.blue = (short)(rgb.blue * 257); + } else { + info.red = (short)(255 * 257); + info.green = (short)(255 * 257); + info.blue = (short)(255 * 257); + } + info.flags = OS.kColorPickerDialogIsMoveable | OS.kColorPickerDialogIsModal; + // NEEDS WORK - shouldn't be at mouse location + info.placeWhere = (short)OS.kAtSpecifiedOrigin; + org.eclipse.swt.internal.carbon.Point mp = new org.eclipse.swt.internal.carbon.Point (); + OS.GetGlobalMouse (mp); + info.v = mp.v; + info.h = mp.h; + if (title != null) { + // NEEDS WORK - no title displayed + info.prompt = new byte[256]; + int length = title.length(); + if (length > 255) length = 255; + info.prompt [0] = (byte)length; + for (int i=0; i<length; i++) { + info.prompt [i+1] = (byte)title.charAt (i); + } + } + rgb = null; + if (OS.PickColor (info) == OS.noErr && info.newColorChosen) { + int red = (info.red >> 8) & 0xFF; + int green = (info.green >> 8) & 0xFF; + int blue = (info.blue >> 8) & 0xFF; + rgb = new RGB(red, green, blue); + } return rgb; } -/** - * Returns the receiver's selected color to be the argument. - * - * @param rgb the new RGB value for the selected color, may be - * null to let the platform to select a default when - * open() is called - * - * @see PaletteData#getRGBs - */ + public void setRGB(RGB rgb) { this.rgb = rgb; - fColor[0]= (short) (rgb.red * 257); - fColor[1]= (short) (rgb.green * 257); - fColor[2]= (short) (rgb.blue * 257); - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java index 3192a9a1de..4ae5ca8740 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java @@ -8,60 +8,20 @@ package org.eclipse.swt.widgets; */ import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.dnd.*; -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.CFRange; +import org.eclipse.swt.internal.carbon.CGRect; +import org.eclipse.swt.internal.carbon.Rect; -/** - * Instances of this class are controls that allow the user - * to choose an item from a list of items, or optionally - * enter a new value by typing it into an editable text - * field. Often, <code>Combo</code>s are used in the same place - * where a single selection <code>List</code> widget could - * be used but space is limited. A <code>Combo</code> takes - * less space than a <code>List</code> widget and shows - * similar information. - * <p> - * Note: Since <code>Combo</code>s can contain both a list - * and an editable text field, it is possible to confuse methods - * which access one versus the other (compare for example, - * <code>clearSelection()</code> and <code>deselectAll()</code>). - * The API documentation is careful to indicate either "the - * receiver's list" or the "the receiver's text field" to - * distinguish between the two cases. - * </p><p> - * Note that although this class is a subclass of <code>Composite</code>, - * it does not make sense to add children to it, or set a layout on it. - * </p> - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd> - * <dt><b>Events:</b></dt> - * <dd>DefaultSelection, Modify, Selection</dd> - * </dl> - * <p> - * 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 - */ -public /*final*/ class Combo extends Composite { +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 int LIMIT; - private static int fgCommandID= 6000; - private static final int FOCUS_BORDER= 3; - private static final int MARGIN= 2; - - private int menuHandle; - private int textLimit= LIMIT; /* * These values can be different on different platforms. @@ -71,173 +31,59 @@ public /*final*/ class Combo extends Composite { static { LIMIT = 0x7FFFFFFF; } + + // NEEDS WORK - is this handle being leaked? + int menuHandle; -/** - * 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)); } -/** - * Adds the argument to the end of the receiver's list. - * - * @param string the new item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li> - * </ul> - * - * @see #add(String,int) - */ + public void add (String string) { - checkWidget(); - if (string == null) error (SWT.ERROR_NULL_ARGUMENT); + checkWidget (); + if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - if (menuHandle != 0) { - if (OS.AppendMenuItemTextWithCFString(menuHandle, sHandle, 0, fgCommandID++, null) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_ADDED); - OS.SetControl32BitMaximum(handle, OS.CountMenuItems(menuHandle)); - } else { - if (OS.HIComboBoxAppendTextItem(handle, sHandle) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_ADDED); - } - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_ITEM_NOT_ADDED); + int result; + if ((style & SWT.READ_ONLY) != 0) { + result = OS.AppendMenuItemTextWithCFString (menuHandle, ptr, 0, 0, null); + } else { + result = OS.HIComboBoxAppendTextItem (handle, ptr, null); } + OS.CFRelease (ptr); + if (result != OS.noErr) error (SWT.ERROR_ITEM_NOT_ADDED); } -/** - * Adds the argument to the receiver's list at the given - * zero-relative index. - * <p> - * Note: To add an item at the end of the list, use the - * result of calling <code>getItemCount()</code> as the - * index or use <code>add(String)</code>. - * </p> - * - * @param string the new item - * @param index the index for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li> - * </ul> - * - * @see #add(String) - */ + public void add (String string, int index) { - checkWidget(); + checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - if (index == -1) error (SWT.ERROR_INVALID_RANGE); - - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - if (menuHandle != 0) { - if (OS.InsertMenuItemTextWithCFString(menuHandle, sHandle, (short)index, 0, fgCommandID++) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_ADDED); - OS.SetControl32BitMaximum(handle, OS.CountMenuItems(menuHandle)); - } else { - OS.HIComboBoxInsertTextItemAtIndex(handle, index, sHandle); - } - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); + int count = getItemCount (); + if (0 > index || index > count) error (SWT.ERROR_INVALID_RANGE); + + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_ITEM_NOT_ADDED); + int result; + if ((style & SWT.READ_ONLY) != 0) { + result = OS.InsertMenuItemTextWithCFString (menuHandle, ptr, (short)index, 0, 0); + } else { + result = OS.HIComboBoxInsertTextItemAtIndex (handle, index, ptr); } + OS.CFRelease (ptr); + if (result != OS.noErr) error (SWT.ERROR_ITEM_NOT_ADDED); } -/** - * 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 receiver's selection changes, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * <code>widgetSelected</code> is called when the combo's list selection changes. - * <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); @@ -245,13 +91,8 @@ public void addSelectionListener(SelectionListener listener) { addListener (SWT.Selection,typedListener); addListener (SWT.DefaultSelection,typedListener); } -static int checkStyle (int style) { - // AW only READ_ONLY is implemented - style &= ~SWT.DROP_DOWN; - style &= ~SWT.SIMPLE; - // AW - +static int checkStyle (int style) { /* * Feature in Windows. It is not possible to create * a combo box that has a border using Windows style @@ -278,705 +119,453 @@ static int checkStyle (int style) { if ((style & SWT.SIMPLE) != 0) return style & ~SWT.READ_ONLY; return style; } + 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(); - if (menuHandle == 0) - OS.SetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, new short[] { 0, 0 }); -} -public Point computeSize (int wHint, int hHint, boolean changed) { - checkWidget(); - /* AW - int [] argList = { - OS.XmNlist, 0, - OS.XmNtextField, 0, - OS.XmNitemCount, 0, - OS.XmNmarginWidth, 0, - OS.XmNshadowThickness, 0, - OS.XmNhighlightThickness, 0, - OS.XmNarrowSize, 0, - OS.XmNarrowSpacing, 0, - }; - OS.XtGetValues(handle, argList, argList.length / 2); - XtWidgetGeometry result = new XtWidgetGeometry (); - result.request_mode = OS.CWWidth; - OS.XtQueryGeometry (argList[1], null, result); - int width = result.width, height = getTextHeight(); - int[] argList2 = {OS.XmNmarginWidth, 0, OS.XmNshadowThickness, 0}; - OS.XtGetValues(argList[3], argList2, argList2.length / 2); - if ((style & SWT.READ_ONLY) == 0) width += (2 * argList[7]); - if ((style & SWT.DROP_DOWN) != 0) { - width += argList[13] + argList[15]; + if ((style & SWT.READ_ONLY) != 0) { + OS.SetControl32BitValue (handle, 0); } else { - int itemCount = (argList[5] == 0) ? 5 : argList[5]; - height += (getItemHeight () * itemCount); + char [] buffer = new char [0]; + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) return; + OS.SetControlData (handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, new int[] {ptr}); + OS.CFRelease (ptr); } - width += (2 * argList[9]) - + (2 * argList[11]) - + (2 * argList2[1]) - + (2 * argList2[3]); - if (argList[5] == 0) width = DEFAULT_WIDTH; - if (hHint != SWT.DEFAULT) height = hHint; +} + +public Point computeSize (int wHint, int hHint, boolean changed) { + checkWidget (); + // NEEDS WORK + int width = 100; + int height = 30; + Rect inset = getInset (); + width += inset.left + inset.right; + height += inset.top + inset.bottom; if (wHint != SWT.DEFAULT) width = wHint; - */ - - int width = wHint; - int height = hHint; - - if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) { - - Point e= MacUtil.computeSize(handle); - if (wHint == SWT.DEFAULT) - width= e.x; - if (hHint == SWT.DEFAULT) - height= e.y; - } - - width= 150; - height--; - -// width += 2*MARGIN; -// height += 2*MARGIN; -// if ((style & SWT.BORDER) != 0) { - width += 2*FOCUS_BORDER; - height += 2*FOCUS_BORDER; -// } - + if (hHint != SWT.DEFAULT) height = hHint; return new Point (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> - * - * @since 2.1 - */ + public void copy () { checkWidget (); - selectionToClipboard(); + int [] str = new int [1]; + short start, end; + if ((style & SWT.READ_ONLY) != 0) { + // NEEDS WORK - getting whole text, not just selection + int index = OS.GetControlValue (handle); + if (OS.CopyMenuItemTextAsCFString(menuHandle, (short)index, str) != OS.noErr) return; + start = 0; end = (short)OS.CFStringGetLength (str [0]); + if (start >= end) { + OS.CFRelease (str [0]); + return; + } + } else { + short [] s = new short [2]; + OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, s, null); + if (s [0] >= s [1]) return; + start = s [0]; end = s [1]; + if (OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, str, null) != OS.noErr) return; + } + CFRange range = new CFRange (); + range.location = start; + range.length = end - start; + int encoding = OS.CFStringGetSystemEncoding (); + int [] size = new int [1]; + OS.CFStringGetBytes (str [0], range, encoding, (byte)'?', true, null, 0, size); + byte [] buffer = new byte [size [0]]; + OS.CFStringGetBytes (str [0], range, encoding, (byte)'?', true, buffer, size [0], size); + OS.CFRelease (str [0]); + + OS.ClearCurrentScrap(); + int[] scrap = new int [1]; + OS.GetCurrentScrap (scrap); + OS.PutScrapFlavor(scrap [0], OS.kScrapFlavorTypeText, 0, buffer.length, buffer); } -void createHandle (int index) { - state |= HANDLE; + +void createHandle () { + // NEEDS WORK - SIMPLE if ((style & SWT.READ_ONLY) != 0) { - handle= MacUtil.newControl(parent.handle, (short)0, (short)-12345, (short)-1, (short)(OS.kControlPopupButtonProc+1)); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + /* From ControlDefinitions.h: + * + * Passing in a menu ID of -12345 causes the popup not to try and get the menu from a + * resource. Instead, you can build the menu and later stuff the MenuRef field in + * the popup data information. + */ + OS.CreatePopupButtonControl(window, null, 0, (short)-12345, false, (short)0, (short)0, 0, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; int[] menuRef= new int[1]; - OS.CreateNewMenu(20000, 0, menuRef); - menuHandle= menuRef[0]; - if (menuHandle == 0) error (SWT.ERROR_NO_HANDLES); + OS.CreateNewMenu ((short)0, 0, menuRef); + if (menuRef [0] == 0) error (SWT.ERROR_NO_HANDLES); + menuHandle = menuRef[0]; OS.SetControlPopupMenuHandle(handle, menuHandle); + OS.SetControl32BitMaximum(handle, 0x7FFF); } else { - int[] outComboBox= new int[1]; - OS.HIComboBoxCreate(outComboBox, OS.kHIComboBoxAutoSizeListAttribute); - handle= outComboBox[0]; - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - MacUtil.addControl(handle, parent.handle); - OS.HIViewSetVisible(handle, true); + int [] outControl = new int [1]; + CGRect rect = new CGRect (); + int inAttributes = OS.kHIComboBoxAutoCompletionAttribute | OS.kHIComboBoxAutoSizeListAttribute; + OS.HIComboBoxCreate(rect, 0, null, 0, inAttributes, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + OS.HIViewSetVisible (handle, true); } } -/** - * Cuts the selected text. - * <p> - * The current selection is first copied to the - * clipboard and then deleted from the widget. - * </p> - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @since 2.1 - */ + public void cut () { checkWidget (); - selectionToClipboard(); - _replaceTextSelection(""); -} -/* AW -void enableWidget (boolean enabled) { - super.enableWidget (enabled); - int [] argList = { - OS.XmNlist, 0, - OS.XmNtextField, 0, - }; - OS.XtGetValues (handle, argList, argList.length / 2); - enableHandle (enabled, argList [1]); - enableHandle (enabled, argList [3]); + int [] str = new int [1]; + short start, end; + if ((style & SWT.READ_ONLY) != 0) { + // NEEDS WORK - getting whole text, not just selection + int index = OS.GetControlValue (handle); + if (OS.CopyMenuItemTextAsCFString(menuHandle, (short)index, str) != OS.noErr) return; + start = 0; end = (short)OS.CFStringGetLength (str [0]); + if (start >= end) { + OS.CFRelease (str [0]); + return; + } + } else { + short [] s = new short [2]; + OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, s, null); + if (s [0] >= s [1]) return; + start = s [0]; end = s [1]; + if (OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, str, null) != OS.noErr) return; + } + CFRange range = new CFRange (); + range.location = start; + range.length = end - start; + int encoding = OS.CFStringGetSystemEncoding (); + int [] size = new int [1]; + OS.CFStringGetBytes (str [0], range, encoding, (byte)'?', true, null, 0, size); + byte [] buffer = new byte [size [0]]; + OS.CFStringGetBytes (str [0], range, encoding, (byte)'?', true, buffer, size [0], size); + + OS.ClearCurrentScrap(); + int[] scrap = new int [1]; + OS.GetCurrentScrap (scrap); + OS.PutScrapFlavor (scrap [0], OS.kScrapFlavorTypeText, 0, buffer.length, buffer); + + // delete selection + if ((style & SWT.READ_ONLY) != 0) { + // NEEDS WORK + } else { + byte [] newBuffer; + range.location = 0; + range.length = start; + size = new int [1]; + OS.CFStringGetBytes (str [0], range, encoding, (byte)'?', true, null, 0, size); + byte [] preBuffer = new byte [size [0]]; + OS.CFStringGetBytes(str [0], range, encoding, (byte)'?', true, preBuffer, size [0], size); + range.location = end; + range.length = OS.CFStringGetLength (str [0]) - end; + size = new int [1]; + OS.CFStringGetBytes (str [0], range, encoding, (byte)'?', true, null, 0, size); + byte [] postBuffer = new byte [size [0]]; + OS.CFStringGetBytes (str [0], range, encoding, (byte)'?', true, postBuffer, size [0], size); + newBuffer = new byte [preBuffer.length + postBuffer.length]; + System.arraycopy(preBuffer, 0, newBuffer, 0, preBuffer.length); + System.arraycopy(postBuffer, 0, newBuffer, preBuffer.length, postBuffer.length); + int ptr = OS.CFStringCreateWithBytes (OS.kCFAllocatorDefault, newBuffer, newBuffer.length, encoding, true); + OS.SetControlData (handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, new int[] {ptr}); + OS.CFRelease (ptr); + } + + OS.CFRelease (str [0]); } -*/ -/** - * 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(); + checkWidget (); if (index == -1) return; - /* AW - int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - - if (OS.XmListPosSelected (argList[3], index + 1)) { - Display display = getDisplay (); - boolean warnings = display.getWarnings (); - display.setWarnings (false); - OS.XmTextSetString (argList[1], new byte[1]); - OS.XmTextSetInsertionPosition (argList[1], 0); - display.setWarnings (warnings); - OS.XmListDeselectAllItems (argList[3]); - } - */ - System.out.println("Combo.deselect: nyi"); + // NEEDS WORK } -/** - * 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(); - /* AW - int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - Display display = getDisplay (); - boolean warnings = display.getWarnings (); - display.setWarnings (false); - OS.XmTextSetString (argList[1], new byte[1]); - OS.XmTextSetInsertionPosition (argList[1], 0); - display.setWarnings(warnings); - OS.XmListDeselectAllItems (argList[3]); - */ - System.out.println("Combo.deselectAll: nyi"); + checkWidget (); + // NEEDS WORK } -/** - * Returns the item at the given, zero-relative index in the - * receiver's list. Throws an exception if the index is out - * of range. - * - * @param index the index of the item to return - * @return the item at the given index - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li> - * </ul> - */ + public String getItem (int index) { - checkWidget(); - return _getItem(index); + checkWidget (); + int count = getItemCount (); + if (0 > index || index >= count) error (SWT.ERROR_INVALID_RANGE); + int[] ptr = new int[1]; + int result; + if ((style & SWT.READ_ONLY) != 0) { + result = OS.CopyMenuItemTextAsCFString(menuHandle, (short)(index+1), ptr); + } else { + result = OS.HIComboBoxCopyTextItemAtIndex (handle, index, ptr); + } + if (result != OS.noErr) error(SWT.ERROR_CANNOT_GET_ITEM); + int length = OS.CFStringGetLength (ptr [0]); + char [] buffer= new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (ptr [0], range, buffer); + OS.CFRelease (ptr [0]); + return new String (buffer); } -/** - * Returns the number of items contained in the receiver's list. - * - * @return the number of items - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int getItemCount () { - checkWidget(); - return _getItemCount(); + checkWidget (); + int count; + if ((style & SWT.READ_ONLY) != 0) { + count = OS.CountMenuItems (menuHandle); + } else { + count = OS.HIComboBoxGetItemCount (handle); + } + return count; } -/** - * Returns the height of the area which would be used to - * display <em>one</em> of the items in the receiver's list. - * - * @return the height of one item - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int getItemHeight () { - checkWidget(); - /* AW - int [] listHandleArgs = {OS.XmNlist, 0}; - OS.XtGetValues (handle, listHandleArgs, listHandleArgs.length / 2); - int [] argList = {OS.XmNlistSpacing, 0, OS.XmNhighlightThickness, 0}; - OS.XtGetValues (listHandleArgs[1], argList, argList.length / 2); - int spacing = argList [1], highlight = argList [3]; - */ - /* Result is from empirical analysis on Linux and AIX */ - /* AW - return getFontHeight () + spacing + (2 * highlight); - */ - return MacUtil.computeSize(handle).y; + checkWidget (); + return 26; // NEEDS WORK } -/** - * Returns an array of <code>String</code>s which are the items - * in the receiver's list. - * <p> - * Note: This is not the actual structure used by the receiver - * to maintain its list of items, so modifying the array will - * not affect the receiver. - * </p> - * - * @return the items in the receiver's list - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li> - * </ul> - */ + public String [] getItems () { - checkWidget(); - int itemCount= _getItemCount(); - String[] result= new String [itemCount]; - for (int i= 0; i < itemCount; i++) - result[i]= _getItem(i); + checkWidget (); + int count = getItemCount (); + String [] result = new String [count]; + for (int i=0; i<count; i++) result [i] = getItem (i); return result; } -/** - * Returns a <code>Point</code> whose x coordinate is the start - * of the selection in the receiver's text field, and whose y - * coordinate is the end of the selection. The returned values - * are zero-relative. An "empty" selection as indicated by - * the the x and y coordinates having the same value. - * - * @return a point representing the selection start and end - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Point getSelection () { - checkWidget(); - Point selection= new Point(0, 0); - if (menuHandle == 0) { - short[] s= new short[2]; - OS.GetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, s); - selection.x= (short) s[0]; - selection.y= (short) s[1]; + checkWidget (); + Point selection; + if ((style & SWT.READ_ONLY) != 0) { + // NEEDS WORK + selection = new Point(0, 0); + } else { + short [] s = new short [2]; + OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, s, null); + selection = new Point (s[0], s[1]); } return selection; } -/** - * Returns the zero-relative index of the item which is currently - * selected in the receiver's list, or -1 if no item is selected. - * - * @return the index of the selected item - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getSelectionIndex () { - checkWidget(); - if (menuHandle != 0) - return OS.GetControlValue(handle)-1; - return indexOf(getText()); + checkWidget (); + int index; + if ((style & SWT.READ_ONLY) != 0) { + index = OS.GetControlValue (handle) - 1; + } else { + // NEEDS WORK + index = indexOf(getText ()); + } + return index; } -/** - * Returns a string containing a copy of the contents of the - * receiver's text field. - * - * @return the receiver's text - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public String getText () { - checkWidget(); - if (menuHandle != 0) { - int index= getSelectionIndex(); - if (index >= 0) - return _getItem(index); - return ""; - } - int[] t= new int[1]; - OS.GetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, t); - return MacUtil.getStringAndRelease(t[0]); + checkWidget (); + int [] ptr = new int [1]; + int result; + if ((style & SWT.READ_ONLY) != 0) { + int index = OS.GetControlValue (handle) - 1; + result = OS.CopyMenuItemTextAsCFString(menuHandle, (short)(index+1), ptr); + } else { + int [] actualSize = new int [1]; + result = OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, ptr, actualSize); + } + if (result != OS.noErr) return ""; + int length = OS.CFStringGetLength (ptr [0]); + char [] buffer= new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (ptr [0], range, buffer); + OS.CFRelease (ptr [0]); + return new String (buffer); } -/** - * Returns the height of the receivers's text field. - * - * @return the text height - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int getTextHeight () { checkWidget(); - if ((style & SWT.DROP_DOWN) != 0) { - /* - * Bug in MOTIF. For some reason, XtQueryGeometry () - * returns the wrong height when the combo is not realized. - * The fix is to force the combo to be realized by forcing - * the shell to be realized. - */ - /* AW - if (!OS.XtIsRealized (handle)) getShell ().realizeWidget (); - XtWidgetGeometry result = new XtWidgetGeometry (); - result.request_mode = OS.CWHeight; - OS.XtQueryGeometry (handle, null, result); - return result.height; - */ - return 26; - } else { - /* Calculate text field height. */ - /* AW - int [] argList = {OS.XmNtextField, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - int [] argList2 = {OS.XmNmarginHeight, 0}; - OS.XtGetValues (argList[1], argList2, argList2.length / 2); - int height = getFontHeight (); - XRectangle rect = new XRectangle (); - OS.XmWidgetGetDisplayRect (argList[1], rect); - height += (rect.y * 2) + (2 * argList2[1]); - */ - - /* Add in combo box margins. */ - /* AW - int [] argList3 = {OS.XmNmarginHeight, 0, OS.XmNshadowThickness, 0, OS.XmNhighlightThickness, 0}; - OS.XtGetValues(handle, argList3, argList3.length / 2); - height += (2 * argList3[1]) + (2 * argList3[3]) + (2 * argList3[5]); - - return height; - */ - return 26; - } + return 26; // NEEDS WORK } -/** - * Returns the maximum number of characters that the receiver's - * text field is capable of holding. If this has not been changed - * by <code>setTextLimit()</code>, it will be the constant - * <code>Combo.LIMIT</code>. - * - * @return the text limit - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getTextLimit () { checkWidget(); - return textLimit; + return LIMIT; // NEEDS WORK } + void hookEvents () { super.hookEvents (); - /* AW - int windowProc = getDisplay ().windowProc; - OS.XtAddCallback (handle, OS.XmNselectionCallback, windowProc, SWT.Selection); - int [] argList = {OS.XmNtextField, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - OS.XtAddCallback (argList[1], OS.XmNactivateCallback, windowProc, SWT.DefaultSelection); - OS.XtAddCallback (argList[1], OS.XmNvalueChangedCallback, windowProc, SWT.Modify); - */ + if ((style & SWT.READ_ONLY) != 0) { + Display display = getDisplay (); + int commandProc = display.commandProc; + int [] mask = new int [] { + OS.kEventClassCommand, OS.kEventProcessCommand, + }; + int menuTarget = OS.GetMenuEventTarget (menuHandle); + OS.InstallEventHandler (menuTarget, commandProc, mask.length / 2, mask, handle, null); + } } -/** - * Searches the receiver's list starting at the first item - * (index 0) until an item is found that is equal to the - * argument, and returns the index of that item. If no item - * is found, returns -1. - * - * @param string the search item - * @return the index of the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int indexOf (String string) { - checkWidget(); - if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - int itemCount= _getItemCount(); - for (int i= 0; i < itemCount; i++) { - String s= _getItem(i); - if (s != null && string.equals(s)) - return i; - } - return -1; + return indexOf (string, 0); } -/** - * Searches the receiver's list starting at the given, - * zero-relative index until an item is found that is equal - * to the argument, and returns the index of that item. If - * no item is found or the starting index is out of range, - * returns -1. - * - * @param string the search item - * @return the index of the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int indexOf (String string, int start) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - int itemCount= _getItemCount(); - if (!((0 <= start) && (start < itemCount))) return -1; - for (int i= start; i < itemCount; i++) { - String s= _getItem(i); - if (string.equals(s)) + int count = getItemCount (); + for (int i=start; i<count; i++) { + if (string.equals (getItem (i))) { return i; + } } 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 - */ + +Rect getInset () { + Display display = getDisplay (); + return display.comboInset; +} + +int kEventProcessCommand (int nextHandler, int theEvent, int userData) { + int result = super.kEventProcessCommand (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in the modify + * event. If this happens, end the processing of the + * Windows message by returning zero as the result of + * the window proc. + */ + sendEvent (SWT.Modify); + if (isDisposed ()) return OS.eventNotHandledErr; + postEvent (SWT.Selection); + return OS.eventNotHandledErr; +} + +int kEventRawKeyDown (int nextHandler, int theEvent, int userData) { + int result = super.kEventRawKeyDown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + if (keyCode [0] == 36) { //CR + sendEvent (SWT.DefaultSelection); + return OS.noErr; + } + return OS.eventNotHandledErr; +} + public void paste () { checkWidget (); - if (menuHandle == 0) { - Clipboard clipboard= new Clipboard(getDisplay()); - TextTransfer textTransfer= TextTransfer.getInstance(); - String clipBoard= (String)clipboard.getContents(textTransfer); - clipboard.dispose(); - _replaceTextSelection(clipBoard); + int[] scrap = new int [1]; + OS.GetCurrentScrap (scrap); + int [] size = new int [1]; + if (OS.GetScrapFlavorSize (scrap [0], OS.kScrapFlavorTypeText, size) != OS.noErr || size [0] == 0) return; + byte [] buffer = new byte[size [0]]; + if (OS.GetScrapFlavorData (scrap [0], OS.kScrapFlavorTypeText, size, buffer) != OS.noErr) return; + if ((style & SWT.READ_ONLY) != 0) { + String string = new String (buffer); //?? + int index = indexOf (string); + if (index != -1) select(index); + } else { + byte [] newBuffer; + int encoding = OS.CFStringGetSystemEncoding (); + int[] ptrOld = new int [1]; + if (OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, ptrOld, null) == OS.noErr) { + short [] s = new short [2]; + OS.GetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, s, null); + CFRange range = new CFRange (); + range.location = 0; + range.length = s [0]; + size = new int [1]; + OS.CFStringGetBytes (ptrOld [0], range, encoding, (byte)'?', true, null, 0, size); + byte [] preBuffer = new byte [size [0]]; + OS.CFStringGetBytes(ptrOld [0], range, encoding, (byte)'?', true, preBuffer, size [0], size); + range.location = s [1]; + range.length = OS.CFStringGetLength (ptrOld [0]) - s [1]; + size = new int [1]; + OS.CFStringGetBytes (ptrOld [0], range, encoding, (byte)'?', true, null, 0, size); + byte [] postBuffer = new byte [size [0]]; + OS.CFStringGetBytes(ptrOld [0], range, encoding, (byte)'?', true, postBuffer, size [0], size); + newBuffer = new byte [preBuffer.length + buffer.length + postBuffer.length]; + System.arraycopy(preBuffer, 0, newBuffer, 0, preBuffer.length); + System.arraycopy(buffer, 0, newBuffer, preBuffer.length, buffer.length); + System.arraycopy(postBuffer, 0, newBuffer, preBuffer.length + buffer.length, postBuffer.length); + OS.CFRelease (ptrOld [0]); + } else { + newBuffer = buffer; + } + int ptr = OS.CFStringCreateWithBytes (OS.kCFAllocatorDefault, newBuffer, newBuffer.length, encoding, true); + OS.SetControlData (handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, new int[] {ptr}); + OS.CFRelease (ptr); } } -/** - * Removes the item from the receiver's list at the given - * zero-relative index. - * - * @param index the index for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void remove (int index) { - checkWidget(); + checkWidget (); if (index == -1) error (SWT.ERROR_INVALID_RANGE); - int itemCount= _getItemCount(); - if (!(0 <= index && index < itemCount)) { - error (SWT.ERROR_INVALID_RANGE); + int count = getItemCount (); + if (0 > index || index >= count) error (SWT.ERROR_INVALID_RANGE); + if ((style & SWT.READ_ONLY) != 0) { + OS.DeleteMenuItems (menuHandle, (short)(index+1), 1); + } else { + OS.HIComboBoxRemoveItemAtIndex (handle, index); } - if (menuHandle != 0) { - OS.DeleteMenuItems(menuHandle, (short)(index+1), 1); - OS.SetControl32BitMaximum(handle, OS.CountMenuItems(menuHandle)); - } else { - OS.HIComboBoxRemoveItemAtIndex(handle, index); - } } -/** - * Removes the items from the receiver's list which are - * between the given zero-relative start and end - * indices (inclusive). - * - * @param start the start of the range - * @param end the end of the range - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void remove (int start, int end) { checkWidget(); if (start > end) return; - int itemCount= _getItemCount(); - if (!(0 <= start && start < itemCount)) { - error (SWT.ERROR_INVALID_RANGE); - } - int newEnd = Math.min (end, itemCount - 1); - if (menuHandle != 0) { - OS.DeleteMenuItems(menuHandle, (short)(start+1), newEnd-start+1); - OS.SetControl32BitMaximum(handle, OS.CountMenuItems(menuHandle)); + int count = getItemCount (); + if (0 > start || start >= count) error (SWT.ERROR_INVALID_RANGE); + int newEnd = Math.min (end, count - 1); + if ((style & SWT.READ_ONLY) != 0) { + OS.DeleteMenuItems (menuHandle, (short)(start+1), newEnd-start+1); + OS.SetControl32BitMaximum (handle, OS.CountMenuItems (menuHandle)); } else { - for (int i= end; i >= start; i--) - OS.HIComboBoxRemoveItemAtIndex(handle, i); + // NEEDS WORK + for (int i=newEnd; i>=start; i--) { + OS.HIComboBoxRemoveItemAtIndex(handle, i); + } } } -/** - * Searches the receiver's list starting at the first item - * until an item is found that is equal to the argument, - * and removes that item from the list. - * - * @param string the item to remove - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void remove (String string) { - checkWidget(); + checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - int itemCount= _getItemCount(); - for (int i= 0; i < itemCount; i++) { - String s= _getItem(i); - if (s != null && string.equals(s)) { - remove(i); + // NEEDS WORK + int count = getItemCount (); + for (int i=0; i<count; i++) { + String s = getItem (i); + if (string.equals (s)) { + remove (i); return; } } error (SWT.ERROR_INVALID_ARGUMENT); } -/** - * Removes all of the items from the receiver's list. - * <p> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void removeAll () { - checkWidget(); - int itemCount= _getItemCount(); - if (itemCount > 0) { - if (menuHandle != 0) { - OS.DeleteMenuItems(menuHandle, (short)1, itemCount); - OS.SetControl32BitMaximum(handle, OS.CountMenuItems(menuHandle)); - } else { - for (int i= itemCount-1; i >= 0; i--) - OS.HIComboBoxRemoveItemAtIndex(handle, i); + checkWidget (); + int count = getItemCount (); + if ((style & SWT.READ_ONLY) != 0) { + OS.DeleteMenuItems (menuHandle, (short)1, count); + } else { + // NEEDS WORK + if (count > 0) { + for (int i=count-1; i>=0; i--) { + OS.HIComboBoxRemoveItemAtIndex (handle, i); + } } } } -/** - * 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 receiver's selection changes. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ + public void removeSelectionListener (SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -984,440 +573,96 @@ public void removeSelectionListener (SelectionListener listener) { eventTable.unhook (SWT.Selection, listener); eventTable.unhook (SWT.DefaultSelection,listener); } -/** - * Selects the item at the given zero-relative index in the receiver's - * list. If the item at the index was already selected, it remains - * selected. Indices that are out of range are ignored. - * - * @param index the index of the item to select - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void select (int index) { - checkWidget(); - - int itemCount= _getItemCount(); - if (!(0 <= index && index < itemCount)) { - error (SWT.ERROR_INVALID_RANGE); - } - - if (menuHandle != 0) { - int selected= OS.GetControlValue(handle)-1; - if (index != selected) { - OS.SetControl32BitValue(handle, index+1); - sendEvent(SWT.Modify); - } + checkWidget (); + int count = getItemCount (); + if (0 > index || index >= count) error (SWT.ERROR_INVALID_RANGE); + if ((style & SWT.READ_ONLY) != 0) { + OS.SetControl32BitValue (handle, index+1); } else { - String string= _getItem(index); - _setText(string); - _selectAll(); + int[] ptr = new int[1]; + if (OS.HIComboBoxCopyTextItemAtIndex (handle, index, ptr) != OS.noErr) return; + OS.SetControlData (handle, (short)OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, ptr); + OS.CFRelease (ptr [0]); } } -/** -* Sets the widget bounds. -*/ -public void setBounds (int x, int y, int width, int height) { - checkWidget(); - int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height; - super.setBounds (x, y, width, newHeight); -} -/** - * Sets the text of the item in the receiver's list at the given - * zero-relative index to the string argument. This is equivalent - * to <code>remove</code>'ing the old item at the index, and then - * <code>add</code>'ing the new item at that index. - * - * @param index the index for the item - * @param string the new text for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li> - * <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li> - * </ul> - */ + public void setItem (int index, String string) { - checkWidget(); + checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - if (index == -1) error (SWT.ERROR_INVALID_RANGE); - /* AW - int [] argList = {OS.XmNlist, 0, OS.XmNitemCount, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - if (!(0 <= index && index < argList [3])) { - error (SWT.ERROR_INVALID_RANGE); - } - byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true); - int xmString = OS.XmStringCreateLocalized (buffer); - if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED); - boolean isSelected = OS.XmListPosSelected (argList[1], index + 1); - OS.XmListReplaceItemsPosUnselected (argList[1], new int [] {xmString}, 1, index + 1); - if (isSelected) OS.XmListSelectPos (argList[1], index + 1, false); - OS.XmStringFree (xmString); - */ - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - if (menuHandle != 0) { - if (OS.SetMenuItemTextWithCFString(menuHandle, (short)(index+1), sHandle) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_ADDED); - } else { - OS.HIComboBoxInsertTextItemAtIndex(handle, index, sHandle); - OS.HIComboBoxRemoveItemAtIndex(handle, index+1); - } - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); + int count = getItemCount (); + if (0 > index || index >= count) error (SWT.ERROR_INVALID_RANGE); + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_ITEM_NOT_ADDED); + int result; + if ((style & SWT.READ_ONLY) != 0) { + result = OS.SetMenuItemTextWithCFString (menuHandle, (short)(index+1), ptr); + } else { + result = OS.HIComboBoxInsertTextItemAtIndex (handle, index, ptr); + OS.HIComboBoxRemoveItemAtIndex (handle, index+1); } + OS.CFRelease(ptr); + if (result != OS.noErr) error (SWT.ERROR_ITEM_NOT_ADDED); } -/** - * Sets the receiver's list to be the given array of items. - * - * @param items the array of items - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void setItems (String [] items) { checkWidget(); if (items == null) error (SWT.ERROR_NULL_ARGUMENT); - - if (items.length == 0) { - removeAll(); - return; - } - - /* AW - int index = 0; - int [] table = new int [items.length]; - String codePage = getCodePage (); - while (index < items.length) { - String string = items [index]; - if (string == null) break; - byte [] buffer = Converter.wcsToMbcs (codePage, encodeString(string), true); - int xmString = OS.XmStringCreateLocalized (buffer); - if (xmString == 0) break; - table [index++] = xmString; - } - int ptr = OS.XtMalloc (index * 4); - OS.memmove (ptr, table, index * 4); - int [] argList = {OS.XmNitems, ptr, OS.XmNitemCount, index}; - OS.XtSetValues (handle, argList, argList.length / 2); - for (int i=0; i<index; i++) OS.XmStringFree (table [i]); - OS.XtFree (ptr); - if (index < items.length) error (SWT.ERROR_ITEM_NOT_ADDED); - */ - - if (menuHandle != 0) { - for (int i= 0; i < items.length; i++) { - String string= items[i]; - if (string == null) - break; - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - if (OS.AppendMenuItemTextWithCFString(menuHandle, sHandle, 0, fgCommandID++, null) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_ADDED); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } - } - OS.SetControl32BitMaximum(handle, items.length); - } else { - removeAll(); - for (int i= 0; i < items.length; i++) { - String string= items[i]; - if (string == null) - break; - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - if (OS.HIComboBoxAppendTextItem(handle, sHandle) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_ADDED); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } + removeAll(); + if (items.length == 0) return; + for (int i= 0; i < items.length; i++) { + String string = items[i]; + if (string == null) continue; + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_ITEM_NOT_ADDED); + int result; + if ((style & SWT.READ_ONLY) != 0) { + result = OS.AppendMenuItemTextWithCFString (menuHandle, ptr, 0, 0, null); + } else { + int [] outIndex = new int[1]; + result = OS.HIComboBoxAppendTextItem (handle, ptr, outIndex); } + OS.CFRelease(ptr); + if (result != OS.noErr) error (SWT.ERROR_ITEM_NOT_ADDED); } } -/** - * Sets the selection in the receiver's text field to the - * range specified by the argument whose x coordinate is the - * start of the selection and whose y coordinate is the end - * of the selection. - * - * @param a point representing the new selection start and end - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the point is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setSelection (Point selection) { - checkWidget(); - if (menuHandle == 0) { - short[] s= new short[] { (short)selection.x, (short)selection.y }; - OS.SetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, s); + checkWidget (); + if (selection == null) error (SWT.ERROR_NULL_ARGUMENT); + if ((style & SWT.READ_ONLY) != 0) { + // NEEDS WORK + } else { + short [] s = new short [] {(short)selection.x, (short)selection.y }; + OS.SetControlData (handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, s); } } -/** -* Sets the widget size. -*/ -public void setSize (int width, int height) { - checkWidget(); - int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight () : height; - super.setSize (width, newHeight); -} -/** - * Sets the contents of the receiver's text field to the - * given string. - * <p> - * Note: The text field in a <code>Combo</code> is typically - * only capable of displaying a single line of text. Thus, - * setting the text to a string containing line breaks or - * other special characters will probably cause it to - * display incorrectly. - * </p> - * - * @param text the new text - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setText (String string) { - checkWidget(); + checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - - int index= indexOf (string); - if (index != -1) { - select(index); + if ((style & SWT.READ_ONLY) != 0) { + int index = indexOf (string); + if (index != -1) select(index); } else { - if ((style & SWT.READ_ONLY) == 0) { - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - OS.SetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, sHandle); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } - sendEvent(SWT.Modify); - } + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) return; + OS.SetControlData (handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, 4, new int[] {ptr}); + OS.CFRelease (ptr); } } -/** - * Sets the maximum number of characters that the receiver's - * text field is capable of holding to be the argument. - * - * @param limit new text limit - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setTextLimit (int limit) { - checkWidget(); + checkWidget (); if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO); - textLimit= limit; + // NEEDS WORK } -//////////////////////////////////////////////////////// -// Mac stuff -//////////////////////////////////////////////////////// - - private void _setText (String string) { - if ((style & SWT.READ_ONLY) == 0) { - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - OS.SetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, sHandle); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } - sendEvent(SWT.Modify); - } - } - - private int _getItemCount () { - if (menuHandle != 0) - return OS.CountMenuItems(menuHandle); - return OS.HIComboBoxGetItemCount(handle); - } - - private String _getItem (int index) { - int itemCount= _getItemCount(); - if (!(0 <= index && index < itemCount)) { - error (SWT.ERROR_INVALID_RANGE); - } - int[] sHandle= new int[1]; - int rc; - if (menuHandle != 0) - rc= OS.CopyMenuItemTextAsCFString(menuHandle, (short)(index+1), sHandle); - else - rc= OS.HIComboBoxCopyTextItemAtIndex(handle, index, sHandle); - if (rc != OS.kNoErr) - error(SWT.ERROR_CANNOT_GET_ITEM); - return MacUtil.getStringAndRelease(sHandle[0]); - } - - /** - * Overridden from Control. - * x and y are relative to window! - */ - void handleResize(int hndl, MacRect bounds) { - bounds.inset(FOCUS_BORDER, FOCUS_BORDER, FOCUS_BORDER, FOCUS_BORDER); - super.handleResize(hndl, bounds); - } - - void internalGetControlBounds(int hndl, MacRect bounds) { - super.internalGetControlBounds(hndl, bounds); - bounds.inset(-FOCUS_BORDER, -FOCUS_BORDER, -FOCUS_BORDER, -FOCUS_BORDER); - } - - private void _selectAll() { - String s= getText(); - short[] selection= new short[] { 0, (short) s.length() }; - OS.SetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, selection); - } - - int sendKeyEvent (int type, MacEvent mEvent, Event event) { - - /* AW: other platforms call super - LRESULT result = super.WM_CHAR (wParam, lParam); - if (result != null) return result; - */ - -// if (translateTraversal(mEvent)) -// return 0; - - int kind= mEvent.getKind(); - int mcc= mEvent.getMacCharCodes(); - int code= mEvent.getKeyCode(); - - // return key -> DefaultSelection - if (mcc == SWT.CR) { - if (kind == OS.kEventRawKeyDown) - postEvent (SWT.DefaultSelection); - return OS.kNoErr; - } - - if ((mEvent.getModifiers() & OS.cmdKey) != 0) { - switch (code) { - case 0: // select all - if (kind == OS.kEventRawKeyDown) - _selectAll(); - return OS.kNoErr; - case 7: - if (kind == OS.kEventRawKeyDown) - cut(); - return OS.kNoErr; - case 8: - if (kind == OS.kEventRawKeyDown) - copy(); - return OS.kNoErr; - case 9: - if (kind == OS.kEventRawKeyDown || kind == OS.kEventRawKeyRepeat) - paste(); - return OS.kNoErr; - default: - break; - } - } - - String oldText= getText(); - - int status= OS.CallNextEventHandler(mEvent.getNextHandler(), mEvent.getEventRef()); - - if (kind == OS.kEventRawKeyDown) { - String newText= getText(); - if (!oldText.equals(newText)) - sendEvent (SWT.Modify); - } - - return status; - } - - private void selectionToClipboard() { - short[] s= new short[2]; - OS.GetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, s); - if (s[0] != s[1]) { - int[] t= new int[1]; - OS.GetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, t); - String txt= MacUtil.getStringAndRelease(t[0]); - txt= txt.substring(s[0], s[1]); - - Clipboard clipboard= new Clipboard(getDisplay()); - clipboard.setContents(new Object[] { txt }, new Transfer[]{ TextTransfer.getInstance() }); - clipboard.dispose(); - } - } - - /** - * Replace current text selection with given string. - * If selection is empty, inserts string. - * If string is empty, selection is deleted. - */ - private void _replaceTextSelection(String newText) { - - short[] s= new short[2]; - OS.GetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, s); - - boolean selEmpty= s[0] == s[1]; - if (newText.length() == 0 && selEmpty) - return; - - int[] t= new int[1]; - OS.GetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, t); - String txt= MacUtil.getStringAndRelease(t[0]); - - String pre= ""; - if (selEmpty) - pre= txt.substring(0, s[0]); - else if (s[0] > 0) - pre= txt.substring(0, s[0]-1); - - String post= txt.substring(s[1]); - - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(pre + newText + post); - OS.SetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextCFStringTag, sHandle); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } - - s[0]= s[1]= (short)(pre.length() + newText.length()); - OS.SetControlData(handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, s); - - sendEvent(SWT.Modify); - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java index 427c79d95b..c5e2f1c46a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java @@ -7,33 +7,13 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.RGBColor; +import org.eclipse.swt.internal.carbon.Rect; + 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</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> - * This class may be subclassed by custom control implementors - * who are building controls that are constructed from aggregates - * of other controls. - * </p> - * - * @see Canvas - */ public class Composite extends Scrollable { Layout layout; Control[] tabList; @@ -41,53 +21,22 @@ public class Composite extends Scrollable { 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 Widget#getStyle - */ + public Composite (Composite parent, int style) { super (parent, style); } + Control [] _getChildren () { - short[] cnt= new short[1]; - OS.CountSubControls(handle, cnt); - int count= cnt[0]; - if (count == 0) return new Control [0]; - int[] outControl= new int[1]; - Control [] children = new Control [count]; + short [] count = new short [1]; + OS.CountSubControls (handle, count); + if (count [0] == 0) return new Control [0]; + Control [] children = new Control [count [0]]; + int [] outControl= new int [1]; int i = 0, j = 0; - while (i < count) { - if (MacUtil.getChild(handle, outControl, count, i) != OS.kNoErr) - error (SWT.ERROR_CANNOT_GET_ITEM); - int handle = outControl [0]; - if (handle != 0) { - Widget widget = WidgetTable.get (handle); + while (i < count [0]) { + int status = OS.GetIndexedSubControl (handle, (short)(i+1), outControl); + if (status == OS.noErr) { + Widget widget = WidgetTable.get (outControl [0]); if (widget != null && widget != this) { if (widget instanceof Control) { children [j++] = (Control) widget; @@ -96,24 +45,19 @@ Control [] _getChildren () { } i++; } - if (i == j) return children; + if (j == count [0]) return children; Control [] newChildren = new Control [j]; System.arraycopy (children, 0, newChildren, 0, j); return newChildren; } -/** - * Returns tabList or null - */ Control [] _getTabList () { if (tabList == null) return null; - // ensure to return only non-disposed controls int count = 0; for (int i=0; i<tabList.length; i++) { if (!tabList [i].isDisposed ()) count++; } if (count == tabList.length) return tabList; - // copy only non-disposed controls Control [] newList = new Control [count]; int index = 0; for (int i=0; i<tabList.length; i++) { @@ -144,6 +88,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) { Rectangle trim = computeTrim (0, 0, size.x, size.y); return new Point (trim.width, trim.height); } + protected void checkSubclass () { /* Do nothing - Subclassing is allowed */ } @@ -165,168 +110,88 @@ Control [] computeTabList () { return result; } -void createHandle (int index) { - state |= HANDLE | CANVAS; - if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0) { // no scrollbars - int border = (style & SWT.BORDER) != 0 ? 1 : 0; - /* AW - int [] argList = { - OS.XmNancestorSensitive, 1, - OS.XmNborderWidth, border, - OS.XmNmarginWidth, 0, - OS.XmNmarginHeight, 0, - OS.XmNresizePolicy, OS.XmRESIZE_NONE, - OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1, - }; - */ - int parentHandle = parent.handle; - handle= MacUtil.createDrawingArea (parentHandle, -1, true, 0, 0, border); - - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - /* AW - Display display = getDisplay (); - OS.XtOverrideTranslations (handle, display.tabTranslations); - OS.XtOverrideTranslations (handle, display.arrowTranslations); - */ - } else { +void createHandle () { + state |= CANVAS | GRAB; + if ((style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) != 0) { createScrolledHandle (parent.handle); - } -} -void createScrolledHandle (int topHandle) { - - /* AW - int [] argList = {OS.XmNancestorSensitive, 1}; - scrolledHandle = OS.XmCreateMainWindow (topHandle, null, argList, argList.length / 2); - */ - scrolledHandle= createScrollView(topHandle, style); - if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES); - - if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) { - /* AW - int thickness = display.buttonShadowThickness; - int [] argList1 = { - OS.XmNmarginWidth, 3, - OS.XmNmarginHeight, 3, - OS.XmNresizePolicy, OS.XmRESIZE_NONE, - OS.XmNshadowType, OS.XmSHADOW_IN, - OS.XmNshadowThickness, thickness, - }; - formHandle = OS.XmCreateForm (scrolledHandle, null, argList1, argList1.length / 2); - if (formHandle == 0) error (SWT.ERROR_NO_HANDLES); - int [] argList2 = { - OS.XmNmarginWidth, 0, - OS.XmNmarginHeight, 0, - OS.XmNresizePolicy, OS.XmRESIZE_NONE, - OS.XmNtopAttachment, OS.XmATTACH_FORM, - OS.XmNbottomAttachment, OS.XmATTACH_FORM, - OS.XmNleftAttachment, OS.XmATTACH_FORM, - OS.XmNrightAttachment, OS.XmATTACH_FORM, - OS.XmNresizable, 0, - OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1, - }; - handle = OS.XmCreateDrawingArea (formHandle, null, argList2, argList2.length / 2); - */ - handle= MacUtil.createDrawingArea (scrolledHandle, -1, true, 0, 0, 0); } else { - /* AW - int [] argList3 = { - OS.XmNmarginWidth, 0, - OS.XmNmarginHeight, 0, - OS.XmNresizePolicy, OS.XmRESIZE_NONE, - OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1, - }; - handle = OS.XmCreateDrawingArea (scrolledHandle, null, argList3, argList3.length / 2); - */ - handle = MacUtil.createDrawingArea (scrolledHandle, -1, true, 0, 0, 0); + createHandle (parent.handle); } - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - /* AW - OS.XtOverrideTranslations (handle, display.tabTranslations); - OS.XtOverrideTranslations (handle, display.arrowTranslations); - */ } -int defaultBackground () { - return getDisplay ().compositeBackground; + +void createHandle (int parentHandle) { + int features = OS.kControlSupportsEmbedding | OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parentHandle); + OS.CreateUserPaneControl (window, null, features, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; } -int defaultForeground () { - return getDisplay ().compositeForeground; + +void createScrolledHandle (int parentHandle) { + int features = OS.kControlSupportsEmbedding; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parentHandle); + OS.CreateUserPaneControl (window, null, features, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + scrolledHandle = outControl [0]; + outControl [0] = 0; + features |= OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick; + OS.CreateUserPaneControl (window, null, features, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; } -/* AW -public boolean forceFocus () { - checkWidget(); - Control [] children = _getChildren (); - int [] traversals = new int [children.length]; - int [] argList = new int [] {OS.XmNtraversalOn, 0}; - for (int i=0; i<children.length; i++) { - OS.XtGetValues (children [i].handle, argList, argList.length / 2); - traversals [i] = argList [1]; - argList [1] = 0; - OS.XtSetValues (children [i].handle, argList, argList.length / 2); - } - boolean result = super.forceFocus (); - for (int i=0; i<children.length; i++) { - argList [1] = traversals [i]; - OS.XtSetValues (children [i].handle, argList, argList.length / 2); + +void drawWidget (int control) { + if ((state & CANVAS) != 0) { + if (control == scrolledHandle) { + drawBackground (control, background); + Rect rect = new Rect (); + OS.GetControlBounds (scrolledHandle, rect); + Rect inset = inset (); + rect.left += inset.left; + rect.top += inset.top; + rect.right -= inset.right; + rect.bottom -= inset.bottom; + boolean drawFocus = (style & SWT.NO_FOCUS) == 0 && hooksKeys (); + boolean drawBorder = hasBorder (); + int state = OS.IsControlActive (handle) ? OS.kThemeStateActive : OS.kThemeStateInactive; + if (hasFocus ()) { + if (drawBorder) OS.DrawThemeEditTextFrame (rect, state); + if (drawFocus) OS.DrawThemeFocusRect (rect, true); + } else { + if (drawFocus) OS.DrawThemeFocusRect (rect, false); + if (drawBorder) OS.DrawThemeEditTextFrame (rect, state); + } + } else { + if ((style & SWT.NO_BACKGROUND) != 0) return; + drawBackground (control, background); + } + } else { + super.drawWidget (control); } - return result; } -*/ -/** - * Returns an array containing the receiver's children. - * <p> - * Note: This is not the actual structure used by the receiver - * to maintain its list of children, so modifying the array will - * not affect the receiver. - * </p> - * - * @return an array of children - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Control [] getChildren () { checkWidget(); return _getChildren (); } + int getChildrenCount () { /* * NOTE: The current implementation will count * non-registered children. */ - short[] cnt= new short[1]; - OS.CountSubControls(handle, cnt); - return cnt[0]; + short [] count = new short [1]; + OS.CountSubControls (handle, count); + return count [0]; } -/** - * 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; } -/** - * Gets the last specified tabbing order for the control. - * - * @return tabList the ordered list of controls representing the tab order - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setTabList - */ public Control [] getTabList () { checkWidget (); Control [] tabList = _getTabList (); @@ -347,64 +212,45 @@ public Control [] getTabList () { return tabList; } -void hookEvents () { - super.hookEvents (); - if ((state & CANVAS) != 0) { - /* AW - int windowProc = getDisplay ().windowProc; - OS.XtAddEventHandler (handle, 0, true, windowProc, -1); - */ - Display display= getDisplay(); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneDrawProcTag, display.fUserPaneDrawProc); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneHitTestProcTag, display.fUserPaneHitTestProc); - - - if (MacUtil.HIVIEW) { - // OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneTrackingProcTag, display.fUserPaneTrackingProc); - int ref= OS.GetControlEventTarget(handle); - int[] mask= new int[] { - OS.kEventClassMouse, OS.kEventMouseDown, - OS.kEventClassMouse, OS.kEventMouseWheelMoved, - }; - OS.InstallEventHandler(ref, display.fMouseProc, mask, handle); +int kEventControlClick (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlClick (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + if ((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0 && hooksKeys ()) { + int [] theControl = new int [1]; + int window = OS.GetControlOwner (handle); + OS.GetKeyboardFocus (window, theControl); + if (handle != theControl [0]) { + short [] count = new short [1]; + OS.CountSubControls (handle, count); + if (count [0] == 0) { + if (OS.SetKeyboardFocus (window, handle, (short) OS.kControlFocusNextPart) == OS.noErr) { + return OS.noErr; + } + } } } + return result; +} + +int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlSetFocusPart (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + if (((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0 && hooksKeys ())) { + if (scrolledHandle != 0) redrawWidget (scrolledHandle); + return OS.noErr; + } + return result; +} + +boolean hooksKeys () { + return hooks (SWT.KeyDown) || hooks (SWT.KeyUp) || hooks (SWT.Traverse); } -/** - * If the receiver has a layout, asks the layout to <em>lay out</em> - * (that is, set the size and location of) the receiver's children. - * If the receiver does not have a layout, do nothing. - * <p> - * This is equivalent to calling <code>layout(true)</code>. - * </p> - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public void layout () { checkWidget(); layout (true); } -/** - * If the receiver has a layout, asks the layout to <em>lay out</em> - * (that is, set the size and location of) the receiver's children. - * If the the argument is <code>true</code> the layout must not rely - * on any cached information it is keeping about the children. If it - * is <code>false</code> the layout may (potentially) simplify the - * work it is doing by assuming that the state of the none of the - * receiver's children has changed since the last layout. - * If the receiver does not have a layout, do nothing. - * - * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void layout (boolean changed) { checkWidget(); if (layout == null) return; @@ -412,6 +258,7 @@ public void layout (boolean changed) { if (count == 0) return; layout.layout (this, changed); } + Point minimumSize () { Control [] children = _getChildren (); int width = 0, height = 0; @@ -422,207 +269,43 @@ Point minimumSize () { } return new Point (width, height); } -/* AW -void moveAbove (int handle1, int handle2) { - if (handle1 == handle2) return; - int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - int ptr = argList [1], count = argList [3]; - if (count == 0 || ptr == 0) return; - int [] handles = new int [count]; - OS.memmove (handles, ptr, count * 4); - if (handle2 == 0) handle2 = handles [0]; - int i = 0, index1 = -1, index2 = -1; - while (i < count) { - int handle = handles [i]; - if (handle == handle1) index1 = i; - if (handle == handle2) index2 = i; - if (index1 != -1 && index2 != -1) break; - i++; - } - if (index1 == -1 || index2 == -1) return; - if (index1 == index2) return; - if (index1 < index2) { - System.arraycopy (handles, index1 + 1, handles, index1, index2 - index1 - 1); - handles [index2 - 1] = handle1; - } else { - System.arraycopy (handles, index2, handles, index2 + 1, index1 - index2); - handles [index2] = handle1; - } - OS.memmove (ptr, handles, count * 4); -} -void moveBelow (int handle1, int handle2) { - if (handle1 == handle2) return; - int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - int ptr = argList [1], count = argList [3]; - if (count == 0 || ptr == 0) return; - int [] handles = new int [count]; - OS.memmove (handles, ptr, count * 4); - if (handle2 == 0) handle2 = handles [count - 1]; - int i = 0, index1 = -1, index2 = -1; - while (i < count) { - int handle = handles [i]; - if (handle == handle1) index1 = i; - if (handle == handle2) index2 = i; - if (index1 != -1 && index2 != -1) break; - i++; - } - if (index1 == -1 || index2 == -1) return; - if (index1 == index2) return; - if (index1 < index2) { - System.arraycopy (handles, index1 + 1, handles, index1, index2 - index1); - handles [index2] = handle1; - } else { - System.arraycopy (handles, index2 + 1, handles, index2 + 2, index1 - index2 - 1); - handles [index2 + 1] = handle1; - } - OS.memmove (ptr, handles, count * 4); -} -*/ -int processNonMaskable (Object callData) { - /* AW - if ((state & CANVAS) != 0) { - XExposeEvent xEvent = new XExposeEvent (); - OS.memmove (xEvent, callData, XExposeEvent.sizeof); - if (xEvent.type == OS.GraphicsExpose) processPaint (callData); - } - */ - return 0; -} -void propagateChildren (boolean enabled) { - super.propagateChildren (enabled); - Control [] children = _getChildren (); - for (int i = 0; i < children.length; i++) { - Control child = children [i]; - if (child.getEnabled ()) { - child.propagateChildren (enabled); - } - } -} -void realizeChildren () { - /* AW - super.realizeChildren (); - Control [] children = _getChildren (); - for (int i=0; i<children.length; i++) { - children [i].realizeChildren (); - } - if ((state & CANVAS) != 0) { - if ((style & SWT.NO_BACKGROUND) == 0 && (style & SWT.NO_REDRAW_RESIZE) != 0) return; - int xDisplay = OS.XtDisplay (handle); - if (xDisplay == 0) return; - int xWindow = OS.XtWindow (handle); - if (xWindow == 0) return; - int flags = 0; - XSetWindowAttributes attributes = new XSetWindowAttributes (); - if ((style & SWT.NO_BACKGROUND) != 0) { - flags |= OS.CWBackPixmap; - attributes.background_pixmap = OS.None; - } - if ((style & SWT.NO_REDRAW_RESIZE) == 0) { - flags |= OS.CWBitGravity; - attributes.bit_gravity = OS.ForgetGravity; - } - if (flags != 0) { - OS.XChangeWindowAttributes (xDisplay, xWindow, flags, attributes); - } - } - */ -} -void redrawWidget (int x, int y, int width, int height, boolean all) { - super.redrawWidget (x, y, width, height, all); - if (!all) return; - Control [] children = _getChildren (); - for (int i = 0; i < children.length; i++) { - Control child = children [i]; - Point location = child.getClientLocation (); - child.redrawWidget (x - location.x, y - location.y, width, height, all); - } -} + void releaseChildren () { Control [] children = _getChildren (); for (int i=0; i<children.length; i++) { Control child = children [i]; - if (!child.isDisposed ()) { - child.releaseWidget (); - child.releaseHandle (); - } + if (!child.isDisposed ()) child.releaseResources (); } } + void releaseWidget () { releaseChildren (); super.releaseWidget (); layout = null; tabList = null; - /* AW - if (damagedRegion != 0) OS.XDestroyRegion (damagedRegion); - damagedRegion = 0; - */ -} -void setBackgroundPixel (int pixel) { - super.setBackgroundPixel (pixel); - if ((state & CANVAS) != 0) { - if ((style & SWT.NO_BACKGROUND) != 0) { - /* AW - int xDisplay = OS.XtDisplay (handle); - if (xDisplay == 0) return; - int xWindow = OS.XtWindow (handle); - if (xWindow == 0) return; - XSetWindowAttributes attributes = new XSetWindowAttributes (); - attributes.background_pixmap = OS.None; - OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWBackPixmap, attributes); - */ - } - } } -public void setBounds (int x, int y, int width, int height) { - super.setBounds (x, y, width, height); - if (layout != null) layout (false); + +int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) { + int result = super.setBounds(control, x, y, width, height, move, resize, events); + if (layout != null && (result & RESIZED) != 0) layout.layout (this, false); + return result; } -public boolean setFocus() { + +public boolean setFocus () { checkWidget (); if ((style & SWT.NO_FOCUS) != 0) return false; Control [] children = _getChildren (); for (int i= 0; i < children.length; i++) { - Control child = children [i]; - if (child.setFocus ()) return true; + if (children [i].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; } -public void setSize (int width, int height) { - super.setSize (width, height); - if (layout != null) layout (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) { @@ -648,22 +331,10 @@ public void setTabList (Control [] tabList) { } this.tabList = tabList; } -int traversalCode () { - if ((state & CANVAS) != 0) { - if ((style & SWT.NO_FOCUS) != 0) return 0; - if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) return 0; - } - return super.traversalCode (); -} -/* AW -boolean translateMnemonic (char key, XKeyEvent xEvent) { - if (super.translateMnemonic (key, xEvent)) return true; - Control [] children = _getChildren (); - for (int i=0; i<children.length; i++) { - Control child = children [i]; - if (child.translateMnemonic (key, xEvent)) return true; - } - return false; + +void setZOrder () { + super.setZOrder (); + if (scrolledHandle != 0) OS.HIViewAddSubview (scrolledHandle, handle); } -*/ + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java index b5cd168e8a..effd94aaa8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java @@ -7,94 +7,44 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.CGPoint; +import org.eclipse.swt.internal.carbon.CGRect; +import org.eclipse.swt.internal.carbon.ControlFontStyleRec; +import org.eclipse.swt.internal.carbon.HMHelpContentRec; +import org.eclipse.swt.internal.carbon.Rect; + import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.accessibility.*; -import org.eclipse.swt.internal.carbon.*; - -/** - * Control is the abstract superclass of all windowed user interface classes. - * <p> - * <dl> - * <dt><b>Styles:</b> - * <dd>BORDER</dd> - * <dt><b>Events:</b> - * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseEnter, - * MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize</dd> - * </dl> - * <p> - * IMPORTANT: This class is intended to be subclassed <em>only</em> - * within the SWT implementation. - * </p> - */ +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.accessibility.Accessible; + public abstract class Control extends Widget implements Drawable { + /** + * the handle to the OS resource + * (Warning: This field is platform dependent) + */ + public int handle; Composite parent; - Font font; - int foreground, background; - Menu menu; String toolTipText; Object layoutData; - Accessible accessible; int drawCount; - boolean visible= true; + Menu menu; + float [] foreground, background; + Font font; Cursor cursor; - + 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 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 - */ + createWidget (); +} + public void addControlListener(ControlListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -102,25 +52,7 @@ public void addControlListener(ControlListener listener) { addListener (SWT.Resize,typedListener); addListener (SWT.Move,typedListener); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the control gains or loses focus, by sending - * it one of the messages defined in the <code>FocusListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see FocusListener - * @see #removeFocusListener - */ + public void addFocusListener(FocusListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -128,50 +60,14 @@ public void addFocusListener(FocusListener 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. - * - * @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); @@ -179,25 +75,7 @@ public void addKeyListener(KeyListener listener) { addListener(SWT.KeyUp,typedListener); addListener(SWT.KeyDown,typedListener); } -/** - * Adds the listener to the collection of listeners who will - * be notified when mouse buttons are pressed and released, by sending - * it one of the messages defined in the <code>MouseListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see MouseListener - * @see #removeMouseListener - */ + public void addMouseListener(MouseListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -206,25 +84,7 @@ public void addMouseListener(MouseListener listener) { addListener(SWT.MouseUp,typedListener); addListener(SWT.MouseDoubleClick,typedListener); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the mouse passes or hovers over controls, by sending - * it one of the messages defined in the <code>MouseTrackListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see MouseTrackListener - * @see #removeMouseTrackListener - */ + public void addMouseTrackListener (MouseTrackListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -233,145 +93,32 @@ public void addMouseTrackListener (MouseTrackListener listener) { addListener (SWT.MouseExit,typedListener); addListener (SWT.MouseHover,typedListener); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the mouse moves, by sending it one of the - * messages defined in the <code>MouseMoveListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see MouseMoveListener - * @see #removeMouseMoveListener - */ + public void addMouseMoveListener(MouseMoveListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener(SWT.MouseMove,typedListener); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver needs to be painted, by sending it - * 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); } -/** - * 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 - * @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 - * @see "computeTrim, getClientArea for controls that implement them" - */ + public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); int width = DEFAULT_WIDTH; @@ -413,138 +160,60 @@ Control computeTabRoot () { return parent.computeTabRoot (); } -void createWidget (int index) { - super.createWidget (index); - foreground = background = -1; +void createWidget () { + super.createWidget (); + setZOrder (); +} - /* - * Feature in Motif. When the XmNfontList resource is set for - * a widget, Motif creates a copy of the fontList and disposes - * the copy when the widget is disposed. This means that when - * the programmer queries the font, not only will the handle be - * different but the font will be unexpectedly disposed when - * the widget is disposed. This can cause GP's when the font - * is set in another widget. The fix is to cache the font the - * the programmer provides. The initial value of the cache is - * the default font for the widget. - */ - font = defaultFont (); +Font defaultFont () { + byte [] family = new byte [256]; + short [] size = new short [1]; + byte [] style = new byte [1]; + OS.GetThemeFont ((short) defaultThemeFont (), (short) OS.smSystemScript, family, size, style); + short id = OS.FMGetFontFamilyFromName (family); + int [] font = new int [1]; + OS.FMGetFontFromFontFamilyInstance (id, style [0], font, null); + return Font.carbon_new (getDisplay (), font [0], id, style [0], size [0]); +} - /* - * Explicitly set the tab ordering for XmTAB_GROUP widgets to - * override the default traversal. This is done so that the - * traversal order can be changed after the widget tree is - * created. Unless explicitly changed, the overridded traversal - * order is the same as the default. - */ - /* AW - int [] argList1 = new int [] {OS.XmNnavigationType, 0}; - OS.XtGetValues (handle, argList1, argList1.length / 2); - if (argList1 [1] == OS.XmTAB_GROUP) { - int [] argList2 = new int [] {OS.XmNnavigationType, OS.XmEXCLUSIVE_TAB_GROUP}; - OS.XtSetValues (handle, argList2, argList2.length / 2); +int defaultThemeFont () { + return OS.kThemeSystemFont; +} + +void deregister () { + super.deregister (); + WidgetTable.remove (handle); +} + +void destroyWidget () { + int theControl = topHandle (); + releaseHandle (); + if (theControl != 0) { + OS.DisposeControl (theControl); } - */ } -int defaultBackground () { - return getDisplay ().defaultBackground; + +Cursor findCursor () { + if (cursor != null) return cursor; + return parent.findCursor (); } -Font defaultFont () { - return getDisplay ().defaultFont; -} -int defaultForeground () { - return getDisplay ().defaultForeground; -} -void enableWidget (boolean enabled) { - enableHandle (enabled, handle); -} -char findMnemonic (String string) { - int index = 0; - int length = string.length (); - do { - while ((index < length) && (string.charAt (index) != Mnemonic)) index++; - if (++index >= length) return '\0'; - if (string.charAt (index) != Mnemonic) return string.charAt (index); - index++; - } while (index < length); - return '\0'; -} -int fontHandle () { - return handle; + +void fixFocus () { + Shell shell = getShell (); + Control control = this; + while ((control = control.parent) != null) { + if (control.setFocus () || control == shell) return; + } + int window = OS.GetControlOwner (handle); + OS.ClearKeyboardFocus (window); } -/** - * 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(); - Decorations shell = menuShell (); - shell.setSavedFocus (this); - if (!isEnabled () || !isVisible () /* AW || !isActive () */) return false; - if (isFocusControl ()) return true; - shell.bringToTop (); - /* - * This code is intentionally commented. - * - * When setting focus to a control, it is - * possible that application code can set - * the focus to another control inside of - * WM_SETFOCUS. In this case, the original - * control will no longer have the focus - * and the call to setFocus() will return - * false indicating failure. - * - * We are still working on a solution at - * this time. - */ -// if (OS.GetFocus () != OS.SetFocus (handle)) return false; - - /* AW - OS.SetFocus (handle); - */ - - boolean focus= false; - - if (this instanceof Text || this instanceof List || this instanceof Combo || this instanceof Canvas) - focus= true; - if (!focus && MacUtil.FULL_KBD_NAV && this instanceof Button) - focus= true; - - if (focus) { - Display display= getDisplay(); - if (display != null) - display.setMacFocusHandle(((Shell)shell).shellHandle, handle); - } + int window = OS.GetControlOwner (handle); + return OS.SetKeyboardFocus (window, handle, (short)OS.kControlFocusNextPart) == OS.noErr; +} - return isFocusControl (); -} - -/** - * 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) { @@ -552,274 +221,69 @@ public Accessible getAccessible () { } return accessible; } - -/** - * Returns the receiver's background color. - * - * @return the background color - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Color getBackground () { checkWidget(); - return Color.carbon_new (getDisplay (), getBackgroundPixel (), false); -} -int getBackgroundPixel () { -/* AW - int [] argList = {OS.XmNbackground, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - return argList [1]; -*/ - if (background == -1) return defaultBackground (); - return background; -} -/** - * 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> - */ + //WRONG + if (background == null) return getDisplay ().getSystemColor (SWT.COLOR_WHITE); + return Color.carbon_new (getDisplay (), background); +} + public int getBorderWidth () { checkWidget(); - /* AW - int topHandle = topHandle (); - int [] argList = {OS.XmNborderWidth, 0}; - OS.XtGetValues (topHandle, argList, argList.length / 2); - return argList [1]; - */ return 0; } -/** - * 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(); - int topHandle = topHandle (); - /* AW - int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; - OS.XtGetValues (topHandle, argList, argList.length / 2); - int borders = argList [9] * 2; - return new Rectangle ((short) argList [1], (short) argList [3], argList [5] + borders, argList [7] + borders); - */ - if (MacUtil.USE_FRAME) { - MacRect br= new MacRect(); - internalGetControlBounds(topHandle, br); - return br.toRectangle(); - } else { - MacRect br= new MacRect(); - short[] bounds= br.getData(); - short[] pbounds= new short[4]; - internalGetControlBounds(topHandle, br); - OS.GetControlBounds(parent.handle, pbounds); - return new Rectangle(bounds[1]-pbounds[1], bounds[0]-pbounds[0], bounds[3]-bounds[1], bounds[2]-bounds[0]); - } -} -Point getClientLocation () { - /* AW - short [] handle_x = new short [1], handle_y = new short [1]; - OS.XtTranslateCoords (handle, (short) 0, (short) 0, handle_x, handle_y); - short [] topHandle_x = new short [1], topHandle_y = new short [1]; - OS.XtTranslateCoords (parent.handle, (short) 0, (short) 0, topHandle_x, topHandle_y); - return new Point (handle_x [0] - topHandle_x [0], handle_y [0] - topHandle_y [0]); - */ - short[] bounds= new short[4]; - short[] pbounds= new short[4]; - OS.GetControlBounds(handle, bounds); - OS.GetControlBounds(parent.handle, pbounds); - return new Point(bounds[1]-pbounds[1], bounds[0]-pbounds[0]); -} -/** - * Returns the display that the receiver was created on. - * - * @return the receiver's display - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + Rect rect = getControlBounds (topHandle ()); + return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); +} + public Display getDisplay () { Composite parent = this.parent; if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getDisplay (); } -/** - * Returns <code>true</code> if the receiver is enabled, and - * <code>false</code> otherwise. A disabled control is typically - * not selectable from the user interface and draws with an - * inactive or "grayed" look. - * - * @return the receiver's enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public boolean getEnabled () { checkWidget(); - int h= topHandle(); - if (OS.IsValidControlHandle(h)) - return OS.IsControlEnabled(h); - System.out.println("Control.getEnabled: fixme for " + getClass().getName()); - return true; + return (state & DISABLED) == 0; } -/** - * Returns the font that the receiver will use to paint textual information. - * - * @return the receiver's font - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Font getFont () { checkWidget(); - return font; -} - -int getFontAscent () { - int oldPort= OS.GetPort(); - OS.SetPortWindowPort(OS.GetControlOwner(handle)); - if (font != null && font.handle != null) - font.handle.installInGrafPort(); - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - int height= fontInfo[0]; - OS.SetPort(oldPort); - return height; -} - -int getFontHeight () { - int oldPort= OS.GetPort(); - OS.SetPortWindowPort(OS.GetControlOwner(handle)); - if (font != null && font.handle != null) - font.handle.installInGrafPort(); - short[] fontInfo= new short[4]; - OS.GetFontInfo(fontInfo); // FontInfo - int height= fontInfo[0] + fontInfo[1]; - OS.SetPort(oldPort); - return height; -} -/** - * 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> - */ + return font != null ? font : defaultFont (); +} + public Color getForeground () { checkWidget(); - return Color.carbon_new (getDisplay (), getForegroundPixel (), false); + //WRONG + if (foreground == null) return getDisplay ().getSystemColor (SWT.COLOR_BLACK); + return Color.carbon_new (getDisplay (), foreground); } -int getForegroundPixel () { - /* AW - int [] argList = {OS.XmNforeground, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - return argList [1]; - */ - if (foreground == -1) return defaultForeground (); - return foreground; -} -/* AW -short [] getIMECaretPos () { - return new short[]{0, 0}; -} -*/ -/** - * Returns layout data which is associated with the receiver. - * - * @return the receiver's layout data - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + 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). - * - * @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 (); - MacRect br= new MacRect(); - if (MacUtil.USE_FRAME) { - internalGetControlBounds(topHandle, br); - return br.getLocation(); - } else { - short[] bounds= br.getData(); - short[] pbounds= new short[4]; - internalGetControlBounds(topHandle, br); - OS.GetControlBounds(parent.handle, pbounds); - return new Point(bounds[1]-pbounds[1], bounds[0]-pbounds[0]); - } -} -/** - * 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> - */ + Rect rect = getControlBounds (topHandle ()); + return new Point (rect.left, rect.top); +} + public Menu getMenu () { checkWidget(); return menu; } -/** - * Returns the receiver's parent, which must be a <code>Composite</code> - * or null when the receiver is a shell that was created with null or - * 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 (); @@ -836,710 +300,436 @@ Control [] getPath () { } return result; } -/** - * Returns the receiver's shell. For all controls other than - * shells, this simply returns the control's nearest ancestor - * shell. Shells return themselves, even if they are children - * of other shells. - * - * @return the receiver's shell - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #getParent - */ + public Shell getShell () { checkWidget(); return parent.getShell (); } -/** - * Returns a point describing the receiver's size. The - * x coordinate of the result is the width of the receiver. - * The y coordinate of the result is the height of the - * receiver. - * - * @return the receiver's size - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Point getSize () { checkWidget(); - int topHandle = topHandle (); - /* - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; - OS.XtGetValues (topHandle, argList, argList.length / 2); - int borders = argList [5] * 2; - return new Point (argList [1] + borders, argList [3] + borders); - */ - MacRect bounds= new MacRect(); - internalGetControlBounds(topHandle, bounds); - return bounds.getSize(); -} -/** - * 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> - */ + Rect rect = getControlSize (topHandle ()); + return new Point (rect.right - rect.left, rect.bottom - rect.top); +} + public String getToolTipText () { checkWidget(); return toolTipText; } -/** - * Returns <code>true</code> if the receiver is visible, and - * <code>false</code> otherwise. - * <p> - * If one of the receiver's ancestors is not visible or some - * other condition makes the receiver not visible, this method - * may still indicate that it is considered visible even though - * it may not actually be showing. - * </p> - * - * @return the receiver's visibility state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public boolean getVisible () { checkWidget(); - return visible; + return (state & HIDDEN) == 0; } + boolean hasFocus () { - return (this == getDisplay ().getFocusControl ()); + return this == getDisplay ().getFocusControl (); +} + +int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) { + Display display = getDisplay (); + switch (inRequest) { + case OS.kHMSupplyContent: { + int [] contentProvided = new int [] {OS.kHMContentNotProvidedDontPropagate}; + if (toolTipText != null && toolTipText.length () != 0) { + char [] buffer = new char [toolTipText.length ()]; + toolTipText.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} + j--; + } + } + if (display.helpString != 0) OS.CFRelease (display.helpString); + display.helpString = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); + HMHelpContentRec helpContent = new HMHelpContentRec (); + OS.memcpy (helpContent, ioHelpContent, HMHelpContentRec.sizeof); + helpContent.version = OS.kMacHelpVersion; + + /* + * Feature in the Macintosh. Despite the fact that the Mac + * provides 23 different types of alignment for the help text, + * it does not allow the text to be positioned at the current + * mouse position. The fix is to center the text in a rectangle + * that surrounds the original position of the mouse. As the + * mouse is moved, this rectangle is grown to include the new + * location of the mouse. The help text is then centered by + * the Mac in the new rectangle that was carefully constructed + * such that the help text will stay in the same position. + */ + int cursorHeight = 16; + helpContent.tagSide = (short) OS.kHMAbsoluteCenterAligned; + int x = (short) (inGlobalMouse & 0xFFFF); + int y = (short) (inGlobalMouse >> 16); + if (display.helpControl != this) { + display.lastHelpX = x + cursorHeight / 2; + display.lastHelpY = y + cursorHeight + cursorHeight / 2; + } + int jitter = 4; + int deltaX = Math.abs (display.lastHelpX - x) + jitter; + int deltaY = Math.abs (display.lastHelpY - y) + jitter; + x = display.lastHelpX - deltaX; + y = display.lastHelpY - deltaY; + int width = deltaX * 2; + int height = deltaY * 2; + display.helpControl = this; + helpContent.absHotRect_left = (short) x; + helpContent.absHotRect_top = (short) y; + helpContent.absHotRect_right = (short) (x + width); + helpContent.absHotRect_bottom = (short) (y + height); + + helpContent.content0_contentType = OS.kHMCFStringContent; + helpContent.content0_tagCFString = display.helpString; + helpContent.content1_contentType = OS.kHMCFStringContent; + helpContent.content1_tagCFString = display.helpString; + OS.memcpy (ioHelpContent, helpContent, HMHelpContentRec.sizeof); + contentProvided [0] = OS.kHMContentProvided; + } + OS.memcpy (outContentProvided, contentProvided, 4); + break; + } + case OS.kHMDisposeContent: { + if (display.helpString != 0) OS.CFRelease (display.helpString); + display.helpString = 0; + break; + } + } + return OS.noErr; } + void hookEvents () { - /* AW - int windowProc = getDisplay ().windowProc; - OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, SWT.KeyDown); - OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, SWT.KeyUp); - OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, SWT.MouseDown); - OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, SWT.MouseUp); - OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, SWT.MouseMove); - OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, SWT.MouseEnter); - OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, SWT.MouseExit); - OS.XtAddEventHandler (handle, OS.ExposureMask, false, windowProc, SWT.Paint); - OS.XtAddEventHandler (handle, OS.FocusChangeMask, false, windowProc, SWT.FocusIn); - OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, SWT.Help); - */ - //Display display= getDisplay(); - //OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneDrawProcTag, display.fUserPaneDrawProc); -} -/** - * Invokes platform specific functionality to allocate a new GC handle. - * <p> - * <b>IMPORTANT:</b> This method is <em>not</em> part of the public - * API for <code>Control</code>. It is marked public only so that it - * can be shared within the packages provided by SWT. It is not - * available on all platforms, and should never be called from - * application code. - * </p> - * - * @param data the platform specific GC data - * @return the platform specific GC handle - * - * @private - */ + super.hookEvents (); + Display display = getDisplay (); + int controlProc = display.controlProc; + int [] mask = new int [] { + OS.kEventClassControl, OS.kEventControlActivate, + OS.kEventClassControl, OS.kEventControlBoundsChanged, + OS.kEventClassControl, OS.kEventControlClick, + OS.kEventClassControl, OS.kEventControlContextualMenuClick, + OS.kEventClassControl, OS.kEventControlDeactivate, + OS.kEventClassControl, OS.kEventControlDraw, + OS.kEventClassControl, OS.kEventControlHit, + OS.kEventClassControl, OS.kEventControlSetCursor, + OS.kEventClassControl, OS.kEventControlSetFocusPart, + }; + int controlTarget = OS.GetControlEventTarget (handle); + OS.InstallEventHandler (controlTarget, controlProc, mask.length / 2, mask, handle, null); + int helpProc = display.helpProc; + OS.HMInstallControlContentCallback (handle, helpProc); +} + public int internal_new_GC (GCData data) { checkWidget(); - /* AW - if (!OS.XtIsRealized (handle)) { - Shell shell = getShell (); - shell.realizeWidget (); + int [] buffer = new int [1]; + int context = 0, paintRgn = 0, visibleRgn = 0; + if (data.paintEvent != 0) { + int theEvent = data.paintEvent; + OS.GetEventParameter (theEvent, OS.kEventParamCGContextRef, OS.typeCGContextRef, null, 4, null, buffer); + context = buffer [0]; + OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle, OS.typeQDRgnHandle, null, 4, null, buffer); + visibleRgn = paintRgn = buffer [0]; } - int xDisplay = OS.XtDisplay (handle); - if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES); - int xWindow = OS.XtWindow (handle); - if (xWindow == 0) SWT.error(SWT.ERROR_NO_HANDLES); - int xGC = OS.XCreateGC (xDisplay, xWindow, 0, null); - if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); - OS.XSetGraphicsExposures (xDisplay, xGC, false); - int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNcolormap, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - */ - if (data != null) { - data.device = getDisplay (); - data.foreground = getForegroundPixel(); - data.background = getBackgroundPixel(); - data.font = font.handle; - data.controlHandle = handle; + if (context == 0) { + int window = OS.GetControlOwner (handle); + int port = OS.GetWindowPort (window); + OS.CreateCGContextForPort (port, buffer); + context = buffer [0]; + if (context != 0) { + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + Rect portRect = new Rect (); + OS.GetPortBounds (port, portRect); + visibleRgn = getVisibleRegion (handle); + if (paintRgn != 0) OS.SectRgn (paintRgn, visibleRgn, visibleRgn); + OS.ClipCGContextToRegion (context, portRect, visibleRgn); + int portHeight = portRect.bottom - portRect.top; + OS.CGContextScaleCTM (context, 1, -1); + OS.CGContextTranslateCTM (context, rect.left, -portHeight + rect.top); + } } - - int wHandle= 0; - if (MacUtil.USE_FRAME) { - Shell shell= getShell(); - if (shell != null) - wHandle= shell.shellHandle; + if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES); + if (data != null) { + Display display = getDisplay (); + data.device = display; + data.foreground = foreground != null ? foreground : display.getSystemColor (SWT.COLOR_BLACK).handle; + data.background = background != null ? background : display.getSystemColor (SWT.COLOR_WHITE).handle; + data.font = font != null ? font : defaultFont (); + data.visibleRgn = visibleRgn; + data.control = handle; } else { - wHandle= OS.GetControlOwner(handle); + if (visibleRgn != paintRgn) OS.DisposeRgn (visibleRgn); } - int xGC= OS.GetWindowPort(wHandle); - if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); - - return xGC; -} -/** - * Invokes platform specific functionality to dispose a GC handle. - * <p> - * <b>IMPORTANT:</b> This method is <em>not</em> part of the public - * API for <code>Control</code>. It is marked public only so that it - * can be shared within the packages provided by SWT. It is not - * available on all platforms, and should never be called from - * application code. - * </p> - * - * @param handle the platform specific GC handle - * @param data the platform specific GC data - * - * @private - */ -public void internal_dispose_GC (int xGC, GCData data) { + return context; +} + +public void internal_dispose_GC (int context, GCData data) { checkWidget (); - /* AW - int xDisplay = 0; - if (data != null) xDisplay = data.display; - if (xDisplay == 0 && handle != 0) xDisplay = OS.XtDisplay (handle); - if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES); - OS.XFreeGC (xDisplay, xGC); - */ -} -/** - * Returns <code>true</code> if the receiver is enabled and 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 - */ + if (data != null) { + int paintContext = 0, paintRgn = 0; + if (data.paintEvent != 0) { + int theEvent = data.paintEvent; + int [] buffer = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamCGContextRef, OS.typeCGContextRef, null, 4, null, buffer); + paintContext = buffer [0]; + OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle, OS.typeQDRgnHandle, null, 4, null, buffer); + paintRgn = buffer [0]; + } + if (data.visibleRgn != 0 && data.visibleRgn != paintRgn) { + OS.DisposeRgn (data.visibleRgn); + data.visibleRgn = 0; + } + if (paintContext == context) return; + } + OS.CGContextFlush (context); + OS.CGContextRelease (context); +} + 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> - */ + return OS.IsControlEnabled (topHandle ()); +} + +boolean isFocusAncestor () { + Display display = getDisplay (); + Control control = display.getFocusControl (); + while (control != null && control != this) { + control = control.parent; + } + return control == this; +} + 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. - */ - /* AW - 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; - } - } - /* AW - int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); - return (bits & OS.WS_TABSTOP) != 0; - */ - // AW: Motif: - int code = traversalCode (); - if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false; - return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0; + return false; } boolean isTabItem () { - Control [] tabList = parent._getTabList (); - if (tabList != null) { - for (int i=0; i<tabList.length; i++) { - if (tabList [i] == this) return false; - } - } - /* AW - int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); - if ((bits & OS.WS_TABSTOP) != 0) return false; - int code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0); - if ((code & OS.DLGC_STATIC) != 0) return false; - if ((code & OS.DLGC_WANTALLKEYS) != 0) return false; - if ((code & OS.DLGC_WANTARROWS) != 0) return false; - if ((code & OS.DLGC_WANTTAB) != 0) return false; - */ - // AW: Motif - int code = traversalCode (); - return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0; -} -/** - * Returns <code>true</code> if the receiver is visible and all - * of the receiver's ancestors are visible and <code>false</code> - * otherwise. - * - * @return the receiver's visibility state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #getVisible - */ + return false; +} + public boolean isVisible () { checkWidget(); - return getVisible () && parent.isVisible (); -} -void manageChildren () { -/* AW - OS.XtSetMappedWhenManaged (handle, false); - OS.XtManageChild (handle); - int [] argList = {OS.XmNborderWidth, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - OS.XtResizeWidget (handle, 1, 1, argList [1]); - OS.XtSetMappedWhenManaged (handle, true); -*/ + return OS.IsControlVisible (topHandle ()); } + Decorations menuShell () { return parent.menuShell (); } -boolean mnemonicHit (char key) { - return false; -} -boolean mnemonicMatch (char key) { - return false; -} -/** - * Moves the receiver above the specified control in the - * drawing order. If the argument is null, then the receiver - * is moved to the top of the drawing order. The control at - * the top of the drawing order will not be covered by other - * controls even if they occupy intersecting areas. - * - * @param the sibling control (or null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void moveAbove (Control control) { - checkWidget(); - if (control != null && control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); - setZOrder (control, true); -} -/** - * Moves the receiver below the specified control in the - * drawing order. If the argument is null, then the receiver - * is moved to the bottom of the drawing order. The control at - * the bottom of the drawing order will be covered by all other - * controls which occupy intersecting areas. - * - * @param the sibling control (or null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void moveBelow (Control control) { - checkWidget(); - if (control != null && control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); - setZOrder (control, false); -} -/** - * Causes the receiver to be resized to its preferred size. - * For a composite, this involves computing the preferred size - * from its layout, if there is one. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #computeSize - */ -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> - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #computeSize - */ -public void pack (boolean changed) { - checkWidget(); - setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed)); -} -int processDefaultSelection (Object callData) { - postEvent (SWT.DefaultSelection); - return 0; -} -int processFocusIn () { - sendEvent (SWT.FocusIn); - return 0; -} -int processFocusOut () { - sendEvent (SWT.FocusOut); - return 0; -} -int processHelp (Object callData) { - sendHelpEvent (callData); - return 0; -} -int processKeyDown (Object callData) { - MacEvent macEvent = (MacEvent) callData; - if (translateTraversal (macEvent)) - return OS.kNoErr; - // widget could be disposed at this point - if (isDisposed ()) return 0; - return sendKeyEvent (SWT.KeyDown, macEvent); + +int kEventControlContextualMenuClick (int nextHandler, int theEvent, int userData) { + if (menu != null && !menu.isDisposed ()) { + org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); + OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, pt.sizeof, null, pt); + Rect rect = new Rect (); + int window = OS.GetControlOwner (handle); + OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect); + menu.setLocation (pt.h + rect.left, pt.v + rect.top); + menu.setVisible (true); + return OS.noErr; + } + return OS.eventNotHandledErr; } -int processKeyUp (Object callData) { - // widget could be disposed at this point - if (isDisposed ()) return 0; - return sendKeyEvent (SWT.KeyUp, (MacEvent) callData); + +int kEventControlDraw (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlDraw (nextHandler, theEvent, userData); + int [] theControl = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeControlRef, null, 4, null, theControl); + if (theControl [0] != handle) return result; + if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return result; + + /* Retrieve the damage region */ + int [] region = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle, OS.typeQDRgnHandle, null, 4, null, region); + Rect bounds = new Rect (); + OS.GetRegionBounds (region [0], bounds); + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + if (!OS.SectRect (rect, bounds, bounds)) return result; + OS.OffsetRect (bounds, (short) -rect.left, (short) -rect.top); + + GCData data = new GCData (); + data.paintEvent = theEvent; + GC gc = GC.carbon_new (this, data); + + /* Send the paint event */ + Event event = new Event (); + event.gc = gc; + event.x = bounds.left; + event.y = bounds.top; + event.width = bounds.right - bounds.left; + event.height = bounds.bottom - bounds.top; +// gc.setClipping (Region.carbon_new (region [0])); + sendEvent (SWT.Paint, event); + event.gc = null; + gc.dispose (); + + return result; } -int processModify (Object callData) { - sendEvent (SWT.Modify); - return 0; + +int kEventControlSetCursor (int nextHandler, int theEvent, int userData) { + Cursor cursor = findCursor (); + if (cursor != null) { + setCursor (cursor.handle); + return OS.noErr; + } + return OS.eventNotHandledErr; } -int processMouseDown (MacMouseEvent mmEvent) { + +int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { Display display = getDisplay (); - Shell shell = getShell (); - display.hideToolTip (); - int button= mmEvent.getButton(); - sendMouseEvent (SWT.MouseDown, button, mmEvent); - if (button == 2 && hooks (SWT.DragDetect)) { - sendEvent (SWT.DragDetect); - } - if (button == 3 && menu != null) { - /* AW - OS.XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT); - menu.setVisible (true); - */ - } - int clickTime = display.getDoubleClickTime (); - int lastTime = display.lastTime, eventTime = mmEvent.getWhen(); - int lastButton = display.lastButton, eventButton = button; - if (lastButton == eventButton && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) { - sendMouseEvent (SWT.MouseDoubleClick, eventButton, mmEvent); + if (!display.ignoreFocus) { + short [] part = new short [1]; + OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part); + sendFocusEvent (part [0] != 0); } - display.lastTime = eventTime == 0 ? 1 : eventTime; - display.lastButton = eventButton; + return OS.eventNotHandledErr; +} +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + Shell shell = getShell (); + if ((state & GRAB) != 0) { + int [] clickCount = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamClickCount, OS.typeUInt32, null, 4, null, clickCount); + sendMouseEvent (SWT.MouseDown, theEvent); + if (clickCount [0] == 2) sendMouseEvent (SWT.MouseDoubleClick, theEvent); + Display display = getDisplay (); + display.grabControl = this; + } /* * 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); } - return 0; -} -int processMouseEnter (MacMouseEvent mme) { - /* AW - XCrossingEvent xEvent = new XCrossingEvent (); - OS.memmove (xEvent, callData, XCrossingEvent.sizeof); - if (xEvent.mode != OS.NotifyNormal) return 0; - if (xEvent.subwindow != 0) return 0; - */ - Event event = new Event (); - Point p= MacUtil.toControl(handle, mme.getWhere()); - event.x = p.x; - event.y = p.y; - postEvent (SWT.MouseEnter, event); - return 0; + return OS.eventNotHandledErr; } -int processMouseMove (MacMouseEvent mme) { - Display display = getDisplay (); - display.addMouseHoverTimeOut (handle); - sendMouseEvent (SWT.MouseMove, 0, mme); - return 0; + +int kEventMouseDragged (int nextHandler, int theEvent, int userData) { + sendMouseEvent (SWT.MouseMove, theEvent); + return OS.eventNotHandledErr; } -int processMouseExit (MacMouseEvent mme) { - Display display = getDisplay (); - display.removeMouseHoverTimeOut (); - display.hideToolTip (); - /* AW - XCrossingEvent xEvent = new XCrossingEvent (); - OS.memmove (xEvent, callData, XCrossingEvent.sizeof); - if (xEvent.mode != OS.NotifyNormal) return 0; - if (xEvent.subwindow != 0) return 0; - */ - Event event = new Event (); - Point p= MacUtil.toControl(handle, mme.getWhere()); - event.x = p.x; - event.y = p.y; - postEvent (SWT.MouseExit, event); - return 0; + +int kEventMouseMoved (int nextHandler, int theEvent, int userData) { + sendMouseEvent (SWT.MouseMove, theEvent); + return OS.eventNotHandledErr; } -int processMouseHover (MacMouseEvent mme) { - Display display = getDisplay (); - Event event = new Event (); - Point local = toControl (display.getCursorLocation ()); - event.x = local.x; event.y = local.y; - postEvent (SWT.MouseHover, event); - display.showToolTip (handle, toolTipText); - return 0; + +int kEventMouseUp (int nextHandler, int theEvent, int userData) { + sendMouseEvent (SWT.MouseUp, theEvent); + return OS.eventNotHandledErr; +} + +int kEventRawKeyDown (int nextHandler, int theEvent, int userData) { + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + //NOT DONE + if (keyCode [0] == 114) { + //HELP KEY + } + if (!sendKeyEvent (SWT.KeyDown, theEvent)) return OS.noErr; + return OS.eventNotHandledErr; } -int processMouseUp (MacMouseEvent mmEvent) { + +int kEventRawKeyModifiersChanged (int nextHandler, int theEvent, int userData) { + int [] modifiers = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, modifiers.length * 4, null, modifiers); Display display = getDisplay (); - display.hideToolTip (); - sendMouseEvent (SWT.MouseUp, mmEvent.getButton(), mmEvent); - return 0; + int lastModifiers = display.lastModifiers; + int type = SWT.KeyUp; + if ((modifiers [0] & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) type = SWT.KeyDown; + if ((modifiers [0] & OS.controlKey) != 0 && (lastModifiers & OS.controlKey) == 0) type = SWT.KeyDown; + if ((modifiers [0] & OS.cmdKey) != 0 && (lastModifiers & OS.cmdKey) == 0) type = SWT.KeyDown; + if ((modifiers [0] & OS.optionKey) != 0 && (lastModifiers & OS.optionKey) == 0) type = SWT.KeyDown; + boolean result = sendKeyEvent (type, theEvent); + display.lastModifiers = modifiers [0]; + return result ? OS.eventNotHandledErr : OS.noErr; } -int processPaint (Object callData) { - //if (!hooks (SWT.Paint)) return 0; - - /* - if (!fVisible || fDrawCount > 0) { - System.out.println("Control.processPaint: premature exit"); - return 0; - } - */ - /* AW - event.count = xEvent.count; - event.time = OS.XtLastTimestampProcessed (xDisplay); - */ - - GC gc= new GC (this); - MacControlEvent me= (MacControlEvent) callData; - Rectangle r= gc.carbon_focus(me.getDamageRegionHandle()); - if (r == null || !r.isEmpty()) { - - if (!MacUtil.HIVIEW) { - // erase background - //if ((state & CANVAS) != 0) { - if ((style & SWT.NO_BACKGROUND) == 0) { - //gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_YELLOW)); - gc.fillRectangle(r); - } - //} - } - - if (hooks (SWT.Paint)) { - Event event = new Event(); - event.gc = gc; - event.x = r.x; event.y = r.y; - event.width = r.width; event.height = r.height; - - sendEvent (SWT.Paint, event); - } - } - - gc.carbon_unfocus (); - - if (!gc.isDisposed ()) - gc.dispose (); - return 0; +int kEventRawKeyRepeat (int nextHandler, int theEvent, int userData) { + if (!sendKeyEvent (SWT.KeyDown, theEvent)) return OS.noErr; + return OS.eventNotHandledErr; } -int processResize (Object callData) { - sendEvent (SWT.Resize); - // widget could be disposed at this point - return 0; + +int kEventRawKeyUp (int nextHandler, int theEvent, int userData) { + if (!sendKeyEvent (SWT.KeyUp, theEvent)) return OS.noErr; + return OS.eventNotHandledErr; } -int processSelection (Object callData) { - postEvent (SWT.Selection); - return 0; + +public void moveAbove (Control control) { + checkWidget(); + int inOther = 0; + if (control != null) { + if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + if (parent != control.parent) return; + inOther = control.topHandle (); + } + setZOrder (control, true); } -int processSetFocus (Object callData) { - /* - * Ignore focus change events when the window getting or losing - * focus is a menu. Because XmGetFocusWidget() does not answer - * the menu shell (it answers the menu parent), it is necessary - * to use XGetInputFocus() to get the real X focus window. - */ - /* AW - int xDisplay = xEvent.display; - if (xDisplay == 0) return 0; - int [] unused = new int [1], xWindow = new int [1]; - OS.XGetInputFocus (xDisplay, xWindow, unused); - if (xWindow [0] != 0) { - int widget = OS.XtWindowToWidget (xDisplay, xWindow [0]); - if (widget != 0 && OS.XtClass (widget) == OS.XmMenuShellWidgetClass ()) return 0; + +public void moveBelow (Control control) { + checkWidget(); + int inOther = 0; + if (control != null) { + if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + if (parent != control.parent) return; + inOther = control.topHandle (); } - */ - /* Process the focus change for the widget */ + setZOrder (control, false); +} - Shell shell = getShell (); - Boolean b = (Boolean) callData; - if (b.booleanValue ()) { - - processFocusIn (); - // widget could be disposed at this point - /* - * It is possible that the shell may be - * disposed at this point. If this happens - * don't send the activate and deactivate - * events. - */ - if (!shell.isDisposed ()) { - shell.setActiveControl (this); - } - } else { - Display display = getDisplay (); +public void pack () { + checkWidget(); + pack (true); +} + +public void pack (boolean changed) { + checkWidget(); + setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed)); +} - processFocusOut (); - // widget could be disposed at this point - /* - * It is possible that the shell may be - * disposed at this point. If this happens - * don't send the activate and deactivate - * events. - */ - if (!shell.isDisposed ()) { - Control control = display.getFocusControl (); - if (control == null || shell != control.getShell () ) { - shell.setActiveControl (null); - } - } - } - return 0; -} -void propagateChildren (boolean enabled) { - propagateWidget (enabled); -} -void propagateWidget (boolean enabled) { - propagateHandle (enabled, handle); -} -void realizeChildren () { - if (!isEnabled ()) propagateWidget (false); -} -/** - * Causes the entire bounds of the receiver to be marked - * as needing to be redrawn. The next time a paint request - * is processed, the control will be completely painted. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #update - */ public void redraw () { checkWidget(); - redrawWidget (0, 0, 0, 0, false); -} -/** - * Causes the rectangular area of the receiver specified by - * the arguments to be marked as needing to be redrawn. - * The next time a paint request is processed, that area of - * the receiver will be painted. If the <code>all</code> flag - * is <code>true</code>, any children of the receiver which - * intersect with the specified area will also paint their - * intersecting areas. If the <code>all</code> flag is - * <code>false</code>, the children will not be painted. - * - * @param x the x coordinate of the area to draw - * @param y the y coordinate of the area to draw - * @param width the width of the area to draw - * @param height the height of the area to draw - * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #update - */ + redrawWidget (handle); +} + public void redraw (int x, int y, int width, int height, boolean all) { checkWidget (); - if (width <= 0 || height <= 0) return; - redrawWidget (x, y, width, height, all); + if (!OS.IsControlVisible (handle)) return; + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + x += rect.left; + y += rect.top; + OS.SetRect (rect, (short) x, (short) y, (short)(x + width), (short)(y + height)); + int window = OS.GetControlOwner (handle); + OS.InvalWindowRect (window, rect); +} + +void register () { + super.register (); + WidgetTable.put (handle, this); } -void redrawWidget (int x, int y, int width, int height, boolean all) { - redrawHandle (x, y, width, height, handle, all); + +void releaseHandle () { + super.releaseHandle (); + handle = 0; } + void releaseWidget () { super.releaseWidget (); - Display display = getDisplay (); - display.releaseToolTipHandle (handle); - toolTipText = null; if (menu != null && !menu.isDisposed ()) { menu.dispose (); } @@ -1547,23 +737,7 @@ void releaseWidget () { parent = null; layoutData = null; } -/** - * Removes the listener from the collection of listeners who will - * be notified when the control is moved or resized. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ControlListener - * @see #addControlListener - */ + public void removeControlListener (ControlListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -1571,23 +745,7 @@ public void removeControlListener (ControlListener listener) { eventTable.unhook (SWT.Move, listener); eventTable.unhook (SWT.Resize, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when the control gains or loses focus. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see FocusListener - * @see #addFocusListener - */ + public void removeFocusListener(FocusListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -1595,46 +753,14 @@ public void removeFocusListener(FocusListener listener) { eventTable.unhook(SWT.FocusIn, listener); eventTable.unhook(SWT.FocusOut, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when the help events are generated for the control. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see HelpListener - * @see #addHelpListener - */ + 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 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); @@ -1642,23 +768,7 @@ public void removeKeyListener(KeyListener listener) { eventTable.unhook(SWT.KeyUp, listener); eventTable.unhook(SWT.KeyDown, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when mouse buttons are pressed and released. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see MouseListener - * @see #addMouseListener - */ + public void removeMouseListener(MouseListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -1667,46 +777,14 @@ public void removeMouseListener(MouseListener listener) { eventTable.unhook(SWT.MouseUp, listener); eventTable.unhook(SWT.MouseDoubleClick, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when the mouse moves. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see MouseMoveListener - * @see #addMouseMoveListener - */ + 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 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); @@ -1715,455 +793,233 @@ public void removeMouseTrackListener(MouseTrackListener listener) { eventTable.unhook (SWT.MouseExit, listener); eventTable.unhook (SWT.MouseHover, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver needs to be painted. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see PaintListener - * @see #addPaintListener - */ + 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 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); } -void sendHelpEvent (Object callData) { - Control control = this; - while (control != null) { - if (control.hooks (SWT.Help)) { - control.postEvent (SWT.Help); - return; + +void sendFocusEvent (boolean focusIn) { + Shell shell = getShell (); + if (focusIn) { + sendEvent (SWT.FocusIn); + } else { + sendEvent (SWT.FocusOut); + } + + /* + * It is possible that the shell may be + * disposed at this point. If this happens + * don't send the activate and deactivate + * events. + */ + if (focusIn) { + if (!shell.isDisposed ()) { + shell.setActiveControl (this); + } + } else { + if (!shell.isDisposed ()) { + Display display = shell.getDisplay (); + Control control = display.getFocusControl (); + if (control == null || shell != control.getShell () ) { + shell.setActiveControl (null); + } } - control = control.parent; } } -final int sendKeyEvent (int type, MacEvent mEvent) { + +boolean sendKeyEvent (int type, int theEvent) { Event event = new Event (); - event.time = mEvent.getWhen(); - setKeyState (event, mEvent); - return sendKeyEvent (type, mEvent, event); -// Control control = this; -// if ((state & CANVAS) != 0) { -// if ((style & SWT.NO_FOCUS) != 0) { -// Display display = getDisplay (); -// control = display.getFocusControl (); -// } -// } -// if (control != null) { -// control.postEvent (type, event); -// } + event.type = type; + setKeyState (event, theEvent); + return sendKeyEvent (type, event); } -int sendKeyEvent (int type, MacEvent mEvent, Event event) { + +boolean sendKeyEvent (int type, Event event) { postEvent (type, event); - return 0; + return true; +} + +boolean sendMouseEvent (int type, int theEvent) { + short [] button = new short [1]; + OS.GetEventParameter (theEvent, OS.kEventParamMouseButton, OS.typeMouseButton, null, 2, null, button); + return sendMouseEvent (type, button [0], theEvent); } -final void sendMouseEvent (int type, int button, MacMouseEvent mme) { + +boolean sendMouseEvent (int type, short button, int theEvent) { Event event = new Event (); - event.time = mme.getWhen(); - event.button = button; - Point ml= MacUtil.toControl(handle, mme.getWhere()); - event.x = ml.x; event.y = ml.y; - // AW setInputState (event, mEvent); - event.stateMask= mme.getState(); + event.type = type; + org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); + OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, pt.sizeof, null, pt); + Rect rect = new Rect (); + int window = OS.GetControlOwner (handle); + OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect); + event.x = pt.h - rect.left; + event.y = pt.v - rect.top; + OS.GetControlBounds (handle, rect); + event.x -= rect.left; + event.y -= rect.top; + setInputState (event, theEvent); postEvent (type, event); + return true; } -/** - * Sets the receiver's background color to the color specified - * by the argument, or to the default system color for the control - * if the argument is null. - * - * @param color the new color (or null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +boolean sendMouseEvent (int type, short button, int chord, short x, short y, int modifiers) { + Event event = new Event (); + event.type = type; + event.x = x; + event.y = y; + setInputState (event, button, chord, modifiers); + sendEvent (type, event); + return true; +} + public void setBackground (Color color) { checkWidget(); - int pixel = -1; if (color != null) { if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - pixel = color.handle; } - setBackgroundPixel (pixel); -} -void setBackgroundPixel (int pixel) { - /* AW - int [] argList = {OS.XmNforeground, 0, OS.XmNhighlightColor, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - OS.XmChangeColor (handle, pixel); - OS.XtSetValues (handle, argList, argList.length / 2); - */ - if (background == pixel) return; - background = pixel; - redrawHandle(0, 0, 0, 0, handle, false); -} -/** - * Sets the receiver's size and location to the rectangular - * area specified by the arguments. The <code>x</code> and - * <code>y</code> arguments are relative to the receiver's - * parent (or its display if its parent is null). - * <p> - * Note: Attempting to set the width or height of the - * receiver to a negative number will cause that - * value to be set to zero instead. - * </p> - * - * @param x the new x coordinate for the receiver - * @param y the new y coordinate for the receiver - * @param width the new width for the receiver - * @param height the new height for the receiver - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + background = color != null ? color.handle : null; +} + public void setBounds (int x, int y, int width, int height) { checkWidget(); - int topHandle = topHandle (); - width = Math.max(width, 0); - height = Math.max(height, 0); - MacRect br= new MacRect(); - short[] bounds= br.getData(); - short[] pbounds= new short[4]; - internalGetControlBounds(topHandle, br); - OS.GetControlBounds(parent.handle, pbounds); - boolean sameOrigin; - if (MacUtil.USE_FRAME) { - sameOrigin = bounds[1] == x && bounds[0] == y; - } else { - sameOrigin = (bounds[1]-pbounds[1]) == x && (bounds[0]-pbounds[0]) == y; - } - boolean sameExtent = (bounds[3]-bounds[1]) == width && (bounds[2]-bounds[0]) == height; - if (sameOrigin && sameExtent) return; - internalSetBounds(topHandle, br, pbounds[1]+x, pbounds[0]+y, width, height); - if (!sameOrigin) sendEvent (SWT.Move); - if (!sameExtent) sendEvent (SWT.Resize); -} -/** - * Sets the receiver's size and location to the rectangular - * area specified by the argument. The <code>x</code> and - * <code>y</code> fields of the rectangle are relative to - * the receiver's parent (or its display if its parent is null). - * <p> - * Note: Attempting to set the width or height of the - * receiver to a negative number will cause that - * value to be set to zero instead. - * </p> - * - * @param rect the new bounds for the receiver - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + setBounds (topHandle (), x, y, width, height, true, true, true); +} + public void setBounds (Rectangle rect) { if (rect == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (rect.x, rect.y, rect.width, rect.height); } -/** - * If the argument is <code>true</code>, causes the receiver to have - * all mouse events delivered to it until the method is called with - * <code>false</code> as the argument. - * - * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setCapture (boolean capture) { checkWidget(); - System.out.println("Control.setCapture: nyi"); - /* AW - int display = OS.XtDisplay (handle); - if (display == 0) return; - if (capture) { - int window = OS.XtWindow (handle); - if (window == 0) return; - OS.XGrabPointer ( - display, - window, - 0, - OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask, - OS.GrabModeAsync, - OS.GrabModeAsync, - OS.None, - OS.None, - OS.CurrentTime); - } else { - OS.XUngrabPointer (display, OS.CurrentTime); - } - */ -} -/** - * Sets the receiver's cursor to the cursor specified by the - * argument, or to the default cursor for that kind of control - * if the argument is null. - * <p> - * When the mouse pointer passes over a control its appearance - * is changed to match the control's cursor. - * </p> - * - * @param cursor the new cursor (or null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ +} + public void setCursor (Cursor cursor) { checkWidget(); - if (cursor == null) { - cursor= null; - } else { - if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - this.cursor= cursor; + if (cursor != null && cursor.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + this.cursor = cursor; + org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point (); + OS.GetGlobalMouse (where); + int [] theWindow = new int [1]; + if (OS.FindWindow (where, theWindow) != OS.inContent) return; + if (theWindow [0] == 0) return; + Rect rect = new Rect (); + OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, rect); + CGPoint inPoint = new CGPoint (); + inPoint.x = where.h - rect.left; + inPoint.y = where.v - rect.top; + int [] theRoot = new int [1]; + OS.GetRootControl (theWindow [0], theRoot); + int [] theControl = new int [1]; + OS.HIViewGetSubviewHit (theRoot [0], inPoint, true, theControl); + int cursorControl = theControl [0]; + while (theControl [0] != 0 && theControl [0] != handle) { + OS.GetSuperControl (theControl [0], theControl); } + if (theControl [0] == 0) return; + org.eclipse.swt.internal.carbon.Point localPoint = new org.eclipse.swt.internal.carbon.Point (); + localPoint.h = (short) inPoint.x; + localPoint.v = (short) inPoint.y; + int modifiers = OS.GetCurrentEventKeyModifiers (); + boolean [] cursorWasSet = new boolean [1]; + OS.HandleControlSetCursor (cursorControl, localPoint, (short) modifiers, cursorWasSet); + if (!cursorWasSet [0]) OS.SetThemeCursor (OS.kThemeArrowCursor); } -/** - * 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> - */ + +void setCursor (int cursor) { + switch (cursor) { + case OS.kThemePointingHandCursor: + case OS.kThemeArrowCursor: + case OS.kThemeSpinningCursor: + case OS.kThemeCrossCursor: + case OS.kThemeWatchCursor: + case OS.kThemeIBeamCursor: + case OS.kThemeNotAllowedCursor: + case OS.kThemeResizeLeftRightCursor: + case OS.kThemeResizeLeftCursor: + case OS.kThemeResizeRightCursor: + OS.SetThemeCursor (cursor); + break; + default: + OS.SetCursor (cursor); + } +} + public void setEnabled (boolean enabled) { checkWidget(); - enableWidget (enabled); - if (!enabled || (isEnabled () && enabled)) { - propagateChildren (enabled); + if (enabled) { + if ((state & DISABLED) == 0) return; + state &= ~DISABLED; + OS.EnableControl (topHandle ()); + } else { + if ((state & DISABLED) != 0) return; + state |= DISABLED; + OS.DisableControl (topHandle ()); } } -/** - * Causes the receiver to have the <em>keyboard focus</em>, - * such that all keyboard events will be delivered to it. - * - * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #forceFocus - */ + public boolean setFocus () { checkWidget(); return forceFocus (); } -/** - * 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(); - if (font == null) font = defaultFont (); - if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + if (font != null) { + if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } this.font = font; + setFontStyle (font); +} - int fontHandle = fontHandle (); - if (OS.SetControlFontStyle(fontHandle, font.handle.fID, font.handle.fSize, font.handle.fFace) != OS.kNoErr) - ; //System.out.println("Control.setFont("+this+"): error"); -} -/** - * Sets the receiver's foreground color to the color specified - * by the argument, or to the default system color for the control - * if the argument is null. - * - * @param color the new color (or null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setForeground (Color color) { - checkWidget(); - /* AW - if (color == null) { - setForegroundPixel (defaultForeground ()); +void setFontStyle (Font font) { + ControlFontStyleRec fontStyle = new ControlFontStyleRec (); + if (font != null) { + fontStyle.flags |= OS.kControlUseFontMask | OS.kControlUseSizeMask | OS.kControlUseFaceMask; + fontStyle.font = font.id; + fontStyle.style = font.style; + fontStyle.size = font.size; } else { - if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - setForegroundPixel (color.handle.pixel); + fontStyle.flags |= OS.kControlUseThemeFontIDMask; + fontStyle.font = (short) defaultThemeFont (); } - */ - int pixel = -1; + OS.SetControlFontStyle (handle, fontStyle); +} + +public void setForeground (Color color) { + checkWidget(); if (color != null) { if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - pixel = color.handle; } - setForegroundPixel (pixel); -} -void setForegroundPixel (int pixel) { - /* AW - int [] argList = {OS.XmNforeground, pixel}; - OS.XtSetValues (handle, argList, argList.length / 2); - int xDisplay = OS.XtDisplay (handle); - if (xDisplay == 0) return; - int xWindow = OS.XtWindow (handle); - if (xWindow == 0) return; - OS.XClearArea (xDisplay, xWindow, 0, 0, 0, 0, true); - */ - if (foreground == pixel) return; - foreground = pixel; - redrawHandle(0, 0, 0, 0, handle, false); -} -void setGrabCursor (int cursor) { - System.out.println("Control.setGrabCursor: nyi"); -} -/** - * 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> - */ + foreground = color != null ? color.handle : null; +} + 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). - * - * @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(); - /* AW - int [] argList = {OS.XmNx, 0, OS.XmNy, 0}; - OS.XtGetValues (topHandle, argList, argList.length / 2); - boolean sameOrigin = (x == (short) argList [1]) && (y == (short) argList [3]); - if (sameOrigin) return; - OS.XtMoveWidget (topHandle, x, y); - if (!sameOrigin) sendEvent (SWT.Move); - */ - int topHandle = topHandle (); - MacRect br= new MacRect(); - short[] bounds= br.getData(); - short[] pbounds= new short[4]; - internalGetControlBounds(topHandle, br); - OS.GetControlBounds(parent.handle, pbounds); - boolean sameOrigin; - if (MacUtil.USE_FRAME) { - sameOrigin = (x == bounds[1]) && (y == bounds[0]); - } else { - sameOrigin = (x == (bounds[1]-pbounds[1])) && (y == (bounds[0]-pbounds[0])); - } - if (sameOrigin) return; - internalSetBounds(topHandle, br, pbounds[1]+x, pbounds[0]+y, bounds[3]-bounds[1], bounds[2]-bounds[0]); - sendEvent (SWT.Move); -} -/** - * Sets the receiver's location to the point specified by - * the argument which is relative to the receiver's - * parent (or its display if its parent is null). - * - * @param location the new location for the receiver - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + setBounds (topHandle (), x, y, 0, 0, true, false, true); +} + public void setLocation (Point location) { if (location == null) error (SWT.ERROR_NULL_ARGUMENT); setLocation (location.x, location.y); } -/** - * Sets the receiver's pop up menu to the argument. - * All controls may optionally have a pop up - * menu that is displayed when the user requests one for - * the control. The sequence of key strokes, button presses - * and/or button releases that are used to request a pop up - * menu is platform specific. - * - * @param menu the new pop up menu - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li> - * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li> - * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setMenu (Menu menu) { checkWidget(); if (menu != null) { @@ -2178,411 +1034,163 @@ public void setMenu (Menu menu) { this.menu = menu; } -/** - * Changes the parent of the widget to be the one provided if - * the underlying operating system supports this feature. - * Answers <code>true</code> if the parent is successfully changed. - * - * @param parent the new parent for the control. - * @return <code>true</code> if the parent is changed and <code>false</code> otherwise. - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> - * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> - * </ul> - */ public boolean setParent (Composite parent) { checkWidget(); if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); return false; } -/** - * If the argument is <code>false</code>, causes subsequent drawing - * operations in the receiver to be ignored. No drawing of any kind - * can occur in the receiver until the flag is set to true. - * Graphics operations that occurred while the flag was - * <code>false</code> are lost. When the flag is set to <code>true</code>, - * the entire widget is marked as needing to be redrawn. - * <p> - * Note: This operation is a hint and may not be supported on some - * platforms or for some widgets. - * </p> - * - * @param redraw the new redraw state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #redraw - * @see #update - */ public void setRedraw (boolean redraw) { checkWidget(); - if (redraw) { - if (--drawCount == 0) { - int topHandle= topHandle(); - OS.HIViewSetDrawingEnabled(topHandle, true); - OS.HIViewSetNeedsDisplay(topHandle, true); - } - } else { - if (drawCount++ == 0) - OS.HIViewSetDrawingEnabled(topHandle(), false); - } + //NOT DONE +// if (redraw) { +// if (--drawCount == 0) { +// OS.HIViewSetDrawingEnabled (handle, true); +// OS.HIViewSetNeedsDisplay (handle, true); +// } +// } else { +// if (drawCount++ == 0) { +// OS.HIViewSetDrawingEnabled (handle, false); +// } +// } } -/** - * 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> - */ + +boolean setRadioSelection (boolean value){ + return false; +} + public void setSize (int width, int height) { checkWidget(); - /* - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; - OS.XtGetValues (topHandle, argList, argList.length / 2); - int newWidth = Math.max (width - (argList [5] * 2), 1); - int newHeight = Math.max (height - (argList [5] * 2), 1); - boolean sameExtent = (newWidth == argList [1]) && (newHeight == argList [3]); - OS.XtResizeWidget (topHandle, newWidth, newHeight, argList [5]); - */ - int topHandle = topHandle (); - width = Math.max(width, 0); - height = Math.max(height, 0); - MacRect br= new MacRect(); - short[] bounds= br.getData(); - internalGetControlBounds(topHandle, br); - boolean sameExtent = (bounds[3]-bounds[1]) == width && (bounds[2]-bounds[0]) == height; - if (sameExtent) return; - internalSetBounds(topHandle, br, bounds[1], bounds[0], width, height); - sendEvent (SWT.Resize); -} -/** - * Sets the receiver's size to the point specified by the argument. - * <p> - * Note: Attempting to set the width or height of the - * receiver to a negative number will cause them to be - * set to zero instead. - * </p> - * - * @param size the new size for the receiver - * @param height the new height for the receiver - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the point is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + setBounds (topHandle (), 0, 0, width, height, false, true, true); +} + public void setSize (Point size) { if (size == null) error (SWT.ERROR_NULL_ARGUMENT); setSize (size.x, size.y); } boolean setTabGroupFocus () { - return setTabItemFocus (); + return false; } boolean setTabItemFocus () { - if (!isShowing ()) return false; - return setFocus (); -} - -/** - * Sets the receiver's tool tip text to the argument, which - * may be null indicating that no tool tip text should be shown. - * - * @param string the new tool tip text (or null) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + return false; +} + public void setToolTipText (String string) { checkWidget(); toolTipText = string; } -/** - * Marks the receiver as visible if the argument is <code>true</code>, - * and marks it invisible otherwise. - * <p> - * If one of the receiver's ancestors is not visible or some - * other condition makes the receiver not visible, marking - * it visible may not actually cause it to be displayed. - * </p> - * - * @param visible the new visibility state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setVisible (boolean visible) { checkWidget(); - if (this.visible != visible) { - this.visible= visible; - int topHandle = topHandle (); - if (OS.IsControlVisible(topHandle) != visible) { - OS.HIViewSetVisible(topHandle, visible); - sendEvent (visible ? SWT.Show : SWT.Hide); - } - } + if (visible) { + if ((state & HIDDEN) == 0) return; + state &= ~HIDDEN; + } else { + if ((state & HIDDEN) != 0) return; + state |= HIDDEN; + } + if (visible) { + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in the show + * event. If this happens, just return. + */ + sendEvent (SWT.Show); + if (isDisposed ()) return; + } + + /* + * Feature in the Macintosh. If the receiver has focus, hiding + * the receiver causes no control to have focus. Also, the focus + * needs to be cleared from any TXNObject so that it stops blinking + * the caret. The fix is to assign focus to the first ancestor + * control that takes focus. If no control will take focus, clear + * the focus control. + */ + boolean fixFocus = false; + if (!visible) fixFocus = isFocusAncestor (); + OS.HIViewSetVisible (topHandle (), visible); + if (!visible) { + /* + * It is possible (but unlikely), that application + * code could have disposed the widget in the show + * event. If this happens, just return. + */ + sendEvent (SWT.Hide); + if (isDisposed ()) return; + } + if (fixFocus) fixFocus (); +} + +void setZOrder () { + int topHandle = topHandle (); + int parentHandle = parent.handle; + OS.HIViewAddSubview (parentHandle, topHandle); + //OS.EmbedControl (topHandle, parentHandle); + /* Place the child at (0, 0) in the parent */ + Rect rect = new Rect (); + OS.GetControlBounds (parentHandle, rect); + rect.right = rect.left; + rect.bottom = rect.top; + OS.SetControlBounds (topHandle, rect); } + void setZOrder (Control control, boolean above) { - - if (control != null && control.parent != parent) return; - - int thisHandle= topHandle(); - if (parent == null) - error (SWT.ERROR_INVALID_PARENT); - int destHandle= parent.handle; - int otherHandle= 0; - if (control != null) - otherHandle= control.topHandle(); - - // AW: doesn't handle reparenting case yet! - OS.HIViewSetZOrder(thisHandle, above ? OS.kHIViewZOrderAbove : OS.kHIViewZOrderBelow, otherHandle); -} -/** - * Returns a point which is the result of converting the - * argument, which is specified in display relative coordinates, - * to coordinates relative to the receiver. - * <p> - * @param point the point to be translated (must not be null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the point is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + int inOp = above ? OS.kHIViewZOrderBelow : OS.kHIViewZOrderAbove; + int inOther = control == null ? 0 : control.topHandle (); + OS.HIViewSetZOrder (topHandle (), inOp, inOther); +} + +void sort (int [] items) { + /* Shell Sort from K&R, pg 108 */ + int length = items.length; + for (int gap=length/2; gap>0; gap/=2) { + for (int i=gap; i<length; i++) { + for (int j=i-gap; j>=0; j-=gap) { + if (items [j] <= items [j + gap]) { + int swap = items [j]; + items [j] = items [j + gap]; + items [j + gap] = swap; + } + } + } + } +} + public Point toControl (Point point) { checkWidget(); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - /* AW - short [] root_x = new short [1], root_y = new short [1]; - OS.XtTranslateCoords (handle, (short) 0, (short) 0, root_x, root_y); - return new Point (point.x - root_x [0], point.y - root_y [0]); - */ - return MacUtil.toControl(handle, point); -} -/** - * Returns a point which is the result of converting the - * argument, which is specified in coordinates relative to - * the receiver, to display relative coordinates. - * <p> - * @param point the point to be translated (must not be null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the point is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + Rect rect = new Rect (); + int window = OS.GetControlOwner (handle); + OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect); + int x = point.x - rect.left; + int y = point.y - rect.top; + OS.GetControlBounds (handle, rect); + return new Point (x - rect.left, y - rect.top); +} + public Point toDisplay (Point point) { checkWidget(); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - /* AW - short [] root_x = new short [1], root_y = new short [1]; - OS.XtTranslateCoords (handle, (short) point.x, (short) point.y, root_x, root_y); - return new Point (root_x [0], root_y [0]); - */ - return MacUtil.toDisplay(handle, point); -} -/* AW -boolean translateMnemonic (char key, XKeyEvent xEvent) { - if (!isVisible () || !isEnabled ()) return false; - boolean doit = mnemonicMatch (key); - if (hooks (SWT.Traverse)) { - Event event = new Event(); - event.doit = doit; - event.detail = SWT.TRAVERSE_MNEMONIC; - event.time = xEvent.time; - setKeyState (event, xEvent); - sendEvent (SWT.Traverse, event); - doit = event.doit; - } - if (doit) return mnemonicHit (key); - return false; + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + int x = point.x + rect.left; + int y = point.y + rect.top; + int window = OS.GetControlOwner (handle); + OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect); + return new Point (x + rect.left, y + rect.top); } -boolean translateMnemonic (int key, XKeyEvent xEvent) { - if (xEvent.state != OS.Mod1Mask) { - if (xEvent.state != 0 || !(this instanceof Button)) { - return false; - } - } - Decorations shell = menuShell (); - if (shell.isVisible () && shell.isEnabled ()) { - char ch = mbcsToWcs ((char) key); - return ch != 0 && shell.translateMnemonic (ch, xEvent); - } - return false; + +int topHandle () { + return handle; } -*/ -boolean translateTraversal (MacEvent mEvent) { - - int kind= mEvent.getKind(); - if (kind != OS.kEventRawKeyDown && kind != OS.kEventRawKeyRepeat) - return false; - - int detail = SWT.TRAVERSE_NONE; - /* AW - GdkEventKey keyEvent = new GdkEventKey (); - OS.memmove (keyEvent, gdkEvent, GdkEventKey.sizeof); - int key = keyEvent.keyval; - int code = traversalCode (key, gdkEvent); - int [] state = new int [1]; - OS.gdk_event_get_state (gdkEvent, state); - */ - int code= traversalCode (); - int key= mEvent.getKeyCode(); - int state= mEvent.getStateMask(); - boolean all = false; - switch (key) { - case 53 /* OS.GDK_Escape: - case OS.GDK_Cancel */: { - all = true; - detail = SWT.TRAVERSE_ESCAPE; - break; - } - case 36 /* OS.GDK_Return */ : { - all = true; - detail = SWT.TRAVERSE_RETURN; - break; - } - //case OS.GDK_ISO_Left_Tab: - case 48 /* OS.GDK_Tab */ : { - boolean next = (state & SWT.SHIFT) == 0; - /* - * NOTE: This code causes Shift+Tab and Ctrl+Tab to - * always attempt traversal which is not correct. - * The default should be the same as a plain Tab key. - * This behavior is currently relied on by StyledText. - * - * The correct behavior is to give every key to any - * control that wants to see every key. The default - * behavior for a Canvas should be to see every key. - */ - /* AW - switch (state [0]) { - case OS.GDK_SHIFT_MASK: - case OS.GDK_CONTROL_MASK: - code |= SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT; - } - */ - detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS; - break; - } - case 126: // OS.GDK_Up: - case 123: // OS.GDK_Left: - detail = SWT.TRAVERSE_ARROW_PREVIOUS; - break; - - case 125: // OS.GDK_Down: - case 124: /* OS.GDK_Right: */ - detail = SWT.TRAVERSE_ARROW_NEXT; - break; - - case 116: // OS.GDK_Page_Up: - case 121: /* OS.GDK_Page_Down: */ { - all = true; - /* AW - if ((state [0] & OS.GDK_CONTROL_MASK) == 0) return false; - */ - /* - * NOTE: This code causes Ctrl+PgUp and Ctrl+PgDn to always - * attempt traversal which is not correct. This behavior is - * currently relied on by StyledText. - * - * The correct behavior is to give every key to any - * control that wants to see every key. The default - * behavior for a Canvas should be to see every key. - */ - code |= SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS; - detail = key == 121 ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS; - break; - } - default: - return false; - } - - Event event = new Event (); - event.doit = (code & detail) != 0; - event.detail = detail; - /* AW - event.time = keyEvent.time; - setInputState (event, gdkEvent); - */ - 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); + +boolean traverseMnemonic (char key) { return false; } -int traversalCode () { - /* AW - int [] argList = new int [] {OS.XmNtraversalOn, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - if (argList [1] == 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; - /* AW - if (getNavigationType () == OS.XmNONE) { - code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS; - } - */ - return code; -} -boolean traverseMnemonic (char key) { - if (!isVisible () || !isEnabled ()) return false; - return mnemonicMatch (key) && mnemonicHit (key); -} -/** - * Based on the argument, perform one of the expected platform - * traversal action. The argument should be one of the constants: - * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>, - * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>, - * <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>. - * - * @param traversal the type of traversal - * @return true if the traversal succeeded - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public boolean traverse (int traversal) { checkWidget(); if (!isFocusControl () && !setFocus ()) return false; @@ -2612,71 +1220,19 @@ boolean traverse (Event event) { } boolean traverseEscape () { - Shell shell = getShell (); - if (shell.parent == null) return false; - if (!shell.isVisible () || !shell.isEnabled ()) return false; - shell.close (); - return true; + return false; } boolean traverseGroup (boolean next) { - Control root = computeTabRoot (); - Control group = computeTabGroup (); - Control [] list = root.computeTabList (); - int length = list.length; - int index = 0; - while (index < length) { - if (list [index] == group) break; - index++; - } - /* - * It is possible (but unlikely), that application - * code could have disposed the widget in focus in - * or out events. Ensure that a disposed widget is - * not accessed. - */ - if (index == length) return false; - int start = index, offset = (next) ? 1 : -1; - while ((index = ((index + offset + length) % length)) != start) { - Control control = list [index]; - if (!control.isDisposed () && control.setTabGroupFocus ()) { - if (!isDisposed () && !isFocusControl ()) return true; - } - } - if (group.isDisposed ()) return false; - return group.setTabGroupFocus (); + return false; } boolean traverseItem (boolean next) { - Control [] children = parent._getChildren (); - int length = children.length; - int index = 0; - while (index < length) { - if (children [index] == this) break; - index++; - } - /* - * It is possible (but unlikely), that application - * code could have disposed the widget in focus in - * or out events. Ensure that a disposed widget is - * not accessed. - */ - int start = index, offset = (next) ? 1 : -1; - while ((index = (index + offset + length) % length) != start) { - Control child = children [index]; - if (!child.isDisposed () && child.isTabItem ()) { - if (child.setTabItemFocus ()) return true; - } - } return false; } boolean traverseReturn () { - Button button = menuShell ().getDefaultButton (); - if (button == null || button.isDisposed ()) return false; - if (!button.isVisible () || !button.isEnabled ()) return false; - button.click (); - return true; + return false; } boolean traversePage (boolean next) { @@ -2684,96 +1240,13 @@ boolean traversePage (boolean next) { } boolean traverseMnemonic (Event event) { - // This code is intentionally commented. - // TraverseMnemonic always originates from the OS and - // never through the API, and on the GTK platform, accels - // are hooked by the OS before we get the key event. - // int shellHandle = _getShell ().topHandle (); - // return OS.gtk_accel_groups_activate (shellHandle, keyCode, stateMask); - return true; + return false; } -/** - * Forces all outstanding paint requests for the widget tree - * to be processed before this method returns. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #redraw - */ + public void update () { checkWidget(); - /* AW - int display = OS.XtDisplay (handle); - if (display == 0) return; - int window = OS.XtWindow (handle); - if (window == 0) return; - XAnyEvent event = new XAnyEvent (); - OS.XSync (display, false); OS.XSync (display, false); - while (OS.XCheckWindowEvent (display, window, OS.ExposureMask, event)) { - OS.XtDispatchEvent (event); - } - */ - getDisplay().update(); + Display display = getDisplay (); + display.update (); } -////////////////////////////////////////////////////////////////////// -// Mac stuff -////////////////////////////////////////////////////////////////////// - /** - * Sets the bounds of the given control. - */ - private void internalSetBounds(int hndl, MacRect oldBounds, int x, int y, int width, int height) { - if (MacUtil.USE_FRAME) { - MacRect newBounds= new MacRect(x, y, width, height); - handleResize(hndl, newBounds); - } else { - int wHandle= OS.GetControlOwner(hndl); - OS.InvalWindowRect(wHandle, oldBounds.getData()); - - MacRect newBounds= new MacRect(x, y, width, height); - handleResize(hndl, newBounds); - OS.InvalWindowRect(wHandle, newBounds.getData()); - } - } - - /** - * subclasses can override if a resize must trigger some internal layout. - */ - void handleResize(int hndl, MacRect bounds) { - if (MacUtil.USE_FRAME) - OS.HIViewSetFrame(hndl, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); - else - OS.SetControlBounds(hndl, bounds.getData()); - } - - /** - * subclasses can override. - */ - void internalGetControlBounds(int hndl, MacRect bounds) { - if (MacUtil.USE_FRAME) { - float[] f= new float[4]; - OS.HIViewGetFrame(hndl, f); - bounds.set((int)f[0], (int)f[1], (int)f[2], (int)f[3]); - } else { - OS.GetControlBounds(hndl, bounds.getData()); - } - } - - /** - * Hook (overwritten in Text and Combo) - */ - /* - final int sendKeyEvent(int type, int nextHandler, int eRefHandle) { - - MacEvent mEvent= new MacEvent(eRefHandle); - if (translateTraversal(mEvent)) - return 0; - - processEvent (type, new MacEvent(eRefHandle)); - return OS.kNoErr; - } - */ }
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java index 7a503de3ab..7c6ac98fa1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java @@ -7,413 +7,117 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; + import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -/** - * Instances of this class provide the appearance and - * behavior of <code>Shells</code>, but are not top - * level shells or dialogs. Class <code>Shell</code> - * shares a significant amount of code with this class, - * and is a subclass. - * <p> - * Instances are always displayed in one of the maximized, - * minimized or normal states: - * <ul> - * <li> - * When an instance is marked as <em>maximized</em>, the - * window manager will typically resize it to fill the - * entire visible area of the display, and the instance - * is usually put in a state where it can not be resized - * (even if it has style <code>RESIZE</code>) until it is - * no longer maximized. - * </li><li> - * When an instance is in the <em>normal</em> state (neither - * maximized or minimized), its appearance is controlled by - * the style constants which were specified when it was created - * and the restrictions of the window manager (see below). - * </li><li> - * When an instance has been marked as <em>minimized</em>, - * its contents (client area) will usually not be visible, - * and depending on the window manager, it may be - * "iconified" (that is, replaced on the desktop by a small - * simplified representation of itself), relocated to a - * distinguished area of the screen, or hidden. Combinations - * of these changes are also possible. - * </li> - * </ul> - * </p> - * Note: The styles supported by this class must be treated - * as <em>HINT</em>s, since the window manager for the - * desktop on which the instance is visible has ultimate - * control over the appearance and behavior of decorations. - * For example, some window managers only support resizable - * windows and will always assume the RESIZE style, even if - * it is not set. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, 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 - */ public class Decorations extends Canvas { - String label; Image image; - /* AW - int dialogHandle; - */ - // AW - private static final int FIRST_MENU_ITEM_ID= 1000; - // AW - boolean minimized, maximized; Menu menuBar; - Menu [] menus; - MenuItem [] items; + String text = ""; + boolean minimized, maximized; Control savedFocus; 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, checkStyle (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 add (MenuItem item) { - if (items == null) items = new MenuItem [12]; - for (int i=0; i<items.length; i++) { - if (items [i] == null) { - item.id = FIRST_MENU_ITEM_ID + i; - items [i] = item; - return; - } - } - MenuItem [] newItems = new MenuItem [items.length + 12]; - item.id = FIRST_MENU_ITEM_ID + items.length; - newItems [items.length] = item; - System.arraycopy (items, 0, newItems, 0, items.length); - items = newItems; -} -void bringToTop () { - /* - * Feature in X. Calling XSetInputFocus() when the - * widget is not viewable causes an X bad match error. - * The fix is to call XSetInputFocus() when the widget - * is viewable. - */ - if (minimized) return; - if (!isVisible ()) return; - /* AW - int display = OS.XtDisplay (handle); - if (display == 0) return; - int window = OS.XtWindow (handle); - if (window == 0) return; - OS.XSetInputFocus (display, window, OS.RevertToParent, OS.CurrentTime); - */ -} + static int checkStyle (int style) { if ((style & (SWT.MENU | SWT.MIN | SWT.MAX | SWT.CLOSE)) != 0) { style |= SWT.TITLE; } return style; } + protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } + Control computeTabGroup () { return this; } + Control computeTabRoot () { return this; } -void createHandle (int index) { - state |= HANDLE | CANVAS; - createScrolledHandle (parent.handle); -} -void createWidget (int index) { - super.createWidget (index); - label = ""; -} -/* AW -int dialogHandle () { - if (dialogHandle != 0) return dialogHandle; - return dialogHandle = OS.createDialogShell(handle, 0); -} -*/ -/* AW -Menu findMenu (int id) { - System.out.println("********* Decorator.findMenu *********"); - if (menus == null) return null; - for (int i= 0; i < menus.length; i++) { - Menu menu= menus[i]; - if (menu != null) { - if (OS.GetMenuID(menu.handle) == id) - return menu; - } - } - return null; -} -*/ -// AW -MenuItem findMenuItem (int id) { - if (items == null) return null; - id-= FIRST_MENU_ITEM_ID; - if (0 <= id && id < items.length) return items [id]; - return null; -} -// AW -/** - * Returns the receiver's default button if one had - * previously been set, otherwise returns null. - * - * @return the default button or null - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setDefaultButton - */ + public Button getDefaultButton () { checkWidget(); 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 <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 maximized; } -/** - * Returns the receiver's menu bar if one had previously - * been set, otherwise returns null. - * - * @return the menu bar or null - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Menu getMenuBar () { checkWidget(); return menuBar; } -/** - * Returns <code>true</code> if the receiver is currently - * minimized, and false otherwise. - * <p> - * - * @return the minimized state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setMinimized - */ + public boolean getMinimized () { checkWidget(); return minimized; } + String getNameText () { return getText (); } -/** - * Returns the receiver's text, which is the string that the - * window manager will typically display as the receiver's - * <em>title</em>. If the text has not previously been set, - * returns an empty string. - * - * @return the text - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public String getText () { checkWidget(); - return label; + return text; } + boolean isTabGroup () { return true; } + boolean isTabItem () { return false; } + Decorations menuShell () { return this; } -int processSetFocus (Object callData) { - int result= super.processSetFocus (callData); - - Boolean b= (Boolean) callData; - if (b.booleanValue ()) { // focusIn - restoreFocus (); - } else { // focuOut - saveFocus (); - } - - return result; -} -/* AW -void propagateWidget (boolean enabled) { - super.propagateWidget (enabled); - int [] argList = {OS.XmNmenuBar, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - if (argList [1] != 0) propagateHandle (enabled, argList [1]); -} -*/ -/* AW -void releaseHandle () { - super.releaseHandle (); - dialogHandle = 0; -} -*/ + void releaseWidget () { + if (menuBar != null) menuBar.dispose (); + menuBar = null; + Display display = getDisplay (); + Menu [] menus = display.getMenus (this); if (menus != null) { - for (int i=0; i<menus.length; i++) { - Menu menu = menus [i]; - if (menu != null && !menu.isDisposed ()) { - menu.releaseWidget (); - menu.releaseHandle (); + do { + int index = 0; + while (index < menus.length) { + Menu menu = menus [index]; + if (menu != null && !menu.isDisposed ()) { + while (menu.getParentMenu () != null) { + menu = menu.getParentMenu (); + } + menu.dispose (); + break; + } + index++; } - } + if (index == menus.length) break; + } while (true); } - menuBar = null; menus = null; super.releaseWidget (); defaultButton = saveDefault = null; - label = 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 remove (MenuItem item) { - if (items == null) return; - items [item.id - FIRST_MENU_ITEM_ID] = null; - item.id = -1; } boolean restoreFocus () { @@ -423,33 +127,16 @@ boolean restoreFocus () { } void saveFocus () { - Control control = getDisplay ().getFocusControl (); - if (control != null) setSavedFocus (control); + int window = OS.GetControlOwner (handle); + Control control = getDisplay ().getFocusControl (window); + if (control != null) savedFocus = control; } -/** - * If the argument is not null, sets the receiver's default - * button to the argument, and if the argument is null, sets - * the receiver's default button to the first button which - * was set as the receiver's default button (called the - * <em>saved default button</em>). If no default button had - * previously been set, or the saved default button was - * disposed, the receiver's default button will be set to - * null. - * - * @param the new default button - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setDefaultButton (Button button) { checkWidget(); setDefaultButton (button, true); } + void setDefaultButton (Button button, boolean save) { if (button == null) { if (defaultButton == saveDefault) { @@ -471,96 +158,20 @@ void setDefaultButton (Button button, boolean save) { if (save || saveDefault == null) saveDefault = defaultButton; if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null; } -/** - * Sets the receiver's image to the argument, which may - * be null. The image is typically displayed by the window - * manager when the instance is marked as iconified, and - * may also be displayed somewhere in the trim when the - * instance is in normal or maximized states. - * - * @param image the new image (or null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setImage (Image image) { checkWidget(); - /* AW - int pixmap = 0, mask = 0; - */ if (image != null) { if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); - /* AW - switch (image.type) { - case SWT.BITMAP: - pixmap = image.pixmap; - break; - case SWT.ICON: - pixmap = image.pixmap; - mask = image.mask; - break; - default: - error (SWT.ERROR_INVALID_IMAGE); - } - */ } this.image = image; - /* AW - int [] argList = { - OS.XmNiconPixmap, pixmap, - OS.XmNiconMask, mask, - }; - int topHandle = topHandle (); - OS.XtSetValues (topHandle, argList, argList.length / 2); - */ } -/** - * Sets the maximized state of the receiver. - * If the argument is <code>true</code> causes the receiver - * to switch to the maximized state, and if the argument is - * <code>false</code> and the receiver was previously maximized, - * causes the receiver to switch back to either the minimized - * or normal states. - * <p> - * Note: The result of intermixing calls to<code>setMaximized(true)</code> - * and <code>setMinimized(true)</code> will vary by platform. Typically, - * the behavior will match the platform user's expectations, but not - * always. This should be avoided if possible. - * </p> - * - * @param the new maximized state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setMinimized - */ + public void setMaximized (boolean maximized) { checkWidget(); this.maximized = maximized; } -/** - * Sets the receiver's menu bar to the argument, which - * may be null. - * - * @param menu the new menu bar - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li> - * <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 (menuBar == menu) return; @@ -569,117 +180,20 @@ public void setMenuBar (Menu menu) { if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR); if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT); } - - /* Ensure the new menu bar is correctly enabled */ - if (menuBar != null) { - if (!isEnabled () && menuBar.getEnabled ()) { - propagateHandle (true, menuBar.handle); - } - } - if (menu != null) { - if (!isEnabled ()) { - propagateHandle (false, menu.handle); - } - } - - /* - * Bug in Motif. When a XmMainWindowSetAreas () is used - * to replace an existing menu, both menus must be managed - * before the call to XmMainWindowSetAreas () or the new - * menu will not be layed out properly. - */ - /* AW - int newHandle = (menu != null) ? menu.handle : 0; - int oldHandle = (menuBar != null) ? menuBar.handle : 0; - */ menuBar = menu; - /* AW - int hHandle = (horizontalBar != null) ? horizontalBar.handle : 0; - int vHandle = (verticalBar != null) ? verticalBar.handle : 0; - if (newHandle != 0) { - OS.XtSetMappedWhenManaged (newHandle, false); - OS.XtManageChild (newHandle); - } - int clientHandle = (formHandle != 0) ? formHandle : handle; - OS.XmMainWindowSetAreas (scrolledHandle, newHandle, 0, hHandle, vHandle, clientHandle); - if (oldHandle != 0) OS.XtUnmanageChild (oldHandle); - if (newHandle != 0) { - OS.XtSetMappedWhenManaged (newHandle, true); - } - */ - /* - * Bug in Motif. When a menu bar is removed after the - * main window has been realized, the main window does - * not layout the new menu bar or the work window. - * The fix is to force a layout by temporarily resizing - * the main window. - */ - /* AW - if (newHandle == 0 && OS.XtIsRealized (scrolledHandle)) { - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - OS.XtResizeWidget (scrolledHandle, argList [1] + 1, argList [3], argList [5]); - OS.XtResizeWidget (scrolledHandle, argList [1], argList [3], argList [5]); - } - */ + Display display = getDisplay (); + display.updateMenuBar (); } -/** - * Sets the minimized stated of the receiver. - * If the argument is <code>true</code> causes the receiver - * to switch to the minimized state, and if the argument is - * <code>false</code> and the receiver was previously minimized, - * causes the receiver to switch back to either the maximized - * or normal states. - * <p> - * Note: The result of intermixing calls to<code>setMaximized(true)</code> - * and <code>setMinimized(true)</code> will vary by platform. Typically, - * the behavior will match the platform user's expectations, but not - * always. This should be avoided if possible. - * </p> - * - * @param the new maximized state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setMaximized - */ + public void setMinimized (boolean minimized) { checkWidget(); this.minimized = minimized; } -void setSavedFocus (Control control) { - if (this == control) return; - savedFocus = control; -} -/** - * Sets the receiver's text, which is the string that the - * window manager will typically display as the receiver's - * <em>title</em>, to the argument, which may not be null. - * - * @param text the new text - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - label = string; -} -public void setVisible (boolean visible) { - super.setVisible (visible); - if (!visible) return; - if (savedFocus != null && !savedFocus.isDisposed ()) { - savedFocus.setFocus (); - } - savedFocus = null; + text = string; } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/DirectoryDialog.java index f301b96258..72e55fab51 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/DirectoryDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/DirectoryDialog.java @@ -10,182 +10,97 @@ package org.eclipse.swt.widgets; import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.*; -/** - * Instances of this class allow the user to navigate - * the file system and select a directory. - * <p> - * IMPORTANT: This class is intended to be subclassed <em>only</em> - * within the SWT implementation. - * </p> - */ + public class DirectoryDialog extends Dialog { - String filterPath = ""; - String message = ""; -/** - * Constructs a new instance of this class given only its - * parent. - * <p> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ + String message = "", filterPath = ""; + public DirectoryDialog (Shell parent) { - this (parent, SWT.PRIMARY_MODAL); + 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> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ + public DirectoryDialog (Shell parent, int style) { super (parent, style); checkSubclass (); } -/** - * Returns the path which the dialog will use to filter - * the directories it shows. - * - * @return the filter path - */ + public String getFilterPath () { return filterPath; } -/** - * Returns the dialog's message, which is a description of - * the purpose for which it was opened. This message will be - * visible on the dialog while it is open. - * - * @return the message - */ + public String getMessage () { return message; } -private String interpretOsAnswer(int dialog) { - int[] tmp= new int[1]; - OS.NavDialogGetReply(dialog, tmp); - int reply= tmp[0]; - - int selection= OS.NavReplyRecordGetSelection(reply); - OS.AECountItems(selection, tmp); - int count= tmp[0]; - - if (count > 0) { - OS.AEGetNthPtr(selection, 1, tmp); - return MacUtil.getStringAndRelease(tmp[0]); - } - return null; -} -/** - * 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 dialog= 0; - int titleHandle= 0; - int messageHandle= 0; - try { - int[] dialogHandle= new int[1]; - - int parentWindowHandle= 0; - if (parent != null) - parentWindowHandle= parent.shellHandle; - - titleHandle= OS.CFStringCreateWithCharacters(title); - messageHandle= OS.CFStringCreateWithCharacters(message); - - int flags= 0; - OS.NavCreateChooseFolderDialog(flags, titleHandle, messageHandle, parentWindowHandle, dialogHandle); - dialog= dialogHandle[0]; - - if (dialog != 0) { - - OS.NavDialogRun(dialog); - - switch (OS.NavDialogGetUserAction(dialog)) { - case OS.kNavUserActionCancel: - break; - - case OS.kNavUserActionOpen: - case OS.kNavUserActionChoose: - return interpretOsAnswer(dialog); + String directoryPath = null; + int titlePtr = 0; + int messagePtr = 0; + if (title != null) { + char [] buffer = new char [title.length ()]; + title.getChars (0, buffer.length, buffer, 0); + titlePtr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + } + if (message != null) { + char [] buffer = new char [message.length ()]; + message.getChars (0, buffer.length, buffer, 0); + messagePtr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + } + + NavDialogCreationOptions options = new NavDialogCreationOptions (); + options.parentWindow = OS.GetControlOwner (parent.handle); + // NEEDS WORK - no title displayed + options.windowTitle = options.clientName = titlePtr; + options.optionFlags = OS.kNavSupportPackages | OS.kNavAllowOpenPackages | OS.kNavAllowInvisibleFiles; + options.message = messagePtr; + options.location_h = -1; + options.location_v = -1; + int [] outDialog = new int [1]; + // NEEDS WORK - use inFilterProc to handle filtering + if (OS.NavCreateChooseFolderDialog (options, 0, 0, 0, outDialog) == OS.noErr) { + OS.NavDialogRun (outDialog [0]); + if (OS.NavDialogGetUserAction (outDialog [0]) == OS.kNavUserActionChoose) { + NavReplyRecord record = new NavReplyRecord (); + OS.NavDialogGetReply (outDialog [0], record); + AEDesc selection = new AEDesc (); + selection.descriptorType = record.selection_descriptorType; + selection.dataHandle = record.selection_dataHandle; + int [] count = new int [1]; + OS.AECountItems (selection, count); + if (count [0] > 0) { + int [] theAEKeyword = new int [1]; + int [] typeCode = new int [1]; + int maximumSize = 80; // size of FSRef + int dataPtr = OS.NewPtr (maximumSize); + int [] actualSize = new int [1]; + int status = OS.AEGetNthPtr (selection, 1, OS.typeFSRef, theAEKeyword, typeCode, dataPtr, maximumSize, actualSize); + if (status == OS.noErr && typeCode [0] == OS.typeFSRef) { + byte [] fsRef = new byte [actualSize [0]]; + OS.memcpy (fsRef, dataPtr, actualSize [0]); + int dirUrl = OS.CFURLCreateFromFSRef (OS.kCFAllocatorDefault, fsRef); + int dirString = OS.CFURLCopyFileSystemPath(dirUrl, OS.kCFURLPOSIXPathStyle); + OS.CFRelease (dirUrl); + int length = OS.CFStringGetLength (dirString); + char [] buffer= new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (dirString, range, buffer); + OS.CFRelease (dirString); + directoryPath = new String (buffer); + } + OS.DisposePtr (dataPtr); } } - - return null; - - } finally { - if (titleHandle != 0) - OS.CFRelease(titleHandle); - if (messageHandle != 0) - OS.CFRelease(messageHandle); - if (dialog != 0) - OS.NavDialogDispose(dialog); } + if (titlePtr != 0) OS.CFRelease (titlePtr); + if (messagePtr != 0) OS.CFRelease (messagePtr); + if (outDialog [0] != 0) OS.NavDialogDispose (outDialog [0]); + return directoryPath; } -/** - * Sets the dialog's message, which is a description of - * the purpose for which it was opened. This message will be - * visible on the dialog while it is open. - * - * @param string the message - */ + public void setMessage (String string) { message = string; } -/** - * Sets the path which the dialog will use to filter - * the directories it shows to the argument, which may be - * null. - * - * @param string the filter path - */ + public void setFilterPath (String string) { filterPath = string; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java index a58090eb3d..7ee99dcfd2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java @@ -7,124 +7,35 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import java.util.ArrayList; -import java.util.Iterator; + +import org.eclipse.swt.internal.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.CGPoint; +import org.eclipse.swt.internal.carbon.CGRect; +import org.eclipse.swt.internal.carbon.Rect; +import org.eclipse.swt.internal.carbon.HICommand; +import org.eclipse.swt.internal.carbon.RGBColor; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.Callback; -import org.eclipse.swt.internal.carbon.*; -/** - * 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</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 #dispose - */ public class Display extends Device { - /* Windows, Events and Callbacks */ - static String APP_NAME = "SWT"; - Event [] eventQueue; - EventTable eventTable; - - /* Default Fonts, Colors, Insets, Widths and Heights. */ - Font defaultFont; - Font listFont, textFont, buttonFont, labelFont, groupFont; - private short fHoverThemeFont; - - int dialogBackground, dialogForeground; - int buttonBackground, buttonForeground, buttonShadowThickness; - int compositeBackground, compositeForeground; - int compositeTopShadow, compositeBottomShadow, compositeBorder; - int listBackground, listForeground, listSelect, textBackground, textForeground; - int labelBackground, labelForeground, scrollBarBackground, scrollBarForeground; - int scrolledInsetX, scrolledInsetY, scrolledMarginX, scrolledMarginY; - int defaultBackground, defaultForeground; - int textHighlightThickness; - - /* System Colors */ - Color COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW; - Color COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_BORDER; - Color COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT; - Color COLOR_INFO_BACKGROUND; + //TEMPORARY + int textHighlightThickness = 4; - /* Initial Guesses for Shell Trimmings. */ - int borderTrimWidth = 4, borderTrimHeight = 4; - int resizeTrimWidth = 6, resizeTrimHeight = 6; - int titleBorderTrimWidth = 5, titleBorderTrimHeight = 28; - int titleResizeTrimWidth = 6, titleResizeTrimHeight = 29; - int titleTrimWidth = 0, titleTrimHeight = 23; + /* Windows and Events */ + Event [] eventQueue; + Callback actionCallback, commandCallback, controlCallback; + Callback drawItemCallback, itemDataCallback, itemNotificationCallback, helpCallback; + Callback hitTestCallback, keyboardCallback, menuCallback, mouseHoverCallback; + Callback mouseCallback, trackingCallback, windowCallback; + int actionProc, commandProc, controlProc; + int drawItemProc, itemDataProc, itemNotificationProc, helpProc; + int hitTestProc, keyboardProc, menuProc, mouseHoverProc; + int mouseProc, trackingProc, windowProc; + EventTable eventTable, filterTable; + int queue, lastModifiers; /* Sync/Async Widget Communication */ Synchronizer synchronizer = new Synchronizer (this); @@ -134,44 +45,67 @@ public class Display extends Device { Runnable [] disposeList; /* Timers */ - int [] timerIDs; + int [] timerIds; Runnable [] timerList; + Callback timerCallback; int timerProc; + + /* Current caret */ + Caret currentCaret; + Callback caretCallback; + int caretID, caretProc; + + /* Grabs */ + Control grabControl; + + /* Hover Help */ + int helpString; + Control helpControl; + int lastHelpX, lastHelpY; + + /* Mouse Enter/Exit */ + Control currentControl; + + /* Mouse Hover */ + Control hoverControl; + int mouseHoverID; + + /* Menus */ + Menu menuBar; + Menu [] menus, popups; + MenuItem [] items; + static final int ID_TEMPORARY = 1000; + static final int ID_START = 1001; + + /* Insets */ + Rect buttonInset, tabFolderInset, comboInset; + + /* Focus */ + boolean ignoreFocus; /* Key Mappings. */ static int [] [] KeyTable = { - - // AW - //{49, 0x20}, // space - {51, SWT.BS}, - //{36, SWT.CR}, - // AW - - // Keyboard and Mouse Masks -// {OS.XK_Alt_L, SWT.ALT}, -// {OS.XK_Alt_R, SWT.ALT}, -// {OS.XK_Shift_L, SWT.SHIFT}, -// {OS.XK_Shift_R, SWT.SHIFT}, -// {OS.XK_Control_L, SWT.CONTROL}, -// {OS.XK_Control_R, SWT.CONTROL}, - -// {OS.VK_LBUTTON, SWT.BUTTON1}, -// {OS.VK_MBUTTON, SWT.BUTTON3}, -// {OS.VK_RBUTTON, SWT.BUTTON2}, + + /* Non-Numeric Keypad Keys */ + {126, SWT.ARROW_UP}, + {125, SWT.ARROW_DOWN}, + {123, SWT.ARROW_LEFT}, + {124, SWT.ARROW_RIGHT}, + {116, SWT.PAGE_UP}, + {121, SWT.PAGE_DOWN}, + {115, SWT.HOME}, + {119, SWT.END}, + {71, SWT.INSERT}, + + /* Virtual and Ascii Keys */ + {51, SWT.BS}, + {36, SWT.CR}, + {117, SWT.DEL}, + {53, SWT.ESC}, + {76, SWT.LF}, + {48, SWT.TAB}, - // Non-Numeric Keypad Constants - {126, SWT.ARROW_UP}, - {125, SWT.ARROW_DOWN}, - {123, SWT.ARROW_LEFT}, - {124, SWT.ARROW_RIGHT}, - {116, SWT.PAGE_UP}, - {121, SWT.PAGE_DOWN}, - {115, SWT.HOME}, - {119, SWT.END}, - {71, SWT.INSERT}, -// {OS.XK_Delete, SWT.DELETE}, - - // Functions Keys + /* Functions Keys */ {122, SWT.F1}, {120, SWT.F2}, {99, SWT.F3}, @@ -184,63 +118,22 @@ public class Display extends Device { {109, SWT.F10}, {103, SWT.F11}, {111, SWT.F12}, + + /* Numeric Keypad Keys */ }; /* Multiple Displays. */ static Display Default; static Display [] Displays = new Display [4]; - - /* Double Click */ - int lastTime, lastButton; - - /* Current caret */ - Caret currentCaret; - int caretID, caretProc; - + /* Package Name */ static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; - - /* Mouse Hover */ - int mouseHoverID, mouseHoverProc; - int mouseHoverHandle, toolTipWindowHandle; /* Display Data */ Object data; String [] keys; Object [] values; - /* AW Mac */ - private static final int TOOLTIP_MARGIN= 3; - private static final int HOVER_TIMEOUT= 500; // in milli seconds - private static final int SWT_USER_EVENT= ('S'<<24) + ('W'<<16) + ('T'<<8) + '1'; - - private int fMenuId= 5000; - - // Callbacks - private ArrayList fCallbacks; - // callback procs - int fApplicationProc; - int fWindowProc; - int fMouseProc; - int fMenuProc; - int fControlActionProc; - int fUserPaneDrawProc, fUserPaneHitTestProc, fUserPaneTrackingProc; - int fDataBrowserDataProc, fDataBrowserCompareProc, fDataBrowserItemNotificationProc; - - private int fUpdateRegion; - private int fTrackedControl; - private int fFocusControl; - private int fCurrentControl; - private String fToolTipText; - private int fLastHoverHandle; - boolean fInContextMenu; // true while tracking context menu - public int fCurrentCursor; - private Shell fMenuRootShell; - - private static boolean fgCarbonInitialized; - private static boolean fgInitCursorCalled; - /* end AW */ - /* * TEMPORARY CODE. Install the runnable that * gets the current display. This code will @@ -258,6 +151,26 @@ public class Display extends Device { }; } + static { + /* + * Feature in the Macintosh. On OS 10.2, it is necessary + * to explicitly check in with the Process Manager and set + * the current process to be the front process in order for + * windows to come to the front by default. The fix is call + * both GetCurrentProcess() and SetFrontProcess(). + * + * NOTE: It is not actually necessary to use the process + * serial number returned by GetCurrentProcess() in the + * call to SetFrontProcess() (ie. kCurrentProcess can be + * used) but both functions must be called in order for + * windows to come to the front. + */ + int [] psn = new int [2]; + if (OS.GetCurrentProcess (psn) == OS.noErr) { + OS.SetFrontProcess (psn); + } + } + /* * TEMPORARY CODE. */ @@ -265,53 +178,33 @@ 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 not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - * - * @see #getCurrent - * @see #getDefault - * @see Widget#checkSubclass - * @see Shell - */ -public Display () { - this (null); +static int translateKey (int key) { + for (int i=0; i<KeyTable.length; i++) { + if (KeyTable [i] [0] == key) return KeyTable [i] [1]; + } + return 0; } -public Display (DeviceData data) { - super (checkNull (data)); + +static int untranslateKey (int key) { + for (int i=0; i<KeyTable.length; i++) { + if (KeyTable [i] [1] == key) return KeyTable [i] [0]; + } + return 0; +} + +int actionProc (int theControl, int partCode) { + Widget widget = WidgetTable.get (theControl); + if (widget != null) return widget.actionProc (theControl, partCode); + return OS.noErr; +} + +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 notifed when an event of the given type occurs. When the - * event does occur in the display, the listener is notified by - * sending it the <code>handleEvent()</code> message. - * - * @param eventType the type of event to listen for - * @param listener the listener which should be notified when the event occurs - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see Listener - * @see #removeListener - * - * @since 2.0 - */ public void addListener (int eventType, Listener listener) { checkDevice (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -319,82 +212,95 @@ public void addListener (int eventType, Listener listener) { eventTable.hook (eventType, listener); } -/** - * Requests that the connection between SWT and the underlying - * operating system be closed. - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #dispose - * - * @since 2.0 - */ -public void close () { - checkDevice (); - Event event = new Event (); - sendEvent (SWT.Close, event); - if (event.doit) dispose (); +void addMenu (Menu menu) { + if (menus == null) menus = new Menu [12]; + for (int i=0; i<menus.length; i++) { + if (menus [i] == null) { + menu.id = (short)(ID_START + i); + menus [i] = menu; + return; + } + } + Menu [] newMenus = new Menu [menus.length + 12]; + menu.id = (short)(ID_START + menus.length); + newMenus [menus.length] = menu; + System.arraycopy (menus, 0, newMenus, 0, menus.length); + menus = newMenus; } -void addMouseHoverTimeOut (int handle) { - if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID); - mouseHoverID = 0; - if (handle == fLastHoverHandle) return; - int[] timer= new int[1]; - OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), HOVER_TIMEOUT / 1000.0, 0.0, mouseHoverProc, handle, timer); - mouseHoverID = timer[0]; - mouseHoverHandle = handle; -} -static DeviceData checkNull (DeviceData data) { - if (data == null) data = new DeviceData (); - return data; +void addMenuItem (MenuItem item) { + if (items == null) items = new MenuItem [12]; + for (int i=0; i<items.length; i++) { + if (items [i] == null) { + item.id = ID_START + i; + items [i] = item; + return; + } + } + MenuItem [] newItems = new MenuItem [items.length + 12]; + item.id = ID_START + items.length; + newItems [items.length] = item; + System.arraycopy (items, 0, newItems, 0, items.length); + items = newItems; } -protected void checkDevice () { - if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); - if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); + +void addPopup (Menu menu) { + if (popups == null) popups = new Menu [4]; + int length = popups.length; + for (int i=0; i<length; i++) { + if (popups [i] == menu) return; + } + int index = 0; + while (index < length) { + if (popups [index] == null) break; + index++; + } + if (index == length) { + Menu [] newPopups = new Menu [length + 4]; + System.arraycopy (popups, 0, newPopups, 0, length); + popups = newPopups; + } + popups [index] = menu; } -/** - * Causes the <code>run()</code> method of the runnable to - * be invoked by the user-interface thread at the next - * reasonable opportunity. The caller of this method continues - * to run in parallel, and is not notified when the - * runnable has completed. - * - * @param runnable code to run on the user-interface thread. - * - * @see #syncExec - */ + public void asyncExec (Runnable runnable) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); synchronizer.asyncExec (runnable); } -/** - * Causes the system hardware to emit a short sound - * (if it supports this capability). - */ + public void beep () { checkDevice (); - OS.SysBeep((short)100); + OS.SysBeep ((short) 100); } + int caretProc (int id, int clientData) { - if (id != caretID) { - return 0; - } - OS.RemoveEventLoopTimer(id); - caretID = 0; if (currentCaret == null) return 0; if (currentCaret.blinkCaret ()) { int blinkRate = currentCaret.blinkRate; - int[] timer= new int[1]; - OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), blinkRate / 1000.0, 0.0, caretProc, 0, timer); - caretID = timer[0]; + OS.SetEventLoopTimerNextFireTime (id, blinkRate / 1000.0); } else { currentCaret = null; } return 0; } + +protected void checkDevice () { + if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); + if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); +} + +protected void checkSubclass () { + if (!Display.isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS); +} + +public Display () { + this (null); +} + +public Display (DeviceData data) { + super (data); +} + static synchronized void checkDisplay (Thread thread) { for (int i=0; i<Displays.length; i++) { if (Displays [i] != null && Displays [i].thread == thread) { @@ -402,11 +308,68 @@ static synchronized void checkDisplay (Thread thread) { } } } -protected void checkSubclass () { - if (!Display.isValidClass (getClass ())) { - error (SWT.ERROR_INVALID_SUBCLASS); + +int commandProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + HICommand command = new HICommand (); + OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeHICommand, null, HICommand.sizeof, null, command); + switch (eventKind) { + case OS.kEventProcessCommand: { + if (command.commandID == OS.kAEQuitApplication) { + close (); + return OS.noErr; + } + if ((command.attributes & OS.kHICommandFromMenu) != 0) { + if (userData != 0) { + Widget widget = WidgetTable.get (userData); + if (widget != null) return widget.commandProc (nextHandler, theEvent, userData); + } else { + int menuRef = command.menu_menuRef; + short menuID = OS.GetMenuID (menuRef); + Menu menu = findMenu (menuID); + if (menu != null) { + int [] outCommandID = new int [1]; + short menuIndex = command.menu_menuItemIndex; + OS.GetMenuItemCommandID (menuRef, menuIndex, outCommandID); + MenuItem item = findMenuItem (outCommandID [0]); + return item.kEventProcessCommand (nextHandler, theEvent, userData); + } + OS.HiliteMenu ((short) 0); + } + } + } } + return OS.eventNotHandledErr; } + +Rect computeInset (int control) { + int tempRgn = OS.NewRgn (); + Rect rect = new Rect (); + OS.GetControlRegion (control, (short) OS.kControlStructureMetaPart, tempRgn); + OS.GetControlBounds (control, rect); + Rect rgnRect = new Rect (); + OS.GetRegionBounds (tempRgn, rgnRect); + OS.DisposeRgn (tempRgn); + rect.left -= rgnRect.left; + rect.top -= rgnRect.top; + rect.right = (short) (rgnRect.right - rect.right); + rect.bottom = (short) (rgnRect.bottom - rect.bottom); + return rect; +} + +int controlProc (int nextHandler, int theEvent, int userData) { + Widget widget = WidgetTable.get (userData); + if (widget != null) return widget.controlProc (nextHandler, theEvent, userData); + return OS.eventNotHandledErr; +} + +public void close () { + checkDevice (); + Event event = new Event (); + sendEvent (SWT.Close, event); + if (event.doit) dispose (); +} + protected void create (DeviceData data) { checkSubclass (); checkDisplay (thread = Thread.currentThread ()); @@ -414,54 +377,27 @@ protected void create (DeviceData data) { register (this); if (Default == null) Default = this; } + void createDisplay (DeviceData data) { - - /* Initialize Carbon */ - synchronized (Display.class) { - if (!fgCarbonInitialized) { - OS.RegisterAppearanceClient(); - OS.TXNInitTextension(); - //OS.InitCursor(); - OS.QDSwapTextFlags(OS.kQDUseCGTextRendering + OS.kQDUseCGTextMetrics); - if (OS.InitContextualMenus() != OS.kNoErr) - System.out.println("Display.createDisplay: error in OS.InitContextualMenus"); - int[] psn= new int[2]; - if (OS.GetCurrentProcess(psn) == OS.kNoErr) - OS.SetFrontProcess(psn); - - OS.Init(); - } - fgCarbonInitialized = true; - } - - fGDeviceHandle= OS.GetMainDevice(); + queue = OS.GetCurrentEventQueue (); + OS.TXNInitTextension (0, 0, 0); } + synchronized static void deregister (Display display) { for (int i=0; i<Displays.length; i++) { if (display == Displays [i]) Displays [i] = null; } } + protected void destroy () { if (this == Default) Default = null; deregister (this); destroyDisplay (); } + void destroyDisplay () { - // dispose Callbacks - Iterator iter= fCallbacks.iterator(); - while (iter.hasNext()) { - Callback cb= (Callback) iter.next(); - cb.dispose(); - } - fCallbacks= null; } -/** - * Causes the <code>run()</code> method of the runnable to - * be invoked by the user-interface thread just before the - * receiver is disposed. - * - * @param runnable code to run at dispose time. - */ + public void disposeExec (Runnable runnable) { checkDevice (); if (disposeList == null) disposeList = new Runnable [4]; @@ -476,61 +412,46 @@ public void disposeExec (Runnable runnable) { newDisposeList [disposeList.length] = runnable; disposeList = newDisposeList; } + +int drawItemProc (int browser, int item, int property, int itemState, int theRect, int gdDepth, int colorDevice) { + Widget widget = WidgetTable.get (browser); + if (widget != null) return widget.drawItemProc (browser, item, property, itemState, theRect, gdDepth, colorDevice); + return OS.noErr; +} + void error (int code) { SWT.error(code); } -/** - * Given the operating system handle for a widget, returns - * the instance of the <code>Widget</code> subclass which - * represents it in the currently running application, if - * such exists, or null if no matching widget can be found. - * - * @param handle the handle for the widget - * @return the SWT widget that the handle represents - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +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); +} + +Menu findMenu (int id) { + if (menus == null) return null; + int index = id - ID_START; + if (0 <= index && index < menus.length) return menus [index]; + return null; +} + +MenuItem findMenuItem (int id) { + if (items == null) return null; + int index = id - ID_START; + if (0 <= index && index < items.length) return items [index]; + return null; +} + public Widget findWidget (int handle) { checkDevice (); return WidgetTable.get (handle); } -/** - * Returns the currently active <code>Shell</code>, or null - * if no shell belonging to the currently running application - * is active. - * - * @return the active shell or null - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public Shell getActiveShell () { - checkDevice (); - Control control = getFocusControl (); - if (control == null) return null; - return control.getShell (); -} -/** - * Returns the display which the currently running thread is - * the user-interface thread for, or null if the currently - * running thread is not a user-interface thread for any display. - * - * @return the current display - */ -public static synchronized Display getCurrent () { - return findDisplay (Thread.currentThread ()); -} -/** - * Returns the display which the given thread is the - * user-interface thread for, or null if the given thread - * is not a user-interface thread for any display. - * - * @param thread the user-interface thread - * @return the display for the given thread - */ + public static synchronized Display findDisplay (Thread thread) { for (int i=0; i<Displays.length; i++) { Display display = Displays [i]; @@ -540,93 +461,69 @@ public static synchronized Display findDisplay (Thread thread) { } return null; } -/** - * Returns the control which the on-screen pointer is currently - * over top of, or null if it is not currently over one of the - * controls built by the currently running application. - * - * @return the control under the cursor - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +public Shell getActiveShell () { + checkDevice (); + int theWindow = OS.ActiveNonFloatingWindow (); + if (theWindow == 0) return null; + int [] theControl = new int [1]; + OS.GetRootControl (theWindow, theControl); + Widget widget = WidgetTable.get (theControl [0]); + if (widget instanceof Shell) return (Shell) widget; + return null; +} + +public static synchronized Display getCurrent () { + return findDisplay (Thread.currentThread ()); +} + +int getCaretBlinkTime () { + return OS.GetCaretTime () * 1000 / 60; +} + public Control getCursorControl () { checkDevice (); - System.out.println("Display.getCursorControl: nyi"); - - /* AW - int [] unused = new int [1], buffer = new int [1]; - int xWindow, xParent = OS.XDefaultRootWindow (xDisplay); - do { - if (OS.XQueryPointer ( - xDisplay, xParent, unused, buffer, - unused, unused, unused, unused, unused) == 0) return null; - if ((xWindow = buffer [0]) != 0) xParent = xWindow; - } while (xWindow != 0); - int handle = OS.XtWindowToWidget (xDisplay, xParent); - if (handle == 0) return null; - do { - Widget widget = WidgetTable.get (handle); - if (widget != null && widget instanceof Control) { - Control control = (Control) widget; - if (control.getEnabled ()) return control; - } - } while ((handle = OS.XtParent (handle)) != 0); - */ + org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point (); + OS.GetGlobalMouse (where); + int [] theWindow = new int [1]; + if (OS.FindWindow (where, theWindow) != OS.inContent) return null; + if (theWindow [0] == 0) return null; + Rect rect = new Rect (); + OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, rect); + CGPoint inPoint = new CGPoint (); + inPoint.x = where.h - rect.left; + inPoint.y = where.v - rect.top; + int [] theRoot = new int [1]; + OS.GetRootControl (theWindow [0], theRoot); + int [] theControl = new int [1]; + OS.HIViewGetSubviewHit (theRoot [0], inPoint, true, theControl); + if (theControl [0] != 0) { + do { + Widget widget = WidgetTable.get (theControl [0]); + if (widget != null && widget instanceof Control) { + Control control = (Control) widget; + if (control.getEnabled ()) return control; + } + OS.GetSuperControl (theControl [0], theControl); + } while (theControl [0] != 0); + } + Widget widget = WidgetTable.get (theRoot [0]); + if (widget != null && widget instanceof Control) return (Control) widget; return null; } -/** - * Returns the location of the on-screen pointer relative - * to the top left corner of the screen. - * - * @return the cursor location - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Point getCursorLocation () { checkDevice (); - MacPoint loc= new MacPoint(); - OS.GetGlobalMouse(loc.getData()); - return new Point (loc.getX(), loc.getY()); + org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); + OS.GetGlobalMouse (pt); + return new Point (pt.h, pt.v); } -/** - * Returns the default display. One is created (making the - * thread that invokes this method its user-interface thread) - * if it did not already exist. - * - * @return the default display - */ + public static synchronized Display getDefault () { if (Default == null) Default = new Display (); return Default; } -/** - * Returns the application defined property of the receiver - * with the specified name, or null if it has not been set. - * <p> - * Applications may have associated arbitrary objects with the - * receiver in this fashion. If the objects stored in the - * properties need to be notified when the display is disposed - * of, it is the application's responsibility provide a - * <code>disposeExec()</code> handler which does so. - * </p> - * - * @param key the name of the property - * @return the value of the property or null if it has not been set - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the key is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setData - * @see #disposeExec - */ + public Object getData (String key) { checkDevice (); if (key == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -636,105 +533,74 @@ public Object getData (String key) { } return null; } -/** - * Returns the application defined, display specific data - * associated with the receiver, or null if it has not been - * set. The <em>display specific data</em> is a single, - * unnamed field that is stored with every display. - * <p> - * Applications may put arbitrary objects in this field. If - * the object stored in the display specific data needs to - * be notified when the display is disposed of, it is the - * application's responsibility provide a - * <code>disposeExec()</code> handler which does so. - * </p> - * - * @return the display specific data - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li> - * </ul> - * - * @see #setData - * @see #disposeExec - */ + public Object getData () { checkDevice (); return data; } -/** - * Returns the longest duration, in milliseconds, between - * two mouse button clicks that will be considered a - * <em>double click</em> by the underlying operating system. - * - * @return the double click time - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getDoubleClickTime () { checkDevice (); - return (OS.GetDblTime() * 1000) / 60; + return OS.GetDblTime (); } -/** - * Returns the control which currently has keyboard focus, - * or null if keyboard events are not currently going to - * any of the controls built by the currently running - * application. - * - * @return the control under the cursor - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Control getFocusControl () { checkDevice (); - /* AW - int [] buffer1 = new int [1], buffer2 = new int [1]; - OS.XGetInputFocus (xDisplay, buffer1, buffer2); - int xWindow = buffer1 [0]; - if (xWindow == 0) return null; - int handle = OS.XtWindowToWidget (xDisplay, xWindow); - if (handle == 0) return null; - handle = OS.XmGetFocusWidget (handle); - */ - int handle= fFocusControl; - if (handle == 0) return null; + int theWindow = OS.ActiveNonFloatingWindow (); + if (theWindow == 0) return null; + return getFocusControl (theWindow); +} + +Control getFocusControl (int window) { + int [] theControl = new int [1]; + OS.GetKeyboardFocus (window, theControl); + if (theControl [0] == 0) return null; do { - Widget widget = WidgetTable.get (handle); - if (widget instanceof Control) { - Control window = (Control) widget; - if (window.getEnabled ()) return window; + Widget widget = WidgetTable.get (theControl [0]); + if (widget != null && widget instanceof Control) { + Control control = (Control) widget; + if (control.getEnabled ()) return control; } - } while ((handle = MacUtil.getSuperControl (handle)) != 0); + OS.GetSuperControl (theControl [0], theControl); + } while (theControl [0] != 0); return null; } -/** - * Returns the maximum allowed depth of icons on this display. - * On some platforms, this may be different than the actual - * depth of the display. - * - * @return the maximum icon depth - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getIconDepth () { - return 8; // we don't support direct icons yet + return getDepth (); } -/** - * Returns an array containing all shells which have not been - * disposed and have the receiver as their display. - * - * @return the receiver's shells - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +int getLastEventTime () { + /* + * This code is intentionally commented. Event time is + * in seconds and we need an accurate time in milliseconds. + */ +// return (int) (OS.GetLastUserEventTime () * 1000.0); + return (int) System.currentTimeMillis (); +} + +Menu [] getMenus (Decorations shell) { + if (menus == null) return new Menu [0]; + int count = 0; + for (int i = 0; i < menus.length; i++) { + Menu menu = menus[i]; + if (menu != null && menu.parent == shell) count++; + } + int index = 0; + Menu[] result = new Menu[count]; + for (int i = 0; i < menus.length; i++) { + Menu menu = menus[i]; + if (menu != null && menu.parent == shell) { + result[index++] = menu; + } + } + return result; +} + +Menu getMenuBar () { + return menuBar; +} + public Shell [] getShells () { checkDevice (); /* @@ -762,300 +628,232 @@ public Shell [] getShells () { } return result; } -/** - * Returns the thread that has invoked <code>syncExec</code> - * or null if no such runnable is currently being invoked by - * the user-interface thread. - * <p> - * Note: If a runnable invoked by asyncExec is currently - * running, this method will return null. - * </p> - * - * @return the receiver's sync-interface thread - */ + public Thread getSyncThread () { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); return synchronizer.syncThread; } -/** - * Returns the matching standard color for the given - * constant, which should be one of the color constants - * specified in class <code>SWT</code>. Any value other - * than one of the SWT color constants which is passed - * in will result in the color black. This color should - * not be free'd because it was allocated by the system, - * not the application. - * - * @param id the color constant - * @return the matching color - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SWT - */ + public Color getSystemColor (int id) { checkDevice (); - Color xColor = null; + //NOT DONE + + RGBColor rgb = new RGBColor (); switch (id) { - case SWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK); - case SWT.COLOR_INFO_BACKGROUND: return COLOR_INFO_BACKGROUND; - case SWT.COLOR_TITLE_FOREGROUND: return super.getSystemColor (SWT.COLOR_WHITE); - case SWT.COLOR_TITLE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_BLUE); - case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_BLUE); - case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK); - case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_GRAY); - case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_GRAY); - case SWT.COLOR_WIDGET_DARK_SHADOW: xColor = COLOR_WIDGET_DARK_SHADOW; break; - case SWT.COLOR_WIDGET_NORMAL_SHADOW: xColor = COLOR_WIDGET_NORMAL_SHADOW; break; - case SWT.COLOR_WIDGET_LIGHT_SHADOW: xColor = COLOR_WIDGET_LIGHT_SHADOW; break; - case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: xColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break; - case SWT.COLOR_WIDGET_BACKGROUND: xColor = COLOR_WIDGET_BACKGROUND; break; - case SWT.COLOR_WIDGET_FOREGROUND: - case SWT.COLOR_WIDGET_BORDER: xColor = COLOR_WIDGET_BORDER; break; - case SWT.COLOR_LIST_FOREGROUND: xColor = COLOR_LIST_FOREGROUND; break; - case SWT.COLOR_LIST_BACKGROUND: xColor = COLOR_LIST_BACKGROUND; break; - case SWT.COLOR_LIST_SELECTION: xColor = COLOR_LIST_SELECTION; break; - case SWT.COLOR_LIST_SELECTION_TEXT: xColor = COLOR_LIST_SELECTION_TEXT; break; + case SWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK); + case SWT.COLOR_INFO_BACKGROUND: return Color.carbon_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1}); + case SWT.COLOR_TITLE_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorDocumentWindowTitleActive, (short)getDepth(), true, rgb); break; + case SWT.COLOR_TITLE_BACKGROUND: OS.GetThemeBrushAsColor((short)-5/*undocumented darker highlight color*/, (short)getDepth(), true, rgb); break; + case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: OS.GetThemeBrushAsColor((short)OS.kThemeBrushPrimaryHighlightColor, (short)getDepth(), true, rgb) ; break; + case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorDocumentWindowTitleInactive, (short)getDepth(), true, rgb); break; + case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushSecondaryHighlightColor, (short)getDepth(), true, rgb); break; + case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: OS.GetThemeBrushAsColor((short)OS.kThemeBrushSecondaryHighlightColor, (short)getDepth(), true, rgb); break; + case SWT.COLOR_WIDGET_DARK_SHADOW: return Color.carbon_new (this, new float [] {0x33 / 255f, 0x33 / 255f, 0x33 / 255f, 1}); + case SWT.COLOR_WIDGET_NORMAL_SHADOW: return Color.carbon_new (this, new float [] {0x66 / 255f, 0x66 / 255f, 0x66 / 255f, 1}); + case SWT.COLOR_WIDGET_LIGHT_SHADOW: return Color.carbon_new (this, new float [] {0x99 / 255f, 0x99 / 255f, 0x99 / 255f, 1}); + case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: return Color.carbon_new (this, new float [] {0xCC / 255f, 0xCC / 255f, 0xCC / 255f, 1}); + case SWT.COLOR_WIDGET_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushButtonFaceActive, (short)getDepth(), true, rgb); break; + case SWT.COLOR_WIDGET_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorPushButtonActive, (short)getDepth(), true, rgb); break; + case SWT.COLOR_WIDGET_BORDER: return super.getSystemColor (SWT.COLOR_BLACK); + case SWT.COLOR_LIST_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorListView, (short)getDepth(), true, rgb); break; + case SWT.COLOR_LIST_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushListViewBackground, (short)getDepth(), true, rgb); break; + case SWT.COLOR_LIST_SELECTION_TEXT: OS.GetThemeTextColor((short)OS.kThemeTextColorListView, (short)getDepth(), true, rgb); break; + case SWT.COLOR_LIST_SELECTION: OS.GetThemeBrushAsColor((short)OS.kThemeBrushPrimaryHighlightColor, (short)getDepth(), true, rgb); break; default: return super.getSystemColor (id); } - if (xColor == null) - System.out.println("Display.getSystemColor: color null " + id); - if (xColor == null) return super.getSystemColor (SWT.COLOR_BLACK); - //return Color.carbon_new (this, xColor); - return xColor; - // return getSystemColor(this, 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> - * </ul> - */ -public Font getSystemFont () { - checkDevice (); - return defaultFont; + float red = ((rgb.red >> 8) & 0xFF) / 255f; + float green = ((rgb.green >> 8) & 0xFF) / 255f; + float blue = ((rgb.blue >> 8) & 0xFF) / 255f; + return Color.carbon_new (this, new float[]{red, green, blue, 1}); } -/** - * Returns the user-interface thread for the receiver. - * - * @return the receiver's user-interface thread - */ + public Thread getThread () { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); return thread; } -void hideToolTip () { - if (toolTipWindowHandle != 0) { - OS.HideWindow(toolTipWindowHandle); - OS.DisposeWindow(toolTipWindowHandle); - toolTipWindowHandle = 0; - } + +int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) { + Widget widget = WidgetTable.get (inControl); + if (widget != null) return widget.helpProc (inControl, inGlobalMouse, inRequest, outContentProvided, ioHelpContent); + return OS.eventNotHandledErr; } + +int hitTestProc (int browser, int item, int property, int theRect, int mouseRect) { + Widget widget = WidgetTable.get (browser); + if (widget != null) return widget.hitTestProc (browser, item, property, theRect, mouseRect); + return OS.noErr; +} + protected void init () { super.init (); - - /* Create the callbacks */ - timerProc= createCallback("timerProc", 2); - caretProc= createCallback("caretProc", 2); - mouseHoverProc= createCallback("mouseHoverProc", 2); - - fWindowProc= createCallback("handleWindowCallback", 3); - fMouseProc= createCallback("handleMouseCallback", 3); - fControlActionProc= createCallback("handleControlAction", 2); - fUserPaneDrawProc= createCallback("handleUserPaneDraw", 2); - fUserPaneHitTestProc= createCallback("handleUserPaneHitTest", 2); - fUserPaneTrackingProc= createCallback("handleUserPaneTracking", 3); - fDataBrowserDataProc= createCallback("handleDataBrowserDataCallback", 5); - fDataBrowserCompareProc= createCallback("handleDataBrowserCompareCallback", 4); - fDataBrowserItemNotificationProc= createCallback("handleDataBrowserItemNotificationCallback", 3); - fMenuProc= createCallback("handleMenuCallback", 3); - - // create standard event handler - fApplicationProc= createCallback("handleApplicationCallback", 3); - int[] mask= new int[] { - OS.kEventClassCommand, OS.kEventProcessCommand, - - //OS.kEventClassAppleEvent, OS.kAEQuitApplication, - OS.kEventClassAppleEvent, OS.kEventAppleEvent, + initializeCallbacks (); + initializeInsets (); +} + +void initializeCallbacks () { + /* Create Callbacks */ + actionCallback = new Callback (this, "actionProc", 2); + actionProc = actionCallback.getAddress (); + if (actionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + caretCallback = new Callback(this, "caretProc", 2); + caretProc = caretCallback.getAddress(); + if (caretProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + commandCallback = new Callback (this, "commandProc", 3); + commandProc = commandCallback.getAddress (); + if (commandProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + controlCallback = new Callback (this, "controlProc", 3); + controlProc = controlCallback.getAddress (); + if (controlProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + drawItemCallback = new Callback (this, "drawItemProc", 7); + drawItemProc = drawItemCallback.getAddress (); + if (drawItemProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + itemDataCallback = new Callback (this, "itemDataProc", 5); + itemDataProc = itemDataCallback.getAddress (); + if (itemDataProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + itemNotificationCallback = new Callback (this, "itemNotificationProc", 3); + itemNotificationProc = itemNotificationCallback.getAddress (); + if (itemNotificationProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + helpCallback = new Callback (this, "helpProc", 5); + helpProc = helpCallback.getAddress (); + if (helpProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + hitTestCallback = new Callback (this, "hitTestProc", 5); + hitTestProc = hitTestCallback.getAddress (); + if (hitTestProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + keyboardCallback = new Callback (this, "keyboardProc", 3); + keyboardProc = keyboardCallback.getAddress (); + if (keyboardProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + menuCallback = new Callback (this, "menuProc", 3); + menuProc = menuCallback.getAddress (); + if (menuProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + mouseHoverCallback = new Callback (this, "mouseHoverProc", 2); + mouseHoverProc = mouseHoverCallback.getAddress (); + if (mouseHoverProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + mouseCallback = new Callback (this, "mouseProc", 3); + mouseProc = mouseCallback.getAddress (); + if (mouseProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + timerCallback = new Callback (this, "timerProc", 2); + timerProc = timerCallback.getAddress (); + if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + trackingCallback = new Callback (this, "trackingProc", 6); + trackingProc = trackingCallback.getAddress (); + if (trackingProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + windowCallback = new Callback (this, "windowProc", 3); + windowProc = windowCallback.getAddress (); + if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); - // we track down events here because we need to know when the user - // clicked in the menu bar + /* Install Event Handlers */ + int[] mask1 = new int[] { + OS.kEventClassCommand, OS.kEventProcessCommand, + }; + int appTarget = OS.GetApplicationEventTarget (); + OS.InstallEventHandler (appTarget, commandProc, mask1.length / 2, mask1, 0, null); + int[] mask2 = new int[] { OS.kEventClassMouse, OS.kEventMouseDown, - // we track up, dragged, and moved events because - // we need to get these events even if the mouse is outside of the window. OS.kEventClassMouse, OS.kEventMouseDragged, - OS.kEventClassMouse, OS.kEventMouseUp, +// OS.kEventClassMouse, OS.kEventMouseEntered, +// OS.kEventClassMouse, OS.kEventMouseExited, OS.kEventClassMouse, OS.kEventMouseMoved, - - SWT_USER_EVENT, 54321, - SWT_USER_EVENT, 54322, + OS.kEventClassMouse, OS.kEventMouseUp, + OS.kEventClassMouse, OS.kEventMouseWheelMoved, }; - if (OS.InstallEventHandler(OS.GetApplicationEventTarget(), fApplicationProc, mask, 0) != OS.kNoErr) - error (SWT.ERROR_NO_MORE_CALLBACKS); - - - int textInputProc= createCallback("handleTextCallback", 3); - mask= new int[] { + OS.InstallEventHandler (appTarget, mouseProc, mask2.length / 2, mask2, 0, null); + int [] mask3 = new int[] { OS.kEventClassKeyboard, OS.kEventRawKeyDown, + OS.kEventClassKeyboard, OS.kEventRawKeyModifiersChanged, OS.kEventClassKeyboard, OS.kEventRawKeyRepeat, OS.kEventClassKeyboard, OS.kEventRawKeyUp, }; - if (OS.InstallEventHandler(OS.GetUserFocusEventTarget(), textInputProc, mask, 0) != OS.kNoErr) - error (SWT.ERROR_NO_MORE_CALLBACKS); - - - buttonFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallSystemFont)); - buttonShadowThickness= 1; + int focusTarget = OS.GetUserFocusEventTarget (); + OS.InstallEventHandler (focusTarget, keyboardProc, mask3.length / 2, mask3, 0, null); +} - //scrolledInsetX = scrolledInsetY = 15; - scrolledMarginX= scrolledMarginY= 15; - compositeForeground = 0x000000; - compositeBackground = -1; // 0xEEEEEE; - - groupFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallEmphasizedSystemFont)); - - dialogForeground= 0x000000; - dialogBackground= 0xffffff; - - labelForeground = 0x000000; - labelBackground = -1; - labelFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallSystemFont)); - - listForeground = 0x000000; - listBackground = 0xffffff; - listSelect = listForeground; // if reversed colors - listFont= Font.carbon_new (this, new MacFont((short)1)); // Mac Appl Font - - scrollBarForeground = 0x000000; - scrollBarBackground = 0xffffff; - - textForeground = 0x000000; - textBackground = 0xffffff; - textHighlightThickness = 1; // ??? - textFont= Font.carbon_new (this, new MacFont((short)1)); // Mac Appl Font - - COLOR_WIDGET_DARK_SHADOW = Color.carbon_new(this, 0x333333, true); - COLOR_WIDGET_NORMAL_SHADOW = Color.carbon_new(this, 0x666666, true); - COLOR_WIDGET_LIGHT_SHADOW = Color.carbon_new(this, 0x999999, true); - COLOR_WIDGET_HIGHLIGHT_SHADOW = Color.carbon_new(this, 0xCCCCCC, true); - COLOR_WIDGET_BACKGROUND = Color.carbon_new(this, 0xFFFFFF, true); - COLOR_WIDGET_BORDER = Color.carbon_new(this, 0x000000, true); - COLOR_LIST_FOREGROUND = Color.carbon_new(this, 0x000000, true); - COLOR_LIST_BACKGROUND = Color.carbon_new(this, 0xFFFFFF, true); - COLOR_LIST_SELECTION = Color.carbon_new(this, 0x6666CC, true); - COLOR_LIST_SELECTION_TEXT = Color.carbon_new(this, 0xFFFFFF, true); - COLOR_INFO_BACKGROUND = Color.carbon_new(this, 0xFFFFE1, true); - - fHoverThemeFont= OS.kThemeSmallSystemFont; +void initializeInsets () { + int [] outControl = new int [1]; + Rect rect = new Rect (); + rect.right = rect.bottom = (short) 200; + + OS.CreatePushButtonControl (0, rect, 0, outControl); + buttonInset = computeInset (outControl [0]); + OS.DisposeControl (outControl [0]); + + OS.CreateTabsControl (0, rect, (short)OS.kControlTabSizeLarge, (short)OS.kControlTabDirectionNorth, (short) 0, 0, outControl); + tabFolderInset = computeInset (outControl [0]); + OS.DisposeControl (outControl [0]); + + CGRect cgRect = new CGRect (); + cgRect.width = cgRect.height = 200; + int inAttributes = OS.kHIComboBoxAutoCompletionAttribute | OS.kHIComboBoxAutoSizeListAttribute; + OS.HIComboBoxCreate (cgRect, 0, null, 0, inAttributes, outControl); + comboInset = computeInset (outControl [0]); + //FIXME - + comboInset.bottom = comboInset.top; + OS.DisposeControl (outControl [0]); +} - defaultFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallSystemFont)); - - defaultForeground = compositeForeground; - defaultBackground = compositeBackground; -} -/** - * Invokes platform specific functionality to allocate a new GC handle. - * <p> - * <b>IMPORTANT:</b> This method is <em>not</em> part of the public - * API for <code>Display</code>. It is marked public only so that it - * can be shared within the packages provided by SWT. It is not - * available on all platforms, and should never be called from - * application code. - * </p> - * - * @param data the platform specific GC data - * @return the platform specific GC handle - * - * @private - */ public int internal_new_GC (GCData data) { if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED); - /* AW - int xDrawable = OS.XDefaultRootWindow (xDisplay); - int xGC = OS.XCreateGC (xDisplay, xDrawable, 0, null); - if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES); - OS.XSetSubwindowMode (xDisplay, xGC, OS.IncludeInferiors); - if (data != null) { - data.device = this; - data.display = xDisplay; - data.drawable = xDrawable; - data.fontList = defaultFont; - data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay)); - } - return xGC; - */ - + // NEEDS WORK + int window = OS.FrontWindow (); + int port = OS.GetWindowPort (window); + int [] buffer = new int [1]; + OS.CreateCGContextForPort (port, buffer); + int context = buffer [0]; + if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES); if (data != null) { data.device = this; - /* AW - data.display = xDisplay; - data.drawable = xWindow; - data.foreground = argList [1]; - data.background = argList [3]; - data.fontList = fontList; - data.colormap = argList [5]; - */ - data.foreground = 0x000000; - data.background = 0xffffff; - data.font = new MacFont((short)1); - data.controlHandle = 0; + data.background = getSystemColor (SWT.COLOR_WHITE).handle; + data.foreground = getSystemColor (SWT.COLOR_BLACK).handle; + data.font = getSystemFont (); } - - int wHandle= OS.FrontWindow(); - int xGC= OS.GetWindowPort(wHandle); - if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); - - return xGC; -} -/** - * Invokes platform specific functionality to dispose a GC handle. - * <p> - * <b>IMPORTANT:</b> This method is <em>not</em> part of the public - * API for <code>Display</code>. It is marked public only so that it - * can be shared within the packages provided by SWT. It is not - * available on all platforms, and should never be called from - * application code. - * </p> - * - * @param handle the platform specific GC handle - * @param data the platform specific GC data - * - * @private - */ -public void internal_dispose_GC (int gc, GCData data) { + return context; } -boolean isValidThread () { - return thread == Thread.currentThread (); + +public void internal_dispose_GC (int context, GCData data) { + if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED); + // NEEDS WORK + OS.CGContextFlush (context); + OS.CGContextRelease (context); } + static boolean isValidClass (Class clazz) { String name = clazz.getName (); int index = name.lastIndexOf ('.'); return name.substring (0, index + 1).equals (PACKAGE_PREFIX); } -int mouseHoverProc (int id, int handle) { - if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID); - mouseHoverID = mouseHoverHandle = 0; - int rc= windowProc (handle, SWT.MouseHover, new MacMouseEvent()); - sendUserEvent(54321); - return rc; + +boolean isValidThread () { + return thread == Thread.currentThread (); +} + +int itemDataProc (int browser, int item, int property, int itemData, int setValue) { + Widget widget = WidgetTable.get (browser); + if (widget != null) return widget.itemDataProc (browser, item, property, itemData, setValue); + return OS.noErr; +} + +int itemNotificationProc (int browser, int item, int message) { + Widget widget = WidgetTable.get (browser); + if (widget != null) return widget.itemNotificationProc (browser, item, message); + return OS.noErr; } + +int keyboardProc (int nextHandler, int theEvent, int userData) { + Widget widget = WidgetTable.get (userData); + if (widget == null) { + int theWindow = OS.ActiveNonFloatingWindow (); + if (theWindow == 0) return OS.eventNotHandledErr; + int [] theControl = new int [1]; + OS.GetKeyboardFocus (theWindow, theControl); + if (theControl [0] == 0) { + OS.GetRootControl (theWindow, theControl); + } + widget = WidgetTable.get (theControl [0]); + } + if (widget != null) return widget.keyboardProc (nextHandler, theEvent, userData); + return OS.eventNotHandledErr; +} + void postEvent (Event event) { /* * Place the event at the end of the event queue. @@ -1077,60 +875,127 @@ void postEvent (Event event) { } eventQueue [index] = event; } -/** - * Reads an event from the operating system's event queue, - * dispatches it appropriately, and returns <code>true</code> - * if there is potentially more work to do, or <code>false</code> - * if the caller can sleep until another event is placed on - * the event queue. - * <p> - * In addition to checking the system event queue, this method also - * checks if any inter-thread messages (created by <code>syncExec()</code> - * or <code>asyncExec()</code>) are waiting to be processed, and if - * so handles them before returning. - * </p> - * - * @return <code>false</code> if the caller can sleep upon return from this method - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #sleep - * @see #wake - */ -public boolean readAndDispatch () { - checkDevice (); - - if (!fgInitCursorCalled) { - OS.InitCursor(); - fgInitCursorCalled= true; + +int menuProc (int nextHandler, int theEvent, int userData) { + if (userData != 0) { + Widget widget = WidgetTable.get (userData); + if (widget != null) return widget.menuProc (nextHandler, theEvent, userData); + } else { + int [] theMenu = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeMenuRef, null, 4, null, theMenu); + short menuID = OS.GetMenuID (theMenu [0]); + Menu menu = findMenu (menuID); + if (menu != null) return menu.menuProc (nextHandler, theEvent, userData); } + return OS.eventNotHandledErr; +} - int[] evt= new int[1]; - int rc= OS.ReceiveNextEvent(null, OS.kEventDurationNoWait, true, evt); - - switch (rc) { - case OS.kNoErr: - int event= evt[0]; - if (OS.GetEventClass(event) == SWT_USER_EVENT && OS.GetEventKind(event) == 54322) { - OS.ReleaseEvent(event); +int mouseProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point (); + OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, where.sizeof, null, where); + int [] theWindow = new int [1]; + int part = OS.FindWindow (where, theWindow); + switch (part) { + case OS.inMenuBar: { + if (eventKind == OS.kEventMouseDown) { + OS.MenuSelect (where); + return OS.noErr; + } break; } - OS.SendEventToEventTarget(event, OS.GetEventDispatcherTarget()); - OS.ReleaseEvent(event); - runDeferredEvents(); - return true; + case OS.inContent: { + Rect windowRect = new Rect (); + OS.GetWindowBounds (theWindow [0], (short) OS.kWindowContentRgn, windowRect); + CGPoint inPoint = new CGPoint (); + inPoint.x = where.h - windowRect.left; + inPoint.y = where.v - windowRect.top; + int [] theRoot = new int [1]; + OS.GetRootControl (theWindow [0], theRoot); + int [] theControl = new int [1]; + OS.HIViewGetSubviewHit (theRoot [0], inPoint, true, theControl); + if (theControl [0] == 0) theControl [0] = theRoot [0]; + Widget widget = WidgetTable.get (theControl [0]); + switch (eventKind) { + case OS.kEventMouseDragged: + case OS.kEventMouseMoved: { + org.eclipse.swt.internal.carbon.Point localPoint = new org.eclipse.swt.internal.carbon.Point (); + localPoint.h = (short) inPoint.x; + localPoint.v = (short) inPoint.y; + int [] modifiers = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers); + boolean [] cursorWasSet = new boolean [1]; + OS.HandleControlSetCursor (theControl [0], localPoint, (short) modifiers [0], cursorWasSet); + if (!cursorWasSet [0]) OS.SetThemeCursor (OS.kThemeArrowCursor); + if (widget != null) { + if (widget == hoverControl) { + int [] outDelay = new int [1]; + OS.HMGetTagDelay (outDelay); + if (mouseHoverID != 0) { + OS.SetEventLoopTimerNextFireTime (mouseHoverID, outDelay [0] / 1000.0); + } + } else { + //NOT DONE - get rid of instanceof test + if (widget instanceof Control) { + if (mouseHoverID != 0) OS.RemoveEventLoopTimer (mouseHoverID); + hoverControl = (Control) widget; + int [] id = new int [1], outDelay = new int [1]; + OS.HMGetTagDelay (outDelay); + int handle = hoverControl.handle; + int eventLoop = OS.GetCurrentEventLoop (); + OS.InstallEventLoopTimer (eventLoop, outDelay [0] / 1000.0, 0.0, mouseHoverProc, handle, id); + if ((mouseHoverID = id [0]) == 0) hoverControl = null; + } + } + } + } + } + if (widget != null) { + return userData != 0 ? widget.mouseProc (nextHandler, theEvent, userData) : OS.eventNotHandledErr; + } + break; + } + } + switch (eventKind) { + case OS.kEventMouseDragged: + case OS.kEventMouseMoved: + OS.InitCursor (); + } + if (mouseHoverID != 0) OS.RemoveEventLoopTimer (mouseHoverID); + mouseHoverID = 0; + hoverControl = null; + return OS.eventNotHandledErr; +} - case OS.eventLoopTimedOutErr: - break; +int mouseHoverProc (int id, int handle) { + if (hoverControl == null) return 0; + if (hoverControl.handle == handle && !hoverControl.isDisposed ()) { + //OPTIMIZE - use OS calls + int chord = OS.GetCurrentEventButtonState (); + int modifiers = OS.GetCurrentEventKeyModifiers (); + Point pt = hoverControl.toControl (getCursorLocation ()); + hoverControl.sendMouseEvent (SWT.MouseHover, (short)0, chord, (short)pt.x, (short)pt.y, modifiers); + } + hoverControl = null; + return 0; +} - default: - System.out.println("readAndDispatch: error " + rc); - break; +public boolean readAndDispatch () { + checkDevice (); + runEnterExit (); + int [] outEvent = new int [1]; + int status = OS.ReceiveNextEvent (0, null, OS.kEventDurationNoWait, true, outEvent); + if (status == OS.noErr) { + OS.SendEventToEventTarget (outEvent [0], OS.GetEventDispatcherTarget ()); + OS.ReleaseEvent (outEvent [0]); + runPopups (); + runDeferredEvents (); + runGrabs (); + return true; } return runAsyncMessages (); } + static synchronized void register (Display display) { for (int i=0; i<Displays.length; i++) { if (Displays [i] == null) { @@ -1143,6 +1008,7 @@ static synchronized void register (Display display) { newDisplays [Displays.length] = display; Displays = newDisplays; } + protected void release () { Shell [] shells = WidgetTable.shells (); for (int i=0; i<shells.length; i++) { @@ -1163,80 +1029,51 @@ protected void release () { releaseDisplay (); super.release (); } + void releaseDisplay () { - - /* Dispose the caret callback */ - /* AW - if (caretID != 0) OS.XtRemoveTimeOut (caretID); - */ - if (caretID != 0) OS.RemoveEventLoopTimer(caretID); - caretID = caretProc = 0; - - /* Dispose the timer callback */ - if (timerIDs != null) { - for (int i=0; i<timerIDs.length; i++) { - /* AW - if (timerIDs [i] != 0) OS.XtRemoveTimeOut (timerIDs [i]); - */ - if (timerIDs [i] != 0) OS.RemoveEventLoopTimer (timerIDs [i]); - } - } - timerIDs = null; - timerList = null; + actionCallback.dispose (); + caretCallback.dispose (); + commandCallback.dispose (); + controlCallback.dispose (); + drawItemCallback.dispose (); + itemDataCallback.dispose (); + itemNotificationCallback.dispose (); + helpCallback.dispose (); + hitTestCallback.dispose (); + keyboardCallback.dispose (); + menuCallback.dispose (); + mouseHoverCallback.dispose (); + mouseCallback.dispose (); + trackingCallback.dispose (); + windowCallback.dispose (); + actionCallback = caretCallback = commandCallback = null; + controlCallback = drawItemCallback = itemDataCallback = itemNotificationCallback = null; + helpCallback = hitTestCallback = keyboardCallback = menuCallback = null; + mouseHoverCallback = mouseCallback = trackingCallback = windowCallback = null; + actionProc = caretProc = commandProc = 0; + controlProc = drawItemProc = itemDataProc = itemNotificationProc = 0; + helpProc = hitTestProc = keyboardProc = menuProc = 0; + mouseHoverProc = mouseProc = trackingProc = windowProc = 0; + timerCallback.dispose (); + timerCallback = null; timerProc = 0; + grabControl = helpControl = currentControl = null; + if (helpString != 0) OS.CFRelease (helpString); + helpString = 0; + //NOT DONE - call terminate TXN if this is the last display + //NOTE: - display create and dispose needs to be synchronized on all platforms +// TXNTerminateTextension (); - /* Dispose the mouse hover callback */ - if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID); - mouseHoverID = mouseHoverProc = mouseHoverHandle = toolTipWindowHandle = 0; - - /* Free the font lists */ - /* AW - if (buttonFont != 0) OS.XmFontListFree (buttonFont); - if (labelFont != 0) OS.XmFontListFree (labelFont); - if (textFont != 0) OS.XmFontListFree (textFont); - if (listFont != 0) OS.XmFontListFree (listFont); - listFont = textFont = labelFont = buttonFont = 0; - */ - defaultFont = null; - - /* Release references */ - thread = null; - buttonBackground = buttonForeground = 0; - defaultBackground = defaultForeground = 0; - COLOR_WIDGET_DARK_SHADOW = COLOR_WIDGET_NORMAL_SHADOW = COLOR_WIDGET_LIGHT_SHADOW = - COLOR_WIDGET_HIGHLIGHT_SHADOW = COLOR_WIDGET_BACKGROUND = COLOR_WIDGET_BORDER = - COLOR_LIST_FOREGROUND = COLOR_LIST_BACKGROUND = COLOR_LIST_SELECTION = COLOR_LIST_SELECTION_TEXT = null; - COLOR_INFO_BACKGROUND = null; -} -void releaseToolTipHandle (int handle) { - if (mouseHoverHandle == handle) removeMouseHoverTimeOut (); - if (toolTipWindowHandle != 0) { - /* AW - int shellParent = OS.XtParent(toolTipWindowHandle); - if (handle == shellParent) toolTipWindowHandle = 0; - */ - } } -/** - * Removes the listener from the collection of listeners who will - * be notifed when an event of the given type occurs. - * - * @param eventType the type of event to listen for - * @param listener the listener which should no longer be notified when the event occurs - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see Listener - * @see #addListener - * - * @since 2.0 - */ +public void 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; +} + public void removeListener (int eventType, Listener listener) { checkDevice (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -1244,13 +1081,56 @@ public void removeListener (int eventType, Listener listener) { eventTable.unhook (eventType, listener); } -void removeMouseHoverTimeOut () { - if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID); - mouseHoverID = mouseHoverHandle = 0; +void removeMenu (Menu menu) { + if (menus == null) return; + menus [menu.id - ID_START] = null; +} + +void removeMenuItem (MenuItem item) { + if (items == null) return; + items [item.id - ID_START] = null; } + +void removePopup (Menu menu) { + if (popups == null) return; + for (int i=0; i<popups.length; i++) { + if (popups [i] == menu) { + popups [i] = null; + return; + } + } +} + boolean runAsyncMessages () { return synchronizer.runAsyncMessages (); } + +boolean runEnterExit () { + //OPTIMIZE - use OS calls, no garbage, widget already hit tested in mouse move + Point point = null; + int chord = 0, modifiers = 0; + Control control = getCursorControl (); + if (control != currentControl) { + if (currentControl != null && !currentControl.isDisposed ()) { + point = getCursorLocation (); + chord = OS.GetCurrentEventButtonState (); + modifiers = OS.GetCurrentEventKeyModifiers (); + Point pt = currentControl.toControl (point); + currentControl.sendMouseEvent (SWT.MouseExit, (short)0, chord, (short)pt.x, (short)pt.y, modifiers); + } + if ((currentControl = control) != null) { + if (point == null) { + point = getCursorLocation (); + chord = OS.GetCurrentEventButtonState (); + modifiers = OS.GetCurrentEventKeyModifiers (); + } + Point pt = currentControl.toControl (point); + currentControl.sendMouseEvent (SWT.MouseEnter, (short)0, chord, (short)pt.x, (short)pt.y, modifiers); + } + } + return point != null; +} + boolean runDeferredEvents () { /* * Run deferred events. This code is always @@ -1286,22 +1166,94 @@ boolean runDeferredEvents () { eventQueue = null; return true; } + +void runGrabs () { + if (grabControl == null) return; + Rect rect = new Rect (); + int [] outModifiers = new int [1]; + short [] outResult = new short [1]; + org.eclipse.swt.internal.carbon.Point outPt = new org.eclipse.swt.internal.carbon.Point (); + try { + while (grabControl != null && !grabControl.isDisposed () && outResult [0] != OS.kMouseTrackingMouseUp) { + lastModifiers = OS.GetCurrentEventKeyModifiers (); + int oldState = OS.GetCurrentEventButtonState (); + OS.TrackMouseLocationWithOptions (0, 0, OS.kEventDurationForever, outPt, outModifiers, outResult); + int type = 0, button = 0; + switch ((int)outResult [0]) { + case OS.kMouseTrackingMouseDown: { + type = SWT.MouseDown; + int newState = OS.GetCurrentEventButtonState (); + if ((oldState & 0x1) == 0 && (newState & 0x1) != 0) button = 1; + if ((oldState & 0x2) == 0 && (newState & 0x2) != 0) button = 2; + if ((oldState & 0x4) == 0 && (newState & 0x4) != 0) button = 3; + break; + } + case OS.kMouseTrackingMouseUp: { + type = SWT.MouseUp; + int newState = OS.GetCurrentEventButtonState (); + if ((oldState & 0x1) != 0 && (newState & 0x1) == 0) button = 1; + if ((oldState & 0x2) != 0 && (newState & 0x2) == 0) button = 2; + if ((oldState & 0x4) != 0 && (newState & 0x4) == 0) button = 3; + break; + } + case OS.kMouseTrackingMouseExited: type = SWT.MouseExit; break; + case OS.kMouseTrackingMouseEntered: type = SWT.MouseEnter; break; + case OS.kMouseTrackingMouseDragged: type = SWT.MouseMove; break; + case OS.kMouseTrackingMouseKeyModifiersChanged: break; + case OS.kMouseTrackingUserCancelled: break; + case OS.kMouseTrackingTimedOut: break; + case OS.kMouseTrackingMouseMoved: type = SWT.MouseMove; break; + } + if (type != 0) { + int handle = grabControl.handle; + int window = OS.GetControlOwner (handle); + OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect); + int x = outPt.h - rect.left; + int y = outPt.v - rect.top; + OS.GetControlBounds (handle, rect); + x -= rect.left; + y -= rect.top; + int chord = OS.GetCurrentEventButtonState (); + grabControl.sendMouseEvent (type, (short)button, chord, (short)x, (short)y, outModifiers [0]); + //TEMPORARY CODE + update (); + } + } + } finally { + grabControl = null; + } +} + +boolean runPopups () { + if (popups == null) return false; + grabControl = null; + boolean result = false; + while (popups != null) { + Menu menu = popups [0]; + if (menu == null) break; + int length = popups.length; + System.arraycopy (popups, 1, popups, 0, --length); + popups [length] = null; + menu._setVisible (true); + result = true; + } + popups = null; + return result; +} + void sendEvent (int eventType, Event event) { - if (eventTable == null) return; + if (eventTable == null && filterTable == null) { + return; + } if (event == null) event = new Event (); event.display = this; event.type = eventType; - if (event.time == 0) { - /* AW - if (OS.IsWinCE) { - event.time = OS.GetTickCount (); - } else { - event.time = OS.GetMessageTime (); - } - */ + if (event.time == 0) event.time = getLastEventTime (); + if (!filterEvent (event)) { + if (eventTable != null) eventTable.sendEvent (event); } - eventTable.sendEvent (event); } + /** * On platforms which support it, sets the application name * to be the argument. On Motif, for example, this can be used @@ -1310,7 +1262,20 @@ void sendEvent (int eventType, Event event) { * @param name the new app name */ public static void setAppName (String name) { - APP_NAME = name; +} + +void setCurrentCaret (Caret caret) { + if (caretID != 0) OS.RemoveEventLoopTimer (caretID); + caretID = 0; + currentCaret = caret; + if (currentCaret != null) { + int blinkRate = currentCaret.blinkRate; + int [] timerId = new int [1]; + double time = blinkRate / 1000.0; + int eventLoop = OS.GetCurrentEventLoop (); + OS.InstallEventLoopTimer (eventLoop, time, time, caretProc, 0, timerId); + caretID = timerId [0]; + } } /** @@ -1328,50 +1293,9 @@ public static void setAppName (String name) { public void setCursorLocation (Point point) { checkDevice (); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - /* AW - int x = point.x; - int y = point.y; - int xWindow = OS.XDefaultRootWindow (xDisplay); - OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, x, y); - */ - System.out.println("Display.setCursorLocation: nyi"); + /* Not possible on the MAC */ } -void setCurrentCaret (Caret caret) { - if (caretID != 0) OS.RemoveEventLoopTimer(caretID); - caretID = 0; - currentCaret = caret; - if (currentCaret != null) { - int blinkRate = currentCaret.blinkRate; - int[] timer= new int[1]; - OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), blinkRate / 1000.0, 0.0, caretProc, 0, timer); - caretID = timer[0]; - } -} -/** - * Sets the application defined property of the receiver - * with the specified name to the given argument. - * <p> - * Applications may have associated arbitrary objects with the - * receiver in this fashion. If the objects stored in the - * properties need to be notified when the display is disposed - * of, it is the application's responsibility provide a - * <code>disposeExec()</code> handler which does so. - * </p> - * - * @param key the name of the property - * @param value the new value for the property - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the key is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setData - * @see #disposeExec - */ public void setData (String key, Object value) { checkDevice (); if (key == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -1419,45 +1343,12 @@ public void setData (String key, Object 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 - when called from the wrong thread</li> - * </ul> - * - * @see #getData - * @see #disposeExec - */ + public void setData (Object data) { checkDevice (); this.data = data; } -/** - * Sets the synchronizer used by the display to be - * the argument, which can not be null. - * - * @param synchronizer the new synchronizer for the display (must not be null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setSynchronizer (Synchronizer synchronizer) { checkDevice (); if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -1466,143 +1357,68 @@ public void setSynchronizer (Synchronizer synchronizer) { } this.synchronizer = synchronizer; } -void setToolTipText (int handle, String toolTipText) { -/* AW - if (toolTipHandle == 0) return; - int shellHandle = OS.XtParent (toolTipHandle); - int shellParent = OS.XtParent (shellHandle); - if (handle != shellParent) return; -*/ - showToolTip (handle, toolTipText); -} -void showToolTip (int handle, String toolTipText) { - - if (toolTipText == null || toolTipText.length () == 0) { - if (toolTipWindowHandle != 0) - OS.HideWindow(toolTipWindowHandle); - return; - } - if (toolTipWindowHandle != 0) - return; - - if (handle != fCurrentControl) { - //System.out.println("Display.showToolTip: handle is not current"); - //beep(); - return; - } - if (fInContextMenu) { - //System.out.println("Display.showToolTip: menu is visible"); - //beep(); - return; - } - if (OS.StillDown()) { - //System.out.println("Display.showToolTip: button is down"); - //beep(); - return; - } - - toolTipText= MacUtil.removeMnemonics(toolTipText); - - // remember text - fToolTipText= toolTipText; - - // calculate text bounding box - short[] bounds= new short[2]; - short[] baseLine= new short[1]; - int sHandle= OS.CFStringCreateWithCharacters(toolTipText); - OS.GetThemeTextDimensions(sHandle, fHoverThemeFont, OS.kThemeStateActive, false, bounds, baseLine); - if (bounds[1] > 200) { // too wide -> wrap text - bounds[1]= (short) 200; - OS.GetThemeTextDimensions(sHandle, fHoverThemeFont, OS.kThemeStateActive, true, bounds, baseLine); +void setMenuBar (Menu menu) { + /* + * Feature in the Macintosh. SetRootMenu() does not + * accept NULL to indicate that their should be no + * menu bar. The fix is to create a temporary empty + * menu, set that to be the menu bar, clear the menu + * bar and then delete the temporary menu. + */ + if (menu == menuBar) return; + int theMenu = 0; + if (menu == null) { + int outMenuRef [] = new int [1]; + OS.CreateNewMenu ((short) ID_TEMPORARY, 0, outMenuRef); + theMenu = outMenuRef [0]; + } else { + theMenu = menu.handle; } - OS.CFRelease(sHandle); - int width= bounds[1] + 2*TOOLTIP_MARGIN; - int height= bounds[0] + 2*TOOLTIP_MARGIN; - - // position just below mouse cursor - MacPoint loc= new MacPoint(); - OS.GetGlobalMouse(loc.getData()); - int x= loc.getX() + 16; - int y= loc.getY() + 16; - - // Ensure that the tool tip is on the screen. - MacRect screenBounds= new MacRect(); - OS.GetAvailableWindowPositioningBounds(OS.GetMainDevice(), screenBounds.getData()); - x = Math.max (0, Math.min (x, screenBounds.getWidth() - width )); - y = Math.max (0, Math.min (y, screenBounds.getHeight() - height )); - - // create window - int[] wHandle= new int[1]; - if (OS.CreateNewWindow(OS.kHelpWindowClass, 0, new MacRect(x, y, width, height).getData(), wHandle) == OS.kNoErr) { - toolTipWindowHandle= wHandle[0]; - int[] mask= new int[] { - OS.kEventClassWindow, OS.kEventWindowDrawContent - }; - OS.InstallEventHandler(OS.GetWindowEventTarget(toolTipWindowHandle), fWindowProc, mask, toolTipWindowHandle); - OS.ShowWindow(toolTipWindowHandle); - fLastHoverHandle= handle; + OS.SetRootMenu (theMenu); + if (menu == null) { + OS.ClearMenuBar (); + OS.DeleteMenu (OS.GetMenuID (theMenu)); + OS.DisposeMenu (theMenu); } + menuBar = menu; } -/** - * Causes the user-interface thread to <em>sleep</em> (that is, - * to be put in a state where it does not consume CPU cycles) - * until an event is received or it is otherwise awakened. - * - * @return <code>true</code> if an event requiring dispatching was placed on the queue. - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #wake - */ + public boolean sleep () { checkDevice (); - return OS.ReceiveNextEvent(null, OS.kEventDurationForever, false, null) == OS.kNoErr; + //NOT DONE - timers shouldn't run here + return OS.ReceiveNextEvent (0, null, OS.kEventDurationForever, false, null) == OS.noErr; } -/** - * Causes the <code>run()</code> method of the runnable to - * be invoked by the user-interface thread at the next - * reasonable opportunity. The thread which calls this method - * is suspended until the runnable completes. - * - * @param runnable code to run on the user-interface thread. - * - * @exception SWTException <ul> - * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li> - * </ul> - * - * @see #asyncExec - */ + public void syncExec (Runnable runnable) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); synchronizer.syncExec (runnable); } -/** - * 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. - * - * @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> - * </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]; + if (timerIds == null) timerIds = new int [4]; int index = 0; while (index < timerList.length) { + if (timerList [index] == runnable) break; + index++; + } + if (index != timerList.length) { + int timerId = timerIds [index]; + if (milliseconds < 0) { + OS.RemoveEventLoopTimer (timerId); + timerList [index] = null; + timerIds [index] = 0; + } else { + OS.SetEventLoopTimerNextFireTime (timerId, milliseconds / 1000.0); + } + return; + } + if (milliseconds < 0) return; + index = 0; + while (index < timerList.length) { if (timerList [index] == null) break; index++; } @@ -1610,869 +1426,99 @@ public void timerExec (int milliseconds, Runnable runnable) { 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[] timer= new int[1]; - OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), milliseconds / 1000.0, 0.0, timerProc, index, timer); - int timerID = timer[0]; - - if (timerID != 0) { - timerIDs [index] = timerID; + int [] newTimerIds = new int [timerIds.length + 4]; + System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length); + timerIds = newTimerIds; + } + int [] timerId = new int [1]; + int eventLoop = OS.GetCurrentEventLoop (); + OS.InstallEventLoopTimer (eventLoop, milliseconds / 1000.0, 0.0, timerProc, index, timerId); + if (timerId [0] != 0) { + timerIds [index] = timerId [0]; timerList [index] = runnable; } } + int timerProc (int id, int index) { - if (id != 0) - OS.RemoveEventLoopTimer(id); if (timerList == null) return 0; if (0 <= index && index < timerList.length) { Runnable runnable = timerList [index]; timerList [index] = null; - timerIDs [index] = 0; + timerIds [index] = 0; if (runnable != null) runnable.run (); } return 0; } -static int translateKey (int key) { - for (int i=0; i<KeyTable.length; i++) { - if (KeyTable [i] [0] == key) return KeyTable [i] [1]; - } - return 0; -} -static int untranslateKey (int key) { - for (int i=0; i<KeyTable.length; i++) { - if (KeyTable [i] [1] == key) return KeyTable [i] [0]; - } - return 0; + +int trackingProc (int browser, int itemID, int property, int theRect, int startPt, int modifiers) { + Widget widget = WidgetTable.get (browser); + if (widget != null) return widget.trackingProc (browser, itemID, property, theRect, startPt, modifiers); + return OS.noErr; } -/** - * Forces all outstanding paint requests for the display - * to be processed before this method returns. - * - * @see Control#update - */ + public void update () { checkDevice (); - /* AW - XAnyEvent event = new XAnyEvent (); - int mask = OS.ExposureMask | OS.ResizeRedirectMask | - OS.StructureNotifyMask | OS.SubstructureNotifyMask | - OS.SubstructureRedirectMask; - OS.XSync (xDisplay, false); OS.XSync (xDisplay, false); - while (OS.XCheckMaskEvent (xDisplay, mask, event)) OS.XtDispatchEvent (event); - */ - int wHandle= 0; - int[] macEvent= new int[6]; - while (OS.GetNextEvent(OS.updateMask, macEvent)) { - if (macEvent[0] == OS.updateEvt) { - wHandle= macEvent[1]; - updateWindow(wHandle); - } - } - /* - if (wHandle != 0) { - int port= OS.GetWindowPort(wHandle); - if (port != 0) - OS.QDFlushPortBuffer(port, 0); - } - */ -} -/** - * If the receiver's user-interface thread was <code>sleep</code>'ing, - * causes it to be awakened and start running again. Note that this - * method may be called from any thread. - * - * @see #sleep - */ -public void wake () { - if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); - if (thread == Thread.currentThread ()) return; - /* Send a user event to wake up in ReceiveNextEvent */ - sendUserEvent(54322); -} -public int windowProc (int handle, int clientData) { - Widget widget = WidgetTable.get (handle); - if (widget == null) return 0; - return widget.processEvent (clientData); -} -public int windowProc (int handle, boolean callData) { - Widget widget = WidgetTable.get (handle); - if (widget == null) return 0; - return widget.processSetFocus (new Boolean(callData)); -} -public int windowProc (int handle, int clientData, int callData) { - Widget widget = WidgetTable.get (handle); - if (widget == null) return 0; - return widget.processResize (new Integer(callData)); -} -public int windowProc (int handle, int clientData, MacEvent callData) { - Widget widget = WidgetTable.get (handle); - if (widget == null) return 0; - return widget.processEvent (clientData, callData); -} -public int windowProc (int handle, int clientData, MacMouseEvent mme) { - Widget widget = WidgetTable.get (handle); - if (widget == null) return 0; - return widget.processEvent (clientData, mme); -} -public int windowProc (int handle, int clientData, MacControlEvent mce) { - Widget widget = WidgetTable.get (handle); - if (widget == null) return 0; - return widget.processEvent (clientData, mce); -} -static String convertToLf(String text) { - char Cr = '\r'; - char Lf = '\n'; - int length = text.length (); - if (length == 0) return text; - - /* Check for an LF or CR/LF. Assume the rest of the string - * is formatted that way. This will not work if the string - * contains mixed delimiters. */ - int i = text.indexOf (Lf, 0); - if (i == -1 || i == 0) return text; - if (text.charAt (i - 1) != Cr) 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 (Cr, i); - if (j == -1) j = length; - String s = text.substring (i, j); - result.append (s); - i = j + 2; - result.append (Lf); + int [] outEvent = new int [1]; + int [] mask = new int [] {OS.kEventClassWindow, OS.kEventWindowUpdate}; + while (OS.ReceiveNextEvent (mask.length / 2, mask, OS.kEventDurationNoWait, true, outEvent) == OS.noErr) { + OS.SendEventToEventTarget (outEvent [0], OS.GetEventDispatcherTarget ()); + OS.ReleaseEvent (outEvent [0]); } - return result.toString (); } -//////////////////////////////////////////////////////////////////////////// -// Some Mac helper functions -//////////////////////////////////////////////////////////////////////////// - - int nextMenuId() { - return fMenuId++; - } - - void flush (int cHandle) { - int wHandle= OS.GetControlOwner(cHandle); - if (wHandle != 0) { - int port= OS.GetWindowPort(wHandle); - if (port != 0) - OS.QDFlushPortBuffer(port, 0); - } - } - - //---- callbacks - - private int handleControlAction(int cHandle, int partCode) { - if (MacUtil.HIVIEW) - System.out.println("Display.handleControlAction: " + cHandle + " " + partCode); - return windowProc(cHandle, SWT.Selection, new MacControlEvent(cHandle, partCode, true)); - } - - private int handleUserPaneDraw(int cHandle, int partCode) { - int updateRgn= fUpdateRegion; - if (updateRgn == 0) { - updateRgn= OS.NewRgn(); - int wHandle= OS.GetControlOwner(cHandle); - OS.GetPortVisibleRegion(OS.GetWindowPort(wHandle), updateRgn); - } - int status= windowProc(cHandle, SWT.Paint, new MacControlEvent(cHandle, fUpdateRegion)); - if (updateRgn != fUpdateRegion && updateRgn != 0) - OS.DisposeRgn(updateRgn); - return status; - } - - private int handleUserPaneHitTest(int cHandle, int where) { - if (MacUtil.HIVIEW) - System.out.println("handleUserPaneHitTest"); - Widget w= WidgetTable.get(cHandle); - if (w instanceof Text || w instanceof Combo) - return 112; - return 111; - } - - private int handleUserPaneTracking(int cHandle, int where, int actionProc) { - - MacPoint pt= new MacPoint(OS.HiWord(where), OS.LoWord(where)); - short[] trackingResult= new short[1]; - - Widget widget = WidgetTable.get (cHandle); - if (widget == null) return 0; - - widget.processMouseDown(new MacMouseEvent(1, pt.toPoint())); - //System.out.println("V" + pt.toPoint()); - - /* - MacRect bounds= new MacRect(); - OS.GetControlBounds(cHandle, bounds.getData()); - int x= bounds.getX(); - int y= bounds.getY(); - System.out.println("Bounds" + bounds.toRectangle()); - */ - - while (true) { - OS.TrackMouseLocation(0, pt.getData(), trackingResult); - Point p= pt.toPoint(); - p.x-= 100; - p.y-= 100 - ; - switch (trackingResult[0]) { - case 5: // kMouseTrackingMouseDragged - widget.processMouseMove(new MacMouseEvent(1, p)); - //System.out.println("-" + p); - break; - case 2: // kMouseTrackingMouseUp - case 7: // kMouseTrackingUserCancelled - widget.processMouseUp(new MacMouseEvent(1, p)); - //System.out.println("A" + p); - return 0; - } - } - } - - private int handleDataBrowserDataCallback(int cHandle, int item, int property, int itemData, int setValue) { - Widget widget= WidgetTable.get(cHandle); - if (widget instanceof List) { - List list= (List) widget; - return list.handleItemCallback(item, property, itemData); - } - if (widget instanceof Tree2) { - Tree2 tree= (Tree2) widget; - return tree.handleItemCallback(item, property, itemData, setValue); - } - return OS.kNoErr; - } - - private int handleDataBrowserCompareCallback(int cHandle, int item1ID, int item2ID, int sortID) { - Widget widget= WidgetTable.get(cHandle); - if (widget instanceof List) { - List list= (List) widget; - return list.handleCompareCallback(item1ID, item2ID, sortID); - } - if (widget instanceof Tree2) { - Tree2 tree= (Tree2) widget; - return tree.handleCompareCallback(item1ID, item2ID, sortID); - } - return OS.kNoErr; - } - - private int handleDataBrowserItemNotificationCallback(int cHandle, int item, int message) { - Widget widget= WidgetTable.get(cHandle); - if (widget instanceof List) { - List list= (List) widget; - return list.handleItemNotificationCallback(item, message); - } - if (widget instanceof Tree2) { - Tree2 tree= (Tree2) widget; - return tree.handleItemNotificationCallback(item, message); - } -// if (message == 14) { // selection changed -// windowProc(cHandle, SWT.Selection, new MacControlEvent(cHandle, item, false)); -// } - return OS.kNoErr; - } - - private int handleMenuCallback(int nextHandler, int eHandle, int mHandle) { - switch (OS.GetEventKind(eHandle)) { - case OS.kEventMenuPopulate: - case OS.kEventMenuOpening: - - if (fInContextMenu) - OS.SetMenuFont(mHandle, (short)1024, (short)11); // AW: FIXME menu id - /* - // copy the menu's font - short[] fontID= new short[1]; - short[] size= new short[1]; - OS.GetMenuFont(hMenu, fontID, size); - OS.SetMenuFont(menu.handle, fontID[0], size[0]); - */ - - windowProc(mHandle, SWT.Show, new MacEvent(eHandle, nextHandler)); - break; - case OS.kEventMenuClosed: - windowProc(mHandle, SWT.Hide, new MacEvent(eHandle, nextHandler)); - break; - } - return OS.kNoErr; - } - - private int handleTextCallback(int nextHandler, int eRefHandle, int userData) { - - int eventClass= OS.GetEventClass(eRefHandle); - int eventKind= OS.GetEventKind(eRefHandle); - - switch (eventClass) { - - case OS.kEventClassTextInput: - switch (eventKind) { - case OS.kEventTextInputUnicodeForKeyEvent: - return OS.eventNotHandledErr; - default: - System.out.println("Display.handleTextCallback: kEventClassTextInput: unexpected event kind"); - break; - } - break; - - case OS.kEventClassKeyboard: - - // decide whether a SWT control has the focus - Control focus= getFocusControl(); - if (focus == null || focus.handle == 0) - return OS.eventNotHandledErr; - - int frontWindow= OS.FrontWindow(); - if (findWidget(frontWindow) == null) { - int w= OS.GetControlOwner(focus.handle); - if (w != OS.FrontWindow()) // its probably a standard dialog - return OS.eventNotHandledErr; - } - - switch (eventKind) { - case OS.kEventRawKeyDown: - if (MacEvent.getKeyCode(eRefHandle) == 122) { // help key f1 - windowProc(focus.handle, SWT.Help); - return OS.kNoErr; - } - // fall through! - case OS.kEventRawKeyRepeat: - return focus.processEvent(SWT.KeyDown, new MacEvent(eRefHandle, nextHandler)); - - case OS.kEventRawKeyUp: - return focus.processEvent(SWT.KeyUp, new MacEvent(eRefHandle, nextHandler)); - - default: - System.out.println("Display.handleTextCallback: kEventClassKeyboard: unexpected event kind"); - break; - } - break; - - default: - System.out.println("Display.handleTextCallback: unexpected event class"); - break; - } - return OS.eventNotHandledErr; - } - - private int handleMouseCallback(int nextHandler, int eRefHandle, int whichWindow) { - int eventClass= OS.GetEventClass(eRefHandle); - int eventKind= OS.GetEventKind(eRefHandle); - - switch (eventClass) { - - case OS.kEventClassMouse: - return handleMouseEvent(nextHandler, eRefHandle, eventKind, whichWindow); - - default: - System.out.println("handleMouseCallback: unexpected event class: " + MacUtil.toString(eventClass)); - break; - } - return OS.eventNotHandledErr; - } - - private int handleWindowCallback(int nextHandler, int eRefHandle, int whichWindow) { - - int eventClass= OS.GetEventClass(eRefHandle); - int eventKind= OS.GetEventKind(eRefHandle); - - switch (eventClass) { - - case OS.kEventClassMouse: - return handleMouseEvent(nextHandler, eRefHandle, eventKind, whichWindow); - - case OS.kEventClassWindow: - switch (eventKind) { - case OS.kEventWindowActivated: - Widget widget = WidgetTable.get(whichWindow); - if (widget instanceof Shell) - fMenuRootShell= (Shell) widget; - windowProc(whichWindow, true); - break; //return OS.kNoErr; - - case OS.kEventWindowDeactivated: - fMenuRootShell= null; - windowProc(whichWindow, false); - break; // return OS.kNoErr; - - case OS.kEventWindowBoundsChanged: - int[] attr= new int[1]; - OS.GetEventParameter(eRefHandle, OS.kEventParamAttributes, OS.typeUInt32, null, null, attr); - windowProc(whichWindow, SWT.Resize, attr[0]); - return OS.kNoErr; - - case OS.kEventWindowClose: - windowProc(whichWindow, SWT.Dispose); - return OS.kNoErr; - - case OS.kEventWindowDrawContent: - if (toolTipWindowHandle == whichWindow) { - processPaintToolTip(whichWindow); - } else { - if (MacUtil.HIVIEW) - break; - updateWindow2(whichWindow); - } - return OS.kNoErr; - - default: - System.out.println("handleWindowCallback: kEventClassWindow kind:" + eventKind); - break; - } - break; - - default: - System.out.println("handleWindowCallback: unexpected event class: " + MacUtil.toString(eventClass)); - break; - } - return OS.eventNotHandledErr; - } - - private int handleApplicationCallback(int nextHandler, int eRefHandle, int userData) { - - int eventClass= OS.GetEventClass(eRefHandle); - int eventKind= OS.GetEventKind(eRefHandle); - - switch (eventClass) { - - case OS.kEventClassAppleEvent: - - // check for 'quit' events - int[] aeclass= new int[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamAEEventClass, OS.typeType, null, null, aeclass) == OS.kNoErr) { - // System.out.println("kEventClassAppleEvent: " + MacUtil.toString(aeclass[0])); - int[] aetype= new int[1]; - if (OS.GetEventParameter(eRefHandle, OS.kEventParamAEEventID, OS.typeType, null, null, aetype) == OS.kNoErr) { - //System.out.println("kEventParamAEEventID: " + MacUtil.toString(aetype[0])); - if (aetype[0] == OS.kAEQuitApplication) - close(); - } - } - - OS.AEProcessAppleEvent(new MacEvent(eRefHandle).toOldMacEvent()); - break; - - case OS.kEventClassCommand: - - if (eventKind == OS.kEventProcessCommand) { - int[] rc= new int[4]; - OS.GetEventHICommand(eRefHandle, rc); - - if (rc[1] == OS.kAEQuitApplication) { - close(); - OS.HiliteMenu((short)0); // unhighlight what MenuSelect (or MenuKey) hilited - return OS.kNoErr; - } - - // try to map the MenuRef to a SWT Menu - Widget w= findWidget (rc[2]); - if (w instanceof Menu) { - Menu menu= (Menu) w; - menu.handleMenu(rc[3]); - OS.HiliteMenu((short)0); // unhighlight what MenuSelect (or MenuKey) hilited - return OS.kNoErr; - } - - - OS.HiliteMenu((short)0); // unhighlight what MenuSelect (or MenuKey) hilited - // we do not return kNoErr here so that the default handler - // takes care of special menus like the Combo menu. - } - break; - - case OS.kEventClassMouse: - switch (eventKind) { - - case OS.kEventMouseDown: - - fTrackedControl= 0; - - hideToolTip(); - - MacEvent mEvent= new MacEvent(eRefHandle); - MacPoint where= mEvent.getWhere(); - int[] w= new int[1]; - short part= OS.FindWindow(where.getData(), w); - - OS.QDGlobalToLocalPoint(OS.GetWindowPort(w[0]), where.getData()); - - if (part == OS.inMenuBar) { - OS.MenuSelect(mEvent.getWhere().getData()); - //doMenuCommand(OS.MenuSelect(mEvent.getWhere().getData())); - return OS.kNoErr; - } - break; - - case OS.kEventMouseDragged: - case OS.kEventMouseUp: - case OS.kEventMouseMoved: - return handleMouseEvent(nextHandler, eRefHandle, eventKind, 0); - } - break; - - case SWT_USER_EVENT: // SWT1 user event - //System.out.println("handleApplicationCallback: user event " + eventKind); - return OS.kNoErr; - - default: - System.out.println("handleApplicationCallback: unknown event class" + MacUtil.toString(eventClass)); - break; - } - return OS.eventNotHandledErr; - } - - private int handleMouseEvent(int nextHandler, int eRefHandle, int eventKind, int whichWindow) { - - if (MacUtil.HIVIEW) - return OS.eventNotHandledErr; - - if (eventKind == OS.kEventMouseDown) - fTrackedControl= 0; - - MacEvent me= new MacEvent(eRefHandle); - MacPoint where= me.getWhere(); - - short part= 0; - if (whichWindow == 0) { - if (fTrackedControl != 0) { - whichWindow= OS.GetControlOwner(fTrackedControl); - } else { - int[] w= new int[1]; - part= OS.FindWindow(where.getData(), w); - whichWindow= w[0]; - } - } else { - part= OS.FindWindow(where.getData(), new int[1]); - } - - if (whichWindow == 0 && eventKind == OS.kEventMouseDown) { - int[] wHandle= new int[1]; - int rc= OS.GetEventParameter(eRefHandle, OS.kEventParamWindowRef, OS.typeWindowRef, null, null, wHandle); - if (rc == OS.kNoErr) - whichWindow= wHandle[0]; - } - - if (whichWindow == 0) { - //System.out.println("Display.handleMouseEvent: whichWindow == 0"); - return OS.eventNotHandledErr; - } - - MacEvent.trackStateMask(eRefHandle, eventKind); - - switch (eventKind) { - - case OS.kEventMouseWheelMoved: - OS.QDGlobalToLocalPoint(OS.GetWindowPort(whichWindow), where.getData()); - int cntrl= MacUtil.findControlUnderMouse(where, whichWindow, null); - Widget ww= findWidget(cntrl); - if (ww instanceof Composite) { - Composite s= (Composite) ww; - ScrollBar sb= s.getVerticalBar(); - if (sb != null) - return sb.processWheel(eRefHandle); - } - break; - - case OS.kEventMouseDown: - - if (!OS.IsWindowActive(whichWindow)) { - // let the default handler activate the window - return OS.eventNotHandledErr; - } - - hideToolTip (); - - if (part == OS.inContent || (MacUtil.HIVIEW && part == OS.inStructure)) - if (false && MacUtil.HIVIEW) { - return OS.eventNotHandledErr; - } else { - if (!handleContentClick(me, whichWindow)) - return OS.kNoErr; - } - - break; - - case OS.kEventMouseDragged: - if (fTrackedControl != 0) { - windowProc(fTrackedControl, SWT.MouseMove, new MacMouseEvent(me)); - return OS.kNoErr; - } - break; +void updateMenuBar () { + updateMenuBar (getActiveShell ()); +} - case OS.kEventMouseUp: - if (fTrackedControl != 0) { - windowProc(fTrackedControl, SWT.MouseUp, new MacMouseEvent(me)); - fTrackedControl= 0; - return OS.kNoErr; - } - break; - - case OS.kEventMouseMoved: - - fTrackedControl= 0; - - OS.QDGlobalToLocalPoint(OS.GetWindowPort(whichWindow), where.getData()); - int whichControl= MacUtil.findControlUnderMouse(where, whichWindow, null); - - if (fCurrentControl != whichControl) { - - if (fCurrentControl != 0) { - fLastHoverHandle= 0; - windowProc(fCurrentControl, SWT.MouseExit, new MacMouseEvent(me)); - } - - fCurrentControl= whichControl; - - Widget w= findWidget(fCurrentControl); - if (w instanceof Control) { - Control c= (Control) w; - if (c.cursor != null) - c.cursor.install(this); - else - setCursor(0); - } else - setCursor(0); - - windowProc(fCurrentControl, SWT.MouseMove, new MacMouseEvent(me)); - - if (fCurrentControl != 0) { - windowProc(fCurrentControl, SWT.MouseEnter, new MacMouseEvent(me)); - } - return OS.kNoErr; - } else { - if (fCurrentControl != 0) { - windowProc(fCurrentControl, SWT.MouseMove, new MacMouseEvent(me)); - return OS.kNoErr; - } - } - break; - } - - return OS.eventNotHandledErr; +void updateMenuBar (Shell shell) { + if (shell == null) shell = getActiveShell (); + boolean modal = false; + int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; + while (shell != null) { + if (shell.menuBar != null) break; + if ((shell.style & mask) != 0) modal = true; + shell = (Shell) shell.parent; } - - boolean setMacFocusHandle(int wHandle, int focusHandle) { - - if (fFocusControl != focusHandle) { - int oldFocus= fFocusControl; - fFocusControl= focusHandle; - - if (oldFocus != 0) - windowProc(oldFocus, false); - - - if (wHandle != 0) { - int[] focusControl= new int[1]; - OS.GetKeyboardFocus(wHandle, focusControl); - if (focusControl[0] != fFocusControl) { - OS.SetKeyboardFocus(wHandle, focusHandle, (short)-1); - //if (rc != OS.kNoErr) - // System.out.println("Display.setMacFocusHandle: SetKeyboardFocus " + rc); - } - } - - if (fFocusControl != 0) - windowProc(fFocusControl, true); + /* + * Feature in the Macintosh. For some reason, when a modal shell + * is active, DisableMenuItem() when called with zero (indicating + * that the entire menu is to be disabled) will not disable the + * current menu bar. The fix is to disable each individual menu + * item. + */ + if (menuBar != null) { + MenuItem [] items = menuBar.getItems (); + for (int i=0; i<items.length; i++) { + if (items [i].getEnabled ()) items [i]._setEnabled (true); } - return true; } - - private boolean handleContentClick(MacEvent me, int whichWindow) { - - MacPoint where= me.getWhere(); - MacPoint globalPos= me.getWhere(); - - OS.QDGlobalToLocalPoint(OS.GetWindowPort(whichWindow), where.getData()); - - short[] cpart= new short[1]; - int whichControl= 0; - if (MacUtil.HIVIEW) { - int[] ov= new int[1]; - int root= OS.HIViewGetRoot(whichWindow); - OS.HIViewGetViewForMouseEvent(root, me.getEventRef(), ov); - whichControl= ov[0]; - } else { - whichControl= MacUtil.findControlUnderMouse(where, whichWindow, cpart); - } - - // focus change - setMacFocusHandle(whichWindow, whichControl); - - if (whichControl != 0) { - - // deal with the context menu - Widget wc= WidgetTable.get(whichControl); - if (wc instanceof Control) { - Menu cm= ((Control)wc).getMenu(); // is a context menu installed? - if (cm != null && me.isShowContextualMenuClick()) { - try { - fInContextMenu= true; - // AW: not ready for primetime - // OS.ContextualMenuSelect(cm.handle, globalPos.getData(), new short[1], new short[1]); - OS.PopUpMenuSelect(cm.handle, (short)globalPos.getY(), (short)globalPos.getX(), (short)1); - } finally { - fInContextMenu= false; - } - return false; - } - } - - if (MacUtil.HIVIEW) { - OS.HIViewClick(whichControl, me.getEventRef()); - return false; - } - - switch (cpart[0]) { - case 0: - break; - - case 111: // User pane - fTrackedControl= whichControl; // starts mouse tracking - windowProc(whichControl, SWT.MouseDown, new MacMouseEvent(me)); - break; - - case 112: // User pane - windowProc(whichControl, SWT.MouseDown, new MacMouseEvent(me)); - break; - - default: - windowProc(whichControl, SWT.MouseDown, new MacMouseEvent(me)); - - if (MacUtil.HIVIEW) { - // AW: Jaguar: - OS.HIViewClick(whichControl, me.getEventRef()); - } else { - int cpart2= OS.HandleControlClick(whichControl, where.getData(), me.getModifiers(), -1); - if (cpart2 != 0) { - windowProc(whichControl, SWT.Selection, new MacControlEvent(whichControl, cpart2, false)); - } - } - break; - } - } - return false; + setMenuBar (shell != null ? shell.menuBar : null); + if (menuBar != null && modal) { + int theMenu = menuBar.handle; + MenuItem [] items = menuBar.getItems (); + for (int i=0; i<items.length; i++) items [i]._setEnabled (false); } - - public void updateWindow(int whichWindow) { - - int curPort= OS.GetPort(); - OS.SetPortWindowPort(whichWindow); - OS.BeginUpdate(whichWindow); - - updateWindow2(whichWindow); +} - OS.EndUpdate(whichWindow); - OS.SetPort(curPort); - } +public void wake () { + if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); + if (thread == Thread.currentThread ()) return; + int [] event = new int [1]; + OS.CreateEvent (0, 0, 0, 0.0, OS.kEventAttributeUserEvent, event); + OS.PostEventToQueue (queue, event [0], (short) OS.kEventPriorityStandard); +} - public void updateWindow2(int whichWindow) { - if (toolTipWindowHandle == whichWindow) { - processPaintToolTip(whichWindow); - } else { - fUpdateRegion= OS.NewRgn(); - OS.GetPortVisibleRegion(OS.GetWindowPort(whichWindow), fUpdateRegion); - - OS.EraseRgn(fUpdateRegion); - OS.UpdateControls(whichWindow, fUpdateRegion); - - OS.DisposeRgn(fUpdateRegion); - fUpdateRegion= 0; - } - } - - /* - static void processAllUpdateEvents2(int cHandle) { - - if (true) { - int[] macEvent= new int[6]; - while (OS.GetNextEvent(OS.updateMask, macEvent)) - if (macEvent[0] == OS.updateEvt) - getDefault().updateWindow(macEvent[1]); - } else { - int[] mask= new int[] { - OS.kEventClassWindow, OS.kEventWindowDrawContent - }; - int[] evt= new int[1]; - while (OS.ReceiveNextEvent(mask, 0.01, true, evt) == OS.kNoErr) { - //System.out.println("got update"); - int rc= OS.SendEventToEventTarget(evt[0], OS.GetEventDispatcherTarget()); - if (rc != OS.kNoErr) - System.out.println("processAllUpdateEvents: " + rc); - OS.ReleaseEvent(evt[0]); - } - } +int windowProc (int nextHandler, int theEvent, int userData) { + Widget widget = WidgetTable.get (userData); + if (widget == null) { + int [] theWindow = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeWindowRef, null, 4, null, theWindow); + int [] theRoot = new int [1]; + OS.GetRootControl (theWindow [0], theRoot); + widget = WidgetTable.get (theRoot [0]); + } + if (widget != null) return widget.windowProc (nextHandler, theEvent, userData); + return OS.eventNotHandledErr; +} - int wHandle= OS.GetControlOwner(cHandle); - if (wHandle != 0) { - int port= OS.GetWindowPort(wHandle); - if (port != 0) { - OS.QDFlushPortBuffer(port, 0); - //System.out.println("QDFlushPortBuffer"); - } - } - } - */ - - private void processPaintToolTip(int wHandle) { - - Color infoForeground = getSystemColor (SWT.COLOR_INFO_FOREGROUND); - Color infoBackground = getSystemColor (SWT.COLOR_INFO_BACKGROUND); - MacUtil.RGBBackColor(infoBackground.handle); - MacUtil.RGBForeColor(infoForeground.handle); - - MacRect bounds= new MacRect(); - OS.GetWindowBounds(wHandle, OS.kWindowContentRgn, bounds.getData()); - - bounds= new MacRect(0, 0, bounds.getWidth(), bounds.getHeight()); - - OS.EraseRect(bounds.getData()); - - if (fToolTipText != null) { - int sHandle= OS.CFStringCreateWithCharacters(fToolTipText); - bounds= new MacRect(TOOLTIP_MARGIN, TOOLTIP_MARGIN, - bounds.getWidth()-2*TOOLTIP_MARGIN, bounds.getHeight()-2*TOOLTIP_MARGIN); - OS.DrawThemeTextBox(sHandle, fHoverThemeFont, OS.kThemeStateActive, true, bounds.getData(), (short)0, 0); - OS.CFRelease(sHandle); - } - } - - private void sendUserEvent(int kind) { - int[] event= new int[1]; - OS.CreateEvent(0, SWT_USER_EVENT, kind, 0.0, OS.kEventAttributeUserEvent, event); - if (event[0] != 0) - OS.PostEventToQueue(OS.GetMainEventQueue(), event[0], (short)2); - } - - public static MacFont getThemeFont(short themeFontId) { - byte[] fontName= new byte[256]; - short[] fontSize= new short[1]; - byte[] style= new byte[1]; - OS.GetThemeFont(themeFontId, OS.smSystemScript, fontName, fontSize, style); - return new MacFont(MacUtil.toString(fontName), fontSize[0], style[0]); - } - - public void setCursor(int cursor) { - if (fCurrentCursor != cursor) { - fCurrentCursor= cursor; - if (cursor == 0) - OS.InitCursor(); - else - OS.SetCursor(cursor); - } - } - - private int createCallback(String method, int argCount) { - Callback cb= new Callback(this, method, argCount); - if (fCallbacks == null) - fCallbacks= new ArrayList(); - fCallbacks.add(cb); - int proc= cb.getAddress(); - if (proc == 0) - error (SWT.ERROR_NO_MORE_CALLBACKS); - return proc; - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FileDialog.java index 400b1f04e7..5d618946b9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FileDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FileDialog.java @@ -7,324 +7,195 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.*; +import org.eclipse.swt.internal.carbon.*; -/** - * Instances of this class allow the user to navigate - * the file system and select or enter a file name. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>SAVE, OPEN, MULTI</dd> - * <dt><b>Events:</b></dt> - * <dd>(none)</dd> - * </dl> - * <p> - * IMPORTANT: This class is intended to be subclassed <em>only</em> - * within the SWT implementation. - * </p> - */ -public /*final*/ class FileDialog extends Dialog { +public class FileDialog extends Dialog { String [] filterNames = new String [0]; String [] filterExtensions = new String [0]; - String filterPath = ""; - String [] fileNames = new String[] { "" }; - static final String FILTER = "*"; + String [] fileNames = new String[0]; + String filterPath = "", fileName = ""; -/** - * Constructs a new instance of this class given only its - * parent. - * <p> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ public FileDialog (Shell parent) { - this (parent, SWT.PRIMARY_MODAL); + 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> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ public FileDialog (Shell parent, int style) { super (parent, style); + checkSubclass (); } -/** - * Returns the path of the first file that was - * selected in the dialog relative to the filter path, - * or empty string if the dialog was cancelled. - * - * @return the relative path of the file - */ public String getFileName () { - if (fileNames.length > 0) - return fileNames[0]; - return ""; + return fileName; } -/** - * Returns the paths of all files that were selected - * in the dialog relative to the filter path, or null - * if none are available. - * - * @return the relative paths of the files - */ public String [] getFileNames () { return fileNames; } -/** - * Returns the file extensions which the dialog will - * use to filter the files it shows. - * - * @return the file extensions filter - */ public String [] getFilterExtensions () { return filterExtensions; } -/** - * Returns the file names which the dialog will - * use to filter the files it shows. - * - * @return the file name filter - */ public String [] getFilterNames () { return filterNames; } -/** - * Returns the path which the dialog will use to filter - * the directories it shows. - * - * @return the filter path - */ + public String getFilterPath () { return filterPath; } -private String interpretOsAnswer(int dialog) { - String separator = System.getProperty ("file.separator"); - - String firstResult= null; - int[] tmp= new int[1]; - OS.NavDialogGetReply(dialog, tmp); - int reply= tmp[0]; - - int selection= OS.NavReplyRecordGetSelection(reply); - OS.AECountItems(selection, tmp); - int count= tmp[0]; - - String commonPath= null; - if (count > 0) { - String fileName= null; - fileNames= new String[count]; - for (int i= 0; i < count; i++) { - OS.AEGetNthPtr(selection, i+1, tmp); - String fullPath= MacUtil.getStringAndRelease(tmp[0]); - if (firstResult == null) - firstResult= fullPath; - if (fullPath != null && fullPath.length() > 0) { - int separatorIndex= fullPath.lastIndexOf(separator); - if (separatorIndex >= 0) { - fileName= fullPath.substring(separatorIndex+separator.length()); - String fp= fullPath.substring(0, separatorIndex); - if (commonPath == null) - commonPath= fp; // remember common filterPath - else { - if (!commonPath.equals(fp)) // verify that filterPath is in fact common - System.out.println("FileDialog.getPaths: mismatch in filterPaths"); - } - } else { - fileName= fullPath; - } - fileNames[i]= fileName; - } - } - } else { - fileNames= null; - } - - if (commonPath != null) - filterPath= commonPath; - else - filterPath= ""; - - OS.NavDialogDisposeReply(reply); - - return firstResult; -} -/** - * 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 dialog= 0; - String result= null; - - int titleHandle= 0; - try { - int parentWindowHandle= 0; - if (parent != null) - parentWindowHandle= parent.shellHandle; - - titleHandle= OS.CFStringCreateWithCharacters(title); - - int status= 0; - int flags= 0; - int[] dialogHandle= new int[1]; - - if ((style & SWT.SAVE) != 0) { - status= OS.NavCreatePutFileDialog(flags, titleHandle, parentWindowHandle, dialogHandle, - MacUtil.OSType("TEXT"), MacUtil.OSType("KAHL")); - } else /* if ((style & SWT.OPEN) != 0) */ { - if ((style & SWT.MULTI) != 0) - flags |= OS.kNavAllowMultipleFiles; - status= OS.NavCreateGetFileDialog(flags, titleHandle, parentWindowHandle, dialogHandle); - } + String fullPath = null; + fileNames = null; - if (status == 0) { - dialog= dialogHandle[0]; - } else { - //System.out.println("FileDialog.open: status " + status); - } - - if (dialog != 0) { - //System.out.println("FileDialog.open: got dialog"); - - if ((style & SWT.SAVE) != 0) { - int fileNameHandle= 0; - try { - fileNameHandle= OS.CFStringCreateWithCharacters(fileNames[0]); - OS.NavDialogSetSaveFileName(dialog, fileNameHandle); - } finally { - if (fileNameHandle != 0) - OS.CFRelease(fileNameHandle); - } - } - - //System.out.println("FileDialog.open: vor run"); - OS.NavDialogRun(dialog); - //System.out.println("FileDialog.open: nach run"); + int titlePtr = 0; + if (title != null) { + char [] buffer = new char [title.length ()]; + title.getChars (0, buffer.length, buffer, 0); + titlePtr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + } + int fileNamePtr = 0; + if (fileName != null) { + char [] buffer = new char [fileName.length ()]; + fileName.getChars (0, buffer.length, buffer, 0); + fileNamePtr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + } - int action= OS.NavDialogGetUserAction(dialog); - switch (action) { - case OS.kNavUserActionCancel: - break; - + NavDialogCreationOptions options = new NavDialogCreationOptions (); + options.windowTitle = options.clientName = titlePtr; + options.parentWindow = OS.GetControlOwner (parent.handle); + options.optionFlags = OS.kNavSupportPackages | OS.kNavAllowOpenPackages | OS.kNavAllowInvisibleFiles; + options.location_h = -1; + options.location_v = -1; + options.saveFileName = fileNamePtr; + + int [] outDialog = new int [1]; + if ((style & SWT.SAVE) != 0) { + // NEEDS WORK - filter extensions, start in filter path, allow user + // to select existing files. + OS.NavCreatePutFileDialog (options, 0, 0, 0, 0, outDialog); + } else { + if ((style & SWT.MULTI) != 0) options.optionFlags |= OS.kNavAllowMultipleFiles; + // NEEDS WORK - filter extensions, start in filter path, select file name if it exists + OS.NavCreateGetFileDialog(options, 0, 0, 0, 0, 0, outDialog); + } + if (outDialog [0] != 0) { + OS.NavDialogRun (outDialog [0]); + int action = OS.NavDialogGetUserAction (outDialog [0]); + switch (action) { case OS.kNavUserActionOpen: - case OS.kNavUserActionChoose: - result= interpretOsAnswer(dialog); - break; - - case OS.kNavUserActionSaveAs: - result= MacUtil.getStringAndRelease(OS.NavDialogGetSaveFileName(dialog)); - break; + case OS.kNavUserActionChoose: + case OS.kNavUserActionSaveAs: { + NavReplyRecord record = new NavReplyRecord (); + OS.NavDialogGetReply (outDialog [0], record); + AEDesc selection = new AEDesc (); + selection.descriptorType = record.selection_descriptorType; + selection.dataHandle = record.selection_dataHandle; + int [] count = new int [1]; + OS.AECountItems (selection, count); + if (count [0] > 0) { + fileNames = new String [count [0]]; + int maximumSize = 80; // size of FSRef + int dataPtr = OS.NewPtr (maximumSize); + int[] aeKeyword = new int [1]; + int[] typeCode = new int [1]; + int[] actualSize = new int [1]; + int pathString = 0; + int fullString = 0; + int fileString = 0; + + if ((style & SWT.SAVE) != 0) { + if (OS.AEGetNthPtr (selection, 1, OS.typeFSRef, aeKeyword, typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) { + byte[] fsRef = new byte[actualSize[0]]; + OS.memcpy (fsRef, dataPtr, actualSize [0]); + int pathUrl = OS.CFURLCreateFromFSRef (OS.kCFAllocatorDefault, fsRef); + int fullUrl = OS.CFURLCreateCopyAppendingPathComponent(OS.kCFAllocatorDefault, pathUrl, record.saveFileName, false); + pathString = OS.CFURLCopyFileSystemPath(pathUrl, OS.kCFURLPOSIXPathStyle); + fullString = OS.CFURLCopyFileSystemPath(fullUrl, OS.kCFURLPOSIXPathStyle); + fileString = record.saveFileName; + OS.CFRelease (pathUrl); + OS.CFRelease (fullUrl); + } + } else { + for (int i = 0; i < count [0]; i++) { + if (OS.AEGetNthPtr (selection, i+1, OS.typeFSRef, aeKeyword, typeCode, dataPtr, maximumSize, actualSize) == OS.noErr) { + byte[] fsRef = new byte[actualSize[0]]; + OS.memcpy (fsRef, dataPtr, actualSize [0]); + int url = OS.CFURLCreateFromFSRef (OS.kCFAllocatorDefault, fsRef); + if (i == 0) { + int pathUrl = OS.CFURLCreateCopyDeletingLastPathComponent(OS.kCFAllocatorDefault, url); + pathString = OS.CFURLCopyFileSystemPath (pathUrl, OS.kCFURLPOSIXPathStyle); + fullString = OS.CFURLCopyFileSystemPath (url, OS.kCFURLPOSIXPathStyle); + fileString = OS.CFURLCopyLastPathComponent (url); + OS.CFRelease (pathUrl); + } else { + int lastString = OS.CFURLCopyLastPathComponent (url); + int length = OS.CFStringGetLength (lastString); + char [] buffer= new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (lastString, range, buffer); + fileNames [i] = new String (buffer); + OS.CFRelease (lastString); + } + OS.CFRelease (url); + } + } + } + OS.DisposePtr (dataPtr); + + if (pathString != 0) { + int length = OS.CFStringGetLength (pathString); + char [] buffer= new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (pathString, range, buffer); + OS.CFRelease (pathString); + filterPath = new String (buffer); + } + if (fullString != 0) { + int length = OS.CFStringGetLength (fullString); + char [] buffer= new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (fullString, range, buffer); + OS.CFRelease (fullString); + fullPath = new String (buffer); + } + if (fileString != 0) { + int length = OS.CFStringGetLength (fileString); + char [] buffer= new char [length]; + CFRange range = new CFRange (); + range.length = length; + OS.CFStringGetCharacters (fileString, range, buffer); + OS.CFRelease (fileString); + fileName = fileNames [0] = new String (buffer); + } + } } - } else { - //System.out.println("FileDialog.open: dialog == null"); } - - } finally { - if (titleHandle != 0) - OS.CFRelease(titleHandle); - if (dialog != 0) - OS.NavDialogDispose(dialog); } - - return result; + + if (titlePtr != 0) OS.CFRelease (titlePtr); + if (fileNamePtr != 0) OS.CFRelease (fileNamePtr); + if (outDialog [0] != 0) OS.NavDialogDispose (outDialog [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) { - fileNames = new String[] { string }; + fileName = string; } -/** - * Set the file extensions which the dialog will - * use to filter the files it shows to the argument, - * which may be null. - * - * @param extensions the file extension filter - */ public void setFilterExtensions (String [] extensions) { filterExtensions = extensions; } -/** - * Sets the file names which the dialog will - * use to filter the files it shows to the argument, - * which may be null. - * - * @param names the file name filter - */ public void setFilterNames (String [] names) { filterNames = names; } -/** - * Sets the path which the dialog will use to filter - * the directories it shows to the argument, which may be - * null. - * - * @param string the filter path - */ + public void setFilterPath (String string) { filterPath = string; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java index ae8c91cdfd..11ff317226 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java @@ -9,935 +9,137 @@ package org.eclipse.swt.widgets; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.FontSelectionQDStyle; +import org.eclipse.swt.internal.Callback; +import org.eclipse.swt.internal.carbon.RGBColor; -import java.util.*; - -/** - * Instances of this class allow the user to select a font - * from all available fonts in the system. - * <p> - * IMPORTANT: This class is intended to be subclassed <em>only</em> - * within the SWT implementation. - * </p> - */ public class FontDialog extends Dialog { - /* - * Table containing all available fonts as FontData objects. - * The table is structured as a series of embedded Hashtables as follows: - * <br>characterRegistryName -> faceName -> extendedStyle -> size -> style - */ - private Hashtable characterSets = new Hashtable (); - private FontData initialFontData; - private Font sampleFont; // the current displayed sample font - private boolean okSelected = false; - private boolean ignoreEvents = false; - - // widgets - private Shell shell; - private Combo charSetCombo; - private Combo faceNameCombo; - private Combo fontSizeCombo; - private Combo fontStyleCombo; - private Combo extStyleCombo; - private Label sampleLabel; - private Button okButton; - private Button cancelButton; - - // constants - private static final String TEXT_SAMPLE = "AaBbYyZz"; - private static final String SCALABLE_SIZES[] = new String[] {"8", "10", "11", "12", "14", "16", "18", "22", "24", "26"}; - private static final int DEFAULT_SIZE = 14; - private static final String DEFAULT_STYLE = "medium"; - private static final Integer SCALABLE_KEY = new Integer (0); - private static final Integer NO_SELECTION = new Integer (-1); - private static final int COLUMN1_WIDTH = 200; - private static final int COLUMN2_WIDTH = 150; - private static final int COLUMN3_WIDTH = 100; - private static final String PREFIX_ISO8859 = "iso8859"; - private static final String PREFIX_ISO646 = "iso646"; - private static final String PREFIX_UNICODE = "ucs"; - private static final String PREFIX_JAPANESE = "jis"; - private static final String PREFIX_SIMPLIFIEDCHINESE = "gb"; - private static final String PREFIX_TRADITIONALCHINESE = "cns"; - private static final String PREFIX_KOREAN = "ks"; - private static final String [] ISO_CHARSETS = new String [] { - "", // undefined - SWT.getMessage ("SWT_Charset_Western"), - SWT.getMessage ("SWT_Charset_EastEuropean"), - SWT.getMessage ("SWT_Charset_SouthEuropean"), - SWT.getMessage ("SWT_Charset_NorthEuropean"), - SWT.getMessage ("SWT_Charset_Cyrillic"), - SWT.getMessage ("SWT_Charset_Arabic"), - SWT.getMessage ("SWT_Charset_Greek"), - SWT.getMessage ("SWT_Charset_Hebrew"), - SWT.getMessage ("SWT_Charset_Turkish"), - SWT.getMessage ("SWT_Charset_Nordic"), - SWT.getMessage ("SWT_Charset_Thai"), - "", // undefined - SWT.getMessage ("SWT_Charset_BalticRim"), - SWT.getMessage ("SWT_Charset_Celtic"), - SWT.getMessage ("SWT_Charset_Euro") - }; - + FontData fontData; RGB rgb; -/** - * Constructs a new instance of this class given only its - * parent. - * <p> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ + boolean open; + public FontDialog (Shell parent) { - this (parent, SWT.NONE); + 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> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ public FontDialog (Shell parent, int style) { - super (parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL); + super (parent, style); checkSubclass (); } -/** - * Add the fonts found in 'fonts' to the list of fonts. - * Fonts are stored by character set and face name. For each character - * set/face name combination there is one FontExtStyles object that - * captures the different extended styles and the sizes and styles - * available for that extended style. - */ -void addFonts (FontData fonts[]) { - - for (int i = 0; i < fonts.length; i++) { - FontData font = fonts [i]; - - String charSetName = getTranslatedCharSet (font); - Hashtable charSet = (Hashtable) characterSets.get (charSetName); - if (charSet == null) { - charSet = new Hashtable (9); - characterSets.put (charSetName, charSet); - } - - String faceName = getTranslatedFaceName (font); - Hashtable faceSet = (Hashtable) charSet.get (faceName); - if (faceSet == null) { - faceSet = new Hashtable (9); - charSet.put (faceName, faceSet); - } - - String extStyleName = font.addStyle; - Hashtable extStyleSet = (Hashtable) faceSet.get (extStyleName); - if (extStyleSet == null) { - extStyleSet = new Hashtable (9); - faceSet.put (extStyleName, extStyleSet); - } - - Integer sizeValue = new Integer (font.getHeight ()); - Hashtable sizeSet = (Hashtable) extStyleSet.get (sizeValue); - if (sizeSet == null) { - sizeSet = new Hashtable (9); - extStyleSet.put (sizeValue, sizeSet); - } - - String style = font.weight; - sizeSet.put (style,font); - } -} - -/** - * Create the widgets of the dialog. - */ -void createChildren () { - Label characterSetLabel = new Label (shell, SWT.NONE); - Label faceNameLabel = new Label (shell, SWT.NONE); - Label extendedStyleLabel = new Label (shell, SWT.NONE); - GridLayout layout = new GridLayout (); - - layout.numColumns = 4; - layout.marginWidth = 15; - layout.marginHeight = 15; - layout.horizontalSpacing = 10; - layout.verticalSpacing = 2; - shell.setLayout (layout); - - // row one - characterSetLabel.setText (SWT.getMessage ("SWT_Character_set") + ":"); - faceNameLabel.setText (SWT.getMessage ("SWT_Font") + ":"); - extendedStyleLabel.setText (SWT.getMessage ("SWT_Extended_style") + ":"); - - new Label (shell, SWT.NONE); - - // row two - charSetCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL); - GridData gridData = new GridData (); - gridData.widthHint = COLUMN1_WIDTH; - gridData.heightHint = 150; - gridData.verticalSpan = 2; - charSetCombo.setLayoutData (gridData); - charSetCombo.setData (NO_SELECTION); - - faceNameCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL); - gridData = new GridData (); - gridData.widthHint = COLUMN2_WIDTH; - gridData.heightHint = 150; - gridData.verticalSpan = 2; - gridData.verticalAlignment = GridData.FILL; - faceNameCombo.setLayoutData (gridData); - faceNameCombo.setData (NO_SELECTION); - - extStyleCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL); - gridData = new GridData (); - gridData.widthHint = COLUMN3_WIDTH; - gridData.heightHint = 150; - gridData.verticalSpan = 2; - gridData.verticalAlignment = GridData.FILL; - extStyleCombo.setLayoutData (gridData); - extStyleCombo.setData (NO_SELECTION); - - // create ok and cancel buttons (row two and three) - createOkCancel (); - - // row four - createEmptyRow (); - - // row five - Label fontSizeLabel = new Label (shell, SWT.NONE); - fontSizeLabel.setText (SWT.getMessage ("SWT_Size") + ":"); - Label fontStyleLabel = new Label (shell, SWT.NONE); - fontStyleLabel.setText (SWT.getMessage ("SWT_Style") + ":"); - - Label fillLabel = new Label (shell, SWT.NONE); - gridData = new GridData (); - gridData.horizontalSpan = 2; - fillLabel.setLayoutData (gridData); - - // row six - fontSizeCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL); - gridData = new GridData (); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.FILL; - gridData.heightHint = 110; - fontSizeCombo.setLayoutData (gridData); - fontSizeCombo.setData (NO_SELECTION); - - fontStyleCombo = new Combo (shell, SWT.SIMPLE | SWT.V_SCROLL); - gridData = new GridData (); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.FILL; - fontStyleCombo.setLayoutData (gridData); - fontStyleCombo.setData (NO_SELECTION); - - fillLabel = new Label (shell, SWT.NONE); - gridData = new GridData (); - gridData.horizontalSpan = 2; - fillLabel.setLayoutData (gridData); - - // row seven - createEmptyRow (); - - // row eight - Group sampleGroup = new Group (shell, SWT.NONE); - sampleGroup.setText (SWT.getMessage ("SWT_Sample")); - gridData = new GridData (); - gridData.heightHint = 70; - gridData.horizontalSpan = 3; - gridData.horizontalAlignment = GridData.FILL; - sampleGroup.setLayoutData (gridData); - - // setup group box with sample text - layout = new GridLayout (); - layout.marginWidth = 10; - layout.marginHeight = 10; - sampleGroup.setLayout (layout); - - sampleLabel = new Label (sampleGroup, SWT.CENTER); - sampleLabel.setText (TEXT_SAMPLE); - gridData = new GridData (); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.verticalAlignment = GridData.FILL; - gridData.horizontalAlignment = GridData.FILL; - sampleLabel.setLayoutData (gridData); - shell.setSize (445, 410); -} - -/** - * Fill one row in the grid layout with empty widgets. - * Used to achieve a bigger vertical spacing between separate - * groups of widgets (ie. new rows of Text/Combo combinations). - */ -void createEmptyRow () { - Label fillLabel = new Label (shell, SWT.NONE); - GridData gridData = new GridData (); - - gridData.heightHint = 5; - gridData.horizontalSpan = ((GridLayout) shell.getLayout ()).numColumns; - fillLabel.setLayoutData (gridData); -} - -/** - * Create the widgets of the dialog. - */ -void createOkCancel () { - okButton = new Button (shell, SWT.PUSH); - okButton.setText (SWT.getMessage ("SWT_OK")); - shell.setDefaultButton (okButton); - GridData gridData = new GridData (); - gridData.horizontalAlignment = GridData.FILL; - gridData.widthHint = 70; - okButton.setLayoutData (gridData); - - cancelButton = new Button (shell, SWT.PUSH); - cancelButton.setText (SWT.getMessage ("SWT_Cancel")); - gridData = new GridData (); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.BEGINNING; - cancelButton.setLayoutData (gridData); -} - -Hashtable getExtStyles (String charsetName, String faceName) { - Hashtable faces = getFaces (charsetName); - if (faces == null) return null; - return (Hashtable) faces.get (faceName); -} - -Hashtable getFaces (String charsetName) { - return (Hashtable) getFonts ().get (charsetName); -} - -/** - * Returns a FontData object describing the font that was - * selected in the dialog, or null if none is available. - * - * @return the FontData for the selected font, or null - */ public FontData getFontData () { - if (sampleFont != null) { - return sampleFont.getFontData ()[0]; - } - return initialFontData; + return fontData; } -FontData getFontData (String charsetName, String faceName, String extStyle, int size, String style) { - Hashtable styles = getStyles (charsetName, faceName, extStyle, size); - if (styles == null) return null; - return (FontData) styles.get (style); -} - -/** - * Returns the collection of fonts that are displayed by the - * receiver. - * See the class definition for an explanation of the structure - * of the returned Hashtable. - */ -Hashtable getFonts () { - return characterSets; -} - -/** - * 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; } -/** - * Returns a FontData object that can be used to load the selected - * font. - */ -FontData getSelectionFontData () { - String charSetName = charSetCombo.getText (); - String faceName = faceNameCombo.getText (); - String extStyle = extStyleCombo.getText (); - int size = DEFAULT_SIZE; - try { - size = Integer.valueOf (fontSizeCombo.getText ()).intValue (); - } catch (NumberFormatException e) { - /* - * This block is purposely left empty since a default - * value is already specified above. - */ - } - String style = fontStyleCombo.getText (); - FontData result = getFontData (charSetName, faceName, extStyle, size, style); - - if (result == null) { - /* - * One or more of the dialog's widgets contain custom typed values. - * Create a FontData that mirrors these values so that the Font created - * below will try to find the best match. - */ - result = new FontData (); - result.characterSetRegistry = charSetName; - result.setName(faceName); - result.addStyle = extStyle; - result.weight = style; - } - result.setHeight (size); - return result; -} - -Hashtable getSizes (String charsetName, String faceName, String extStyle) { - Hashtable extStyles = getExtStyles (charsetName, faceName); - if (extStyles == null) return null; - return (Hashtable) extStyles.get (extStyle); -} - -Hashtable getStyles (String charsetName, String faceName, String extStyle, int size) { - Hashtable sizes = getSizes (charsetName, faceName, extStyle); - if (sizes == null) return null; - Hashtable result = (Hashtable) sizes.get (new Integer (size)); - if (result == null) - result = (Hashtable) sizes.get (SCALABLE_KEY); - return result; -} - -/** - * Returns the character set found in 'fontData' prefixed - * with a string explaining the character set. - */ -String getTranslatedCharSet (FontData fontData) { - String characterSet = fontData.characterSetRegistry; - String translatedCharSet = null; - - if (characterSet.startsWith (PREFIX_ISO8859)) { - int charSetName = 1; - try { - charSetName = Integer.valueOf (fontData.characterSetName).intValue (); - } catch (NumberFormatException e) { - /* - * This block is purposely left empty since a default - * value is already specified above. - */ - } - - characterSet += "-" + charSetName; - translatedCharSet = ISO_CHARSETS [charSetName]; - } - else - if (characterSet.startsWith (PREFIX_ISO646)) { - translatedCharSet = SWT.getMessage("SWT_Charset_ASCII"); - } - else - if (characterSet.startsWith (PREFIX_UNICODE)) { - translatedCharSet = SWT.getMessage("SWT_Charset_Unicode"); - } - else - if (characterSet.startsWith (PREFIX_JAPANESE)) { - translatedCharSet = SWT.getMessage("SWT_Charset_Japanese"); - } - else - if (characterSet.startsWith (PREFIX_SIMPLIFIEDCHINESE)) { - translatedCharSet = SWT.getMessage("SWT_Charset_SimplifiedChinese"); - } - else - if (characterSet.startsWith (PREFIX_TRADITIONALCHINESE)) { - translatedCharSet = SWT.getMessage("SWT_Charset_TraditionalChinese"); - } - else - if (characterSet.startsWith (PREFIX_KOREAN)) { - translatedCharSet = SWT.getMessage("SWT_Charset_Korean"); - } - if (translatedCharSet != null) { - translatedCharSet += " (" + characterSet + ')'; - } - else { - translatedCharSet = characterSet; - } - return translatedCharSet; -} - -/** - * Returns the face name as specified in FontData.familyName followed by - * the foundry set in parantheses if available. - * We display the face name first so that the list box sorts the fonts by - * face name, not by foundry. Users generally want to select fonts based - * on the face name and not by foundry. Once they've found the desired - * face name in the list they can compare the font variations from - * different foundries if available. - */ -String getTranslatedFaceName (FontData fontData) { - StringBuffer faceNameBuffer; - - if (fontData.foundry != null && fontData.foundry.length () > 0) { - faceNameBuffer = new StringBuffer (fontData.fontFamily); - faceNameBuffer.append (" ("); - faceNameBuffer.append (fontData.foundry); - faceNameBuffer.append (')'); - } - else { - faceNameBuffer = new StringBuffer (fontData.getName ()); - } - return faceNameBuffer.toString (); -} - -/** - * Handle the events the receiver is listening to. - * Combo selections cause the downstream combos to be initialized - * with font data and the sample text to be updated. - */ -void handleEvent (Event event) { - if (ignoreEvents) return; - if (event.widget instanceof Combo) { - Combo combo = (Combo) event.widget; - int prevSelectIndex = ((Integer) combo.getData ()).intValue (); - String text = combo.getText (); - int newSelectIndex = combo.indexOf (text); - if (prevSelectIndex != newSelectIndex || newSelectIndex == -1) { - ignoreEvents = true; - combo.setData (new Integer (newSelectIndex)); - if (combo == charSetCombo) initFaceNameCombo (); - else if (combo == faceNameCombo) initExtStyleCombo (); - else if (combo == extStyleCombo) initSizeCombo (); - else if (combo == fontSizeCombo) initStyleCombo (); - updateSampleFont (); - if (newSelectIndex != -1) { - // in case it came by typing the name - combo.select (newSelectIndex); +int fontProc (int nextHandler, int theEvent, int userData) { + int kind = OS.GetEventKind (theEvent); + switch (kind) { + case OS.kEventFontPanelClosed: + open = false; + break; + case OS.kEventFontSelection: + if (fontData == null) fontData = new FontData(); + short [] fontFamily = new short [1]; + if (OS.GetEventParameter (theEvent, OS.kEventParamFMFontFamily, OS.typeSInt16, null, 2, null, fontFamily) == OS.noErr) { + byte[] buffer = new byte[256]; + OS.FMGetFontFamilyName(fontFamily [0], buffer); + int length = buffer[0] & 0xFF; + char[] chars = new char[length]; + for (int i=0; i<length; i++) { + chars[i]= (char)buffer[i+1]; + } + fontData.setName (new String(chars)); } - ignoreEvents = false; - } - } - else - if (event.widget == okButton) { - okSelected = true; - shell.close (); - } - else - if (event.widget == cancelButton) { - okSelected = false; - shell.close (); - } -} - -/** - * Initialize the extended styles combo with the extended styles - * available for the selected font. - * Downstream combos are initialized as well (style and size). - */ -void initExtStyleCombo () { - String oldSelect = extStyleCombo.getText (); - extStyleCombo.removeAll (); - - String characterSet = charSetCombo.getText (); - String faceName = faceNameCombo.getText (); - Hashtable extStyles = getExtStyles (characterSet, faceName); - if (extStyles == null) return; - setItemsSorted (extStyleCombo, extStyles); - - int selectIndex = extStyleCombo.indexOf (oldSelect); - selectIndex = Math.max (0, selectIndex); - extStyleCombo.select (selectIndex); - extStyleCombo.setData (new Integer (selectIndex)); - initSizeCombo (); -} - -/** - * Initialize the face name combo box with all font names - * available in the selected character set. - * Downstream combos are initialized as well (extended style). - */ -void initFaceNameCombo () { - String oldSelect = faceNameCombo.getText (); - faceNameCombo.removeAll (); - - Hashtable faceNames = getFaces (charSetCombo.getText ()); - setItemsSorted (faceNameCombo, faceNames); - - int selectIndex = faceNameCombo.indexOf (oldSelect); - selectIndex = Math.max (0, selectIndex); - faceNameCombo.select (selectIndex); - faceNameCombo.setData (new Integer (selectIndex)); - initExtStyleCombo (); -} - -/** - * Initialize the widgets of the receiver with the data of - * all installed fonts. - * If the user specified a default font preselect that font in - * the combo boxes. - */ -void initializeWidgets () { - Display display = shell.getDisplay (); - addFonts (display.getFontList (null, false)); // get all fonts availabe on the current display - addFonts (display.getFontList (null, true)); - setItemsSorted (charSetCombo, getFonts ()); - if (initialFontData != null) { - Font initialFont = new Font (display, initialFontData); // verify that the initial font data is a valid font - initialFontData = null; - ignoreEvents = true; - setFontCombos (initialFont.getFontData ()[0]); - ignoreEvents = false; - initialFont.dispose (); - updateSampleFont (); - } -} - -/** - * Initialize the size combo with the sizes the selected font - * is available in. - * If the selected font is scalable a selection of preset sizes - * is used. - */ -void initSizeCombo () { - String oldSelect = fontSizeCombo.getText (); - fontSizeCombo.removeAll (); - - String characterSet = charSetCombo.getText (); - String faceName = faceNameCombo.getText (); - String extStyle = extStyleCombo.getText (); - Hashtable sizes = getSizes (characterSet, faceName, extStyle); - if (sizes == null) return; - if (sizes.get (SCALABLE_KEY) == null) { - /* - * Font is not scalable so just present the provided sizes. - */ - setSizeItemsSorted (sizes.keys ()); - } else { - /* - * Font is scalable so present the provided sizes and scalable - * sizes for selection. - */ - Vector allSizes = new Vector (); - /* - * Add the scalable sizes. - */ - for (int i = 0; i < SCALABLE_SIZES.length; i++) { - allSizes.addElement (new Integer (SCALABLE_SIZES [i])); - } - /* - * Add the provided sizes. - */ - Enumeration providedSizes = sizes.keys (); - while (providedSizes.hasMoreElements ()) { - Integer size = (Integer) providedSizes.nextElement (); - if (!size.equals (SCALABLE_KEY) && !allSizes.contains (size)) { - allSizes.addElement (size); + short [] fontStyle = new short [1]; + if (OS.GetEventParameter (theEvent, OS.kEventParamFMFontStyle, OS.typeSInt16, null, 2, null, fontStyle) == OS.noErr) { + int style = SWT.NORMAL; + if ((fontStyle [0] & OS.bold) != 0) style |= SWT.BOLD; + if ((fontStyle [0] & OS.italic) != 0) style |= SWT.ITALIC; + fontData.setStyle (style); } - } - setSizeItemsSorted (allSizes.elements ()); - } - - int selectIndex = fontSizeCombo.indexOf (oldSelect); - if (selectIndex == -1) { - selectIndex = fontSizeCombo.indexOf (String.valueOf (DEFAULT_SIZE)); + short [] fontSize = new short [1]; + if (OS.GetEventParameter (theEvent, OS.kEventParamFMFontSize, OS.typeSInt16, null, 2, null, fontSize) == OS.noErr) { + fontData.setHeight (fontSize [0]); + } + // NEEDS WORK - color not supported in native dialog for Carbon + RGBColor color = new RGBColor (); + int [] actualSize = new int [1]; + if (OS.GetEventParameter (theEvent, OS.kEventParamFontColor, OS.typeRGBColor, null, RGBColor.sizeof, actualSize, color) == OS.noErr) { + int red = (color.red >> 8) & 0xFF; + int green = (color.green >> 8) & 0xFF; + int blue = (color.blue >> 8) & 0xFF; + rgb = new RGB(red, green, blue); + } + break; } - selectIndex = Math.max (0, selectIndex); - fontSizeCombo.select (selectIndex); - fontSizeCombo.setData (new Integer (selectIndex)); - initStyleCombo (); + return OS.noErr; } - -/** - * Initialize the styles combo with the styles the selected font - * is available in. - */ -void initStyleCombo () { - String oldSelect = fontStyleCombo.getText (); - fontStyleCombo.removeAll (); - - String characterSet = charSetCombo.getText (); - String faceName = faceNameCombo.getText (); - String extStyle = extStyleCombo.getText (); - int size = DEFAULT_SIZE; - try { - size = Integer.valueOf (fontSizeCombo.getText ()).intValue (); - } catch (NumberFormatException e) { - /* - * This block is purposely left empty since a default - * value is already specified above. - */ - } - Hashtable styles = getStyles (characterSet, faceName, extStyle, size); - if (styles == null) return; - setItemsSorted (fontStyleCombo, styles); - int selectIndex = fontStyleCombo.indexOf (oldSelect); - if (selectIndex == -1) { - selectIndex = fontStyleCombo.indexOf (String.valueOf (DEFAULT_STYLE)); - } - selectIndex = Math.max (0, selectIndex); - fontStyleCombo.select (selectIndex); - fontStyleCombo.setData (new Integer (selectIndex)); - fontStyleCombo.select (Math.max (0, selectIndex)); -} - -/** - * Register the receiver to receive events. - */ -void installListeners () { - Listener listener = new Listener () { - public void handleEvent (Event event) { - FontDialog.this.handleEvent (event); +public FontData open () { + FontSelectionQDStyle qdStyle = new FontSelectionQDStyle(); + qdStyle.version = OS.kFontSelectionQDStyleVersionZero; + // NEEDS WORK - color not supported in native dialog for Carbon + if (rgb != null) { + qdStyle.hasColor = true; + qdStyle.color_red = (short)(rgb.red * 257); + qdStyle.color_green = (short)(rgb.green * 257); + qdStyle.color_blue = (short)(rgb.blue * 257); + } + if (fontData != null) { + String familyName = fontData.name; + byte [] buffer = new byte [256]; + int length = familyName.length(); + if (length > 255) length = 255; + buffer [0] = (byte)length; + for (int i=0; i<length; i++) { + buffer [i+1] = (byte) familyName.charAt(i); } + int id = OS.FMGetFontFamilyFromName (buffer); + if (id == OS.kInvalidFontFamily) id = OS.GetAppFont(); + qdStyle.instance_fontFamily = (short)id; + int style = fontData.style; + int fontStyle = OS.normal; + if ((style & SWT.BOLD) != 0) fontStyle |= OS.bold; + if ((style & SWT.ITALIC) != 0) fontStyle |= OS.italic; + qdStyle.instance_fontStyle = (short)fontStyle; + qdStyle.size = (short)fontData.height; + } + int ptr = OS.NewPtr(FontSelectionQDStyle.sizeof); + OS.memcpy (ptr, qdStyle, FontSelectionQDStyle.sizeof); + OS.SetFontInfoForSelection(OS.kFontSelectionQDType, 1, ptr, 0); + OS.DisposePtr (ptr); + int[] mask = new int[] { + OS.kEventClassFont, OS.kEventFontSelection, + OS.kEventClassFont, OS.kEventFontPanelClosed, }; - okButton.addListener (SWT.Selection, listener); - cancelButton.addListener (SWT.Selection, listener); - charSetCombo.addListener (SWT.Selection, listener); - charSetCombo.addListener (SWT.Modify, listener); - faceNameCombo.addListener (SWT.Modify, listener); - fontStyleCombo.addListener (SWT.Modify, listener); - extStyleCombo.addListener (SWT.Modify, listener); - fontSizeCombo.addListener (SWT.Modify, listener); -} - -/** - * Makes the dialog visible and brings it to the front - * of the display. - * - * @return a FontData object describing the font that was selected, - * or null if the dialog was cancelled or an error occurred - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li> - * </ul> - */ -public FontData open () { - shell = new Shell (getParent (), getStyle () | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL); - createChildren (); - installListeners (); - - initializeWidgets (); - setFontData (null); - openDialog (); - Display display = shell.getDisplay (); - while (!shell.isDisposed ()) { + Callback fontPanelCallback = new Callback (this, "fontProc", 3); + int appTarget = OS.GetApplicationEventTarget (); + int [] outRef = new int [1]; + OS.InstallEventHandler (appTarget, fontPanelCallback.getAddress(), mask.length / 2, mask, 0, outRef); + fontData = null; + rgb = null; + open = true; + OS.FPShowHideFontPanel (); + Display display = parent.getDisplay (); + while (!parent.isDisposed() && open) { if (!display.readAndDispatch ()) display.sleep (); - } - - FontData result = null; - if (okSelected) result = getFontData (); - if (sampleFont != null) sampleFont.dispose (); - return result; -} - -/** - * Open the receiver and set its size to the size calculated by - * the layout manager. - */ -void openDialog () { - // Start everything off by setting the shell size to its computed size. - Point pt = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, false); - - // Ensure that the width of the shell fits the display. - Rectangle displayRect = shell.getDisplay().getBounds(); - int widthLimit = displayRect.width * 7 / 8; - int heightLimit = displayRect.height * 7 / 8; - if (pt.x > widthLimit) { - pt = shell.computeSize (widthLimit, SWT.DEFAULT, false); - } - - // centre the dialog on its parent, and ensure that the - // whole dialog appears within the screen bounds - Rectangle parentBounds = getParent ().getBounds (); - int originX = (parentBounds.width - pt.x) / 2 + parentBounds.x; - originX = Math.max (originX, 0); - originX = Math.min (originX, widthLimit - pt.x); - int originY = (parentBounds.height - pt.y) / 2 + parentBounds.y; - originY = Math.max (originY, 0); - originY = Math.min (originY, heightLimit - pt.y); - shell.setBounds (originX, originY, pt.x, pt.y); - - String title = getText (); - if (title.length () == 0) title = SWT.getMessage ("SWT_FontDialog_Title"); - shell.setText(title); - - // Open the window. - shell.open(); -} - -/** - * Initialize the combo boxes with the data of the preselected - * font specified by the user. - */ -void setFontCombos (FontData fontData) { - String characterSet = getTranslatedCharSet (fontData); - String faceName = getTranslatedFaceName (fontData); - charSetCombo.setText (characterSet); - charSetCombo.setData (new Integer (charSetCombo.indexOf (characterSet))); - - initFaceNameCombo (); - faceNameCombo.setText (faceName); - faceNameCombo.setData (new Integer (faceNameCombo.indexOf (faceName))); - - initExtStyleCombo (); - extStyleCombo.setText (fontData.addStyle); - extStyleCombo.setData (new Integer (extStyleCombo.indexOf (fontData.addStyle))); - - initSizeCombo (); - String value = String.valueOf (fontData.getHeight ()); - fontSizeCombo.setText (value); - fontSizeCombo.setData (new Integer (fontSizeCombo.indexOf (value))); - - initStyleCombo (); - fontStyleCombo.setText (fontData.weight); - fontStyleCombo.setData (new Integer (fontStyleCombo.indexOf (fontData.weight))); + }; + OS.RemoveEventHandler (outRef [0]); + fontPanelCallback.dispose (); + return fontData; } -/** - * Sets a FontData object describing the font to be - * selected by default in the dialog, or null to let - * the platform choose one. - * - * @param fontData the FontData to use initially, or null - */ public void setFontData (FontData fontData) { - initialFontData = fontData; + this.fontData = fontData; } -/** - * Returns the receiver's selected color to be the argument. - * - * @param rgb the new RGB value for the selected color, may be - * null to let the platform to select a default when - * open() is called - * - * @see PaletteData#getRGBs - */ public void setRGB (RGB rgb) { this.rgb = rgb; } -/** - * Set the contents of 'combo' to the keys of 'items'. - * Keys are sorted in ascending order first and have to be Strings. - */ -void setItemsSorted (Combo combo, Hashtable items) { - Enumeration itemKeys = items.keys (); - String [] sortedItems = new String[items.size ()]; - int index = 0; - while (itemKeys.hasMoreElements ()) { - String item = (String) itemKeys.nextElement (); - if (item.length () != 0) sortedItems[index++] = item; - } - if (index != sortedItems.length) { - String [] newItems = new String[index]; - System.arraycopy (sortedItems, 0, newItems, 0, index); - sortedItems = newItems; - } - sort (sortedItems); - combo.setItems (sortedItems); -} - -/** - * Set the contents of the size combo to the keys of 'items'. - * Keys are sorted in ascending order first and have to be Integers. - */ -void setSizeItemsSorted (Enumeration itemsEnum) { - Vector items = new Vector (); - while (itemsEnum.hasMoreElements ()) { - items.addElement (itemsEnum.nextElement ()); - } - Integer[] sortedItems = new Integer [items.size ()]; - items.copyInto (sortedItems); - sort (sortedItems); - String[] sortedItemStrings = new String [items.size ()]; - for (int i = 0; i < sortedItemStrings.length; i++) { - sortedItemStrings [i] = String.valueOf (sortedItems [i].intValue ()); - } - fontSizeCombo.setItems (sortedItemStrings); -} - -/** - * Sort 'items' in ascending order. - */ -void sort (Integer[] 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].intValue () > items [j + gap].intValue ()) { - Integer swap = items [j]; - items[j] = items [j + gap]; - items[j + gap] = swap; - } - } - } - } -} - -/** - * Sort 'items' in ascending order. - */ -void sort (String 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].compareTo (items [j + gap]) > 0) { - String swap = items [j]; - items [j] = items[j + gap]; - items [j + gap] = swap; - } - } - } - } -} - -/** - * Set the font of the sample text to the selected font. - * Display an error in place of the sample text if the selected - * font could not be loaded. - */ -void updateSampleFont () { - FontData selectionFontData = getSelectionFontData (); - /* - * sampleFont may not be the same as the one specified in selectionFontData. - * This happens when selectionFontData specifies a font alias. - */ - Font newSampleFont = new Font (shell.getDisplay (), selectionFontData); - sampleLabel.setFont (newSampleFont); - if (sampleFont != null) sampleFont.dispose (); - sampleFont = newSampleFont; -} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Group.java index 57529b177f..4fe04daf42 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Group.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Group.java @@ -7,9 +7,10 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; /** * Instances of this class provide an etched border @@ -31,11 +32,9 @@ import org.eclipse.swt.*; * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> */ -public /*final*/ class Group extends Composite { - - private static final int LABEL_HEIGHT= 20; - private static final int MARGIN= 4; - +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. @@ -71,6 +70,7 @@ public /*final*/ class Group extends Composite { public Group (Composite parent, int style) { super (parent, checkStyle (style)); } + static int checkStyle (int style) { /* * Even though it is legal to create this widget @@ -81,93 +81,59 @@ static int checkStyle (int style) { */ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL); } + protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } + public Rectangle computeTrim (int x, int y, int width, int height) { - checkWidget(); - /* AW - int trimX, trimY, trimWidth, trimHeight; - int [] argList = { - OS.XmNwidth, 0, - OS.XmNheight, 0, - OS.XmNshadowThickness, 0, - OS.XmNmarginWidth, 0, - OS.XmNmarginHeight, 0 - }; - OS.XtGetValues (handle, argList, argList.length / 2); - int thickness = argList [5]; - int marginWidth = argList [7]; - int marginHeight = argList [9]; - int borderWidth = getBorderWidth (); - trimX = x - marginWidth + thickness - borderWidth; - trimY = y - marginHeight + thickness - borderWidth; - trimWidth = width + ((marginWidth + thickness + borderWidth) * 2); - trimHeight = height + ((marginHeight + thickness + borderWidth) * 2); - if (OS.XtIsManaged (labelHandle)) { - int [] argList2 = {OS.XmNy, 0, OS.XmNheight, 0}; - OS.XtGetValues (labelHandle, argList2, argList2.length / 2); - int labelHeight = ((short) argList2 [1]) + argList2 [3]; - trimY = y - labelHeight; - trimHeight = height + labelHeight + (marginHeight + thickness); - } - */ - return new Rectangle (x-MARGIN, y-LABEL_HEIGHT, width+(2*MARGIN), height+LABEL_HEIGHT+MARGIN); + checkWidget (); + Rect bounds = new Rect (); + OS.GetControlBounds (handle, bounds); + int rgnHandle = OS.NewRgn (); + OS.GetControlRegion (handle, (short)OS.kControlContentMetaPart, rgnHandle); + Rect client = new Rect (); + OS.GetRegionBounds (rgnHandle, client); + OS.DisposeRgn (rgnHandle); + x -= client.left - bounds.left; + y -= client.top - bounds.top; + width += Math.max (8, (bounds.right - bounds.left) - (client.right - client.left)); + height += Math.max (22, (bounds.bottom - bounds.top) - (client.bottom - client.top)); + return new Rectangle (x, y, width, height); } -void createHandle (int index) { - state |= HANDLE; - int parentHandle = parent.handle; - /* - formHandle = OS.XmCreateForm (parentHandle, null, argList1, argList1.length / 2); - if (formHandle == 0) error (SWT.ERROR_NO_HANDLES); - */ - /* AW - int [] argList2 = { - OS.XmNshadowType, shadowType (), - OS.XmNtopAttachment, OS.XmATTACH_FORM, - OS.XmNbottomAttachment, OS.XmATTACH_FORM, - OS.XmNleftAttachment, OS.XmATTACH_FORM, - OS.XmNrightAttachment, OS.XmATTACH_FORM, - OS.XmNresizable, 0, - }; - handle = OS.XmCreateFrame (formHandle, null, argList2, argList2.length / 2); - */ - handle= MacUtil.newControl(parentHandle, OS.kControlGroupBoxTextTitleProc); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - setFont(defaultFont()); + +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateGroupBoxControl (window, null, 0, true, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; } -Font defaultFont () { - return getDisplay ().groupFont; + +int defaultThemeFont () { + return OS.kThemeEmphasizedSystemFont; } + +void drawWidget (int control) { + drawBackground (handle, background); +} + public Rectangle getClientArea () { checkWidget(); - /* AW - int [] argList = { - OS.XmNwidth, 0, - OS.XmNheight, 0, - OS.XmNshadowThickness, 0, - OS.XmNmarginWidth, 0, - OS.XmNmarginHeight, 0 - }; - OS.XtGetValues (handle, argList, argList.length / 2); - int thickness = argList [5]; - int marginWidth = argList [7]; - int marginHeight = argList [9]; - int x = marginWidth + thickness; - int y = marginHeight + thickness; - int width = argList [1] - ((marginWidth + thickness) * 2) - 1; - int height = argList [3] - ((marginHeight + thickness) * 2) - 1; - if (OS.XtIsManaged (labelHandle)) { - int [] argList2 = {OS.XmNy, 0, OS.XmNheight, 0}; - OS.XtGetValues (labelHandle, argList2, argList2.length / 2); - y = ((short) argList2 [1]) + argList2 [3]; - height = argList [3] - y - (marginHeight + thickness) - 1; - } + Rect bounds = new Rect (); + OS.GetControlBounds (handle, bounds); + int rgnHandle = OS.NewRgn (); + OS.GetControlRegion (handle, (short)OS.kControlContentMetaPart, rgnHandle); + Rect client = new Rect (); + OS.GetRegionBounds (rgnHandle, client); + OS.DisposeRgn (rgnHandle); + int x = Math.max (0, client.left - bounds.left); + int y = Math.max (0, client.top - bounds.top); + int width = Math.max (0, client.right - client.left); + int height = Math.max (0, client.bottom - client.top); return new Rectangle (x, y, width, height); - */ - Point e= getSize(); - return new Rectangle(MARGIN, LABEL_HEIGHT, e.x-(2*MARGIN), e.y-(LABEL_HEIGHT+MARGIN)); } + /** * Returns the receiver's text, which is the string that the * is used as the <em>title</em>. If the text has not previously @@ -181,21 +147,10 @@ public Rectangle getClientArea () { * </ul> */ public String getText () { - checkWidget(); - int[] sHandle= new int[1]; - OS.GetControlTitleAsCFString(handle, sHandle); - return MacUtil.getStringAndRelease(sHandle[0]); + checkWidget (); + return text; } -/* AW -boolean mnemonicHit (char key) { - return setFocus (); -} -boolean mnemonicMatch (char key) { - char mnemonic = findMnemonic (getText ()); - if (mnemonic == '\0') return false; - return Character.toUpperCase (key) == Character.toUpperCase (mnemonic); -} -*/ + /** * Sets the receiver's text, which is the string that will * be displayed as the receiver's <em>title</em>, to the argument, @@ -214,13 +169,22 @@ boolean mnemonicMatch (char key) { public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(MacUtil.removeMnemonics(string)); - OS.SetControlTitleWithCFString(handle, sHandle); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); + if ((style & SWT.ARROW) != 0) return; + text = string; + char [] buffer = new char [text.length ()]; + text.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} + j--; + } } + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + OS.SetControlTitleWithCFString (handle, ptr); + OS.CFRelease (ptr); } -} + +}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Label.java index 688592b67b..189ceab5e7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Label.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Label.java @@ -7,431 +7,159 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; + import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.carbon.*; -/** - * Instances of this class represent a non-selectable - * user interface object that displays a string or image. - * When SEPARATOR is specified, displays a single - * vertical or horizontal line. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>SEPARATOR, HORIZONTAL, 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> - */ -public /*final*/ class Label extends Control { +public class Label extends Control { String text = ""; - Image image, disabled; + Image image; + boolean isImage; -/** - * 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) { if ((style & SWT.SEPARATOR) != 0) return style; return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0); } + public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); - int border = getBorderWidth (); int width = 0, height = 0; - if ((style & SWT.SEPARATOR) != 0) { if ((style & SWT.HORIZONTAL) != 0) { - width += DEFAULT_WIDTH; - height += 3; + width = DEFAULT_WIDTH; + height = 3; } else { - width += 3; - height += DEFAULT_HEIGHT; + width = 3; + height = DEFAULT_HEIGHT; } } else { - if (image != null) { + if (isImage && image != null) { Rectangle r = image.getBounds(); - width= r.width; - height= r.height; + width = r.width; + height = r.height; } else { - short[] bounds= new short[2]; - short[] baseLine= new short[1]; - boolean wrap= false; - if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) { - wrap= true; - bounds[1]= (short) wHint; // If we are wrapping text, calculate the height based on wHint. + int [] ptr = new int [1]; + int [] actualSize = new int [1]; + OS.GetControlData (handle, (short)0 , OS.kControlStaticTextCFStringTag, 4, ptr, actualSize); + if (ptr [0] != 0) { + org.eclipse.swt.internal.carbon.Point bounds = new org.eclipse.swt.internal.carbon.Point (); + short [] baseLine = new short [1]; + boolean wrap = false; + if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) { + wrap = true; + bounds.h = (short) wHint; + } + // NEEDS work - only works for default font + OS.GetThemeTextDimensions (ptr [0], (short)OS.kThemeSystemFont, OS.kThemeStateActive, wrap, bounds, baseLine); + width = bounds.h; + height = bounds.v; + OS.CFRelease (ptr [0]); + } else { + width = DEFAULT_WIDTH; + height = DEFAULT_HEIGHT; } - int sHandle= OS.CFStringCreateWithCharacters(MacUtil.removeMnemonics(text)); - - GC gc= new GC(this); - gc.installFont(); - OS.GetThemeTextDimensions(sHandle, OS.kThemeCurrentPortFont, OS.kThemeStateActive, wrap, bounds, baseLine); - gc.dispose(); - - OS.CFRelease(sHandle); - width = bounds[1]; - height = bounds[0]; } - /* - * Feature in Motif. If a label's labelType is XmSTRING but it - * has no label set into it yet, recomputing the size will - * not take into account the height of the font, as we would - * like it to. Take care of this case. - */ - /* AW - if (text.length () == 0) { - height += getFontHeight (); - width = 0; - } - */ } if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; - return new Point (width + 2*border, height + 2*border); + return new Point (width, height); } -void createHandle (int index) { - state |= HANDLE; - int parentHandle = parent.handle; - int borderWidth = (style & SWT.BORDER) != 0 ? 1 : 0; + +void createHandle () { + state |= GRAB; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); if ((style & SWT.SEPARATOR) != 0) { - handle= MacUtil.newControl(parentHandle, (short)0, (short)0, (short)100, OS.kControlSeparatorLineProc); - if ((style & SWT.HORIZONTAL) != 0) - OS.SizeControl(handle, (short) 20, (short) 1); - else - OS.SizeControl(handle, (short) 1, (short) 20); + OS.CreateSeparatorControl (window, null, outControl); } else { - handle = MacUtil.createDrawingArea(parentHandle, -1, true, 0, 0, borderWidth); + OS.CreateStaticTextControl (window, null, 0, null, outControl); } - if (handle == 0) error (SWT.ERROR_NO_HANDLES); -} -int defaultBackground () { - return getDisplay ().labelBackground; + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; } -Font defaultFont () { - return getDisplay ().labelFont; -} -int defaultForeground () { - return getDisplay ().labelForeground; -} -/** - * Returns a value which describes the position of the - * text or image in the receiver. The value will be one of - * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code> - * unless the receiver is a <code>SEPARATOR</code> label, in - * which case, <code>NONE</code> is returned. - * - * @return the alignment - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getAlignment () { checkWidget(); if ((style & SWT.SEPARATOR) != 0) return SWT.LEFT; - if ((style & SWT.CENTER) != 0) - return SWT.CENTER; - if ((style & SWT.RIGHT) != 0) - return SWT.RIGHT; + if ((style & SWT.CENTER) != 0) return SWT.CENTER; + if ((style & SWT.RIGHT) != 0) return SWT.RIGHT; return SWT.LEFT; } + public int getBorderWidth () { checkWidget(); return (style & SWT.BORDER) != 0 ? 1 : 0; } -/** - * Returns the receiver's image if it has one, or null - * if it does not. - * - * @return the receiver's image - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + 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; } -void hookEvents () { - super.hookEvents (); - Display display= getDisplay(); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneDrawProcTag, display.fUserPaneDrawProc); -} -/* AW -boolean mnemonicHit (char key) { - 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 true; - } - control = control.parent; - } - return false; -} -boolean mnemonicMatch (char key) { - char mnemonic = findMnemonic (getText ()); - if (mnemonic == '\0') return false; - return Character.toUpperCase (key) == Character.toUpperCase (mnemonic); -} -*/ -int processPaint (Object callData) { - if ((style & SWT.SEPARATOR) != 0) return 0; - - GC gc= new GC(this); - MacControlEvent me= (MacControlEvent) callData; - Rectangle r= gc.carbon_focus(me.getDamageRegionHandle()); - - if (! r.isEmpty()) { - - MacRect bounds= new MacRect(); - int hndl= topHandle(); - OS.GetControlBounds(hndl, bounds.getData()); - - int w= bounds.getWidth(); - int h= bounds.getHeight(); - int borderWidth = (style & SWT.BORDER) != 0 ? 1 : 0; - - gc.fillRectangle(0, 0, r.width, r.height); - - boolean enabled= OS.IsControlEnabled(handle); - + +int kEventControlDraw (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlDraw (nextHandler, theEvent, userData); + if (isImage) { if (image != null) { - Rectangle imageBounds= image.getBounds(); - Image im; - if (enabled) - im= image; - else { - if (disabled == null) - disabled = new Image (getDisplay(), image, SWT.IMAGE_DISABLE); - im= disabled; - } - gc.drawImage(im, (w-imageBounds.width) / 2, (h-imageBounds.height) / 2); - } else { - int sHandle= OS.CFStringCreateWithCharacters(MacUtil.removeMnemonics(text)); - boolean wrap= (style & SWT.WRAP) != 0; - short just= 0; - if ((style & SWT.RIGHT) != 0) - just= 2; - else if ((style & SWT.CENTER) != 0) - just= 1; - MacUtil.RGBForeColor(enabled ? 0x000000 : 0x808080); - gc.installFont(); - bounds.set(borderWidth, borderWidth, w-2*borderWidth, h-2*borderWidth); - OS.DrawThemeTextBox(sHandle, OS.kThemeCurrentPortFont, OS.kThemeStateActive, wrap, bounds.getData(), just, 0); - OS.CFRelease(sHandle); - } - - if (borderWidth > 0) { - gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY)); - gc.drawRectangle(0, 0, w-1, h-1); + GCData data = new GCData (); + data.paintEvent = theEvent; + GC gc = GC.carbon_new (this, data); + gc.drawImage (image, 0, 0); + gc.dispose (); } - - // AW: debugging - //gc.drawRectangle(0, 0, r.width-1, r.height-1); - } - - gc.carbon_unfocus(); - gc.dispose(); - - return 0; -} -void propagateWidget (boolean enabled) { - super.propagateWidget (enabled); - /* - * Labels never participate in focus traversal when - * either enabled or disabled. - */ - /* AW - if (enabled) { - int [] argList = {OS.XmNtraversalOn, 0}; - OS.XtSetValues (handle, argList, argList.length / 2); + return OS.noErr; } - */ -} -void releaseWidget () { - super.releaseWidget (); - if (disabled != null) disabled.dispose (); - image = disabled = null; -} -/* AW -int separatorType () { - if ((style & (SWT.SHADOW_IN)) != 0) return OS.XmSHADOW_ETCHED_IN; - if ((style & (SWT.SHADOW_OUT)) != 0) return OS.XmSHADOW_ETCHED_OUT; - return OS.XmSHADOW_ETCHED_IN; + return result; } -*/ -/** - * 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; - int mask= SWT.LEFT | SWT.CENTER | SWT.RIGHT; - int newAlignment= alignment & mask; - int currentAlignment= style & mask; - if (currentAlignment != newAlignment) { - style &= ~mask; - style |= newAlignment; - redrawWidget (0, 0, 0, 0, false); - } } -public void setBounds (int x, int y, int width, int height) { - super.setBounds (x, y, width, height); - if ((style & SWT.WRAP) != 0) setText (text); -} -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; - if (disabled != null) disabled.dispose (); - disabled = null; - if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); - redrawWidget (0, 0, 0, 0, false); -} -public void setSize (int width, int height) { - super.setSize (width, height); - if ((style & SWT.WRAP) != 0) setText (text); + isImage = true; + redraw (); } -/** - * Sets the receiver's text. - * <p> - * This method sets the widget label. The label may include - * the mnemonic characters and line delimiters. - * </p> - * - * @param string the new text - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the text is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); if ((style & SWT.SEPARATOR) != 0) return; + isImage = false; text = string; - - /* Strip out mnemonic marker symbols, and remember the mnemonic. */ - char [] unicode = new char [string.length ()]; - string.getChars (0, unicode.length, unicode, 0); - int i=0, j=0, mnemonic=0; - while (i < unicode.length) { - if ((unicode [j++] = unicode [i++]) == Mnemonic) { - if (i == unicode.length) {continue;} - if (unicode [i] == Mnemonic) {i++; continue;} - if (mnemonic == 0) mnemonic = unicode [i]; + char [] buffer = new char [text.length ()]; + text.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} j--; } } - while (j < unicode.length) unicode [j++] = 0; - - redrawWidget (0, 0, 0, 0, false); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + OS.SetControlData (handle, 0 , OS.kControlStaticTextCFStringTag, 4, new int[]{ptr}); + OS.CFRelease (ptr); + redraw (); } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java index 3f09963669..cc83c96571 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java @@ -7,169 +7,58 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import java.util.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.DataBrowserCallbacks; +import org.eclipse.swt.internal.carbon.DataBrowserListViewColumnDesc; +import org.eclipse.swt.internal.carbon.Rect; import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.internal.carbon.*; - -/** - * Instances of this class represent a selectable user interface - * object that displays a list of strings and issues notificiation - * when a string selected. A list may be single or multi select. - * <p> - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>SINGLE, MULTI</dd> - * <dt><b>Events:</b></dt> - * <dd>Selection, DefaultSelection</dd> - * </dl> - * <p> - * Note: Only one of SINGLE and MULTI may be specified. - * </p><p> - * IMPORTANT: This class is <em>not</em> intended to be subclassed. - * </p> - */ -public /*final*/ class List extends Scrollable { +import org.eclipse.swt.graphics.*; - // AW - private static final int COL_ID= 12345; - private ArrayList fData= new ArrayList(); - private int fRowID= 1000; - - private class Pair { - int fId; - String fValue; +public class List extends Scrollable { + String [] items; + int itemCount, anchorFirst, anchorLast; + boolean ignoreSelect; + static final int COLUMN_ID = 1024; - Pair(String v) { - fValue= v; - fId= fRowID++; - } - - } - // AW - -/** - * 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)); } -/** - * Adds the argument to the end of the receiver's list. - * - * @param string the new item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li> - * </ul> - * - * @see #add(String,int) - */ + public void add (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - Pair p= new Pair(string); - fData.add(p); - OS.AddDataBrowserItems(handle, OS.kDataBrowserNoItem, 1, new int[] { p.fId }, 0); + int [] id = new int [] {itemCount + 1}; + if (OS.AddDataBrowserItems (handle, OS.kDataBrowserNoItem, 1, id, 0) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_ADDED); + } + if (itemCount == items.length) { + String [] newItems = new String [itemCount + 4]; + System.arraycopy (items, 0, newItems, 0, items.length); + items = newItems; + } + items [itemCount++] = string; } -/** - * Adds the argument to the receiver's list at the given - * zero-relative index. - * <p> - * Note: To add an item at the end of the list, use the - * result of calling <code>getItemCount()</code> as the - * index or use <code>add(String)</code>. - * </p> - * - * @param string the new item - * @param index the index for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li> - * </ul> - * - * @see #add(String) - */ + public void add (String string, int index) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - if (index == -1) error (SWT.ERROR_INVALID_RANGE); - int size= fData.size(); - if (!(0 <= index && index <= size)) { - error (SWT.ERROR_INVALID_RANGE); - } - Pair p= new Pair(string); - fData.add(index, p); - if (OS.AddDataBrowserItems(handle, OS.kDataBrowserNoItem, 1, new int[] { p.fId }, 0) != OS.kNoErr) + if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE); + int [] id = new int [] {itemCount + 1}; + if (OS.AddDataBrowserItems (handle, OS.kDataBrowserNoItem, 1, id, 0) != OS.noErr) { error (SWT.ERROR_ITEM_NOT_ADDED); + } + if (itemCount == items.length) { + String [] newItems = new String [itemCount + 4]; + System.arraycopy (items, 0, newItems, 0, items.length); + items = newItems; + } + System.arraycopy (items, index, items, index + 1, itemCount++ - index); + items [index] = string; + OS.UpdateDataBrowserItems (handle, 0, 0, null, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver's selection changes, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * <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 - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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); @@ -177,639 +66,465 @@ public void addSelectionListener(SelectionListener listener) { addListener(SWT.Selection,typedListener); addListener(SWT.DefaultSelection,typedListener); } + static int checkStyle (int style) { return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0); } + public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); - /* AW - XtWidgetGeometry result = new XtWidgetGeometry (); - result.request_mode = OS.CWWidth; - OS.XtQueryGeometry (handle, null, result); - int width = result.width, height = 0; - */ - int width = 300, height = 0; - if (wHint != SWT.DEFAULT) width = wHint; - if (hHint != SWT.DEFAULT) height = hHint; - if (hHint == SWT.DEFAULT || wHint == SWT.DEFAULT) { - /* AW - int [] argList = {OS.XmNitemCount, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - int count = argList [1]; - */ - int count = fData.size(); - if (hHint == SWT.DEFAULT) { - if (count == 0) { - height = DEFAULT_HEIGHT; - } else { - height = getItemHeight () * count; - } - } - if (wHint == SWT.DEFAULT && count == 0) { - width = DEFAULT_WIDTH; + int width = 0; + if (wHint == SWT.DEFAULT) { + GC gc = new GC (this); + for (int i=0; i<itemCount; i++) { + Point extent = gc.stringExtent (items [i]); + width = Math.max (width, extent.x); } + gc.dispose (); + } else { + width = wHint; + } + if (width <= 0) width = DEFAULT_WIDTH; + int height = 0; + if (hHint == SWT.DEFAULT) { + height = itemCount * getItemHeight (); + } else { + height = hHint; } + if (height <= 0) height = DEFAULT_HEIGHT; Rectangle rect = computeTrim (0, 0, width, height); return new Point (rect.width, rect.height); } + public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget(); - int border = getBorderWidth (); - int trimX = x - border; - int trimY = y - border; - int trimWidth = width + (border * 2); - int trimHeight = height + (border * 2); - Display display= getDisplay(); - if (horizontalBar != null) { - trimHeight += 15; - trimY -= display.scrolledInsetY; - if (verticalBar != null) { - trimX -= display.scrolledInsetX; - } - } - if (verticalBar != null) { - trimWidth += 15; - trimX -= display.scrolledInsetX; - if (horizontalBar != null) { - trimY -= display.scrolledInsetY; - } - } - /* AW - int [] argList = { - OS.XmNhighlightThickness, 0, // 1 - OS.XmNshadowThickness, 0, // 3 - OS.XmNlistMarginWidth, 0, // 5 - OS.XmNlistMarginHeight, 0 // 7 - }; - OS.XtGetValues (handle, argList, argList.length / 2); - int thickness = argList [1] + (argList [3] * 2); - trimWidth += thickness + argList [5] + 1; - trimHeight += thickness + argList [7] + 1; - trimX -= argList [1] + argList [3] + argList [5]; - trimY -= argList [1] + argList [3] + argList [7]; - */ - return new Rectangle (trimX, trimY, trimWidth, trimHeight); + Rect rect = new Rect (); + OS.GetDataBrowserScrollBarInset (handle, rect); + x -= rect.left; + y -= rect.top; + width += (rect.left + rect.right) * 3; + height += rect.top + rect.bottom; + return new Rectangle (x, y, width, height); } -void createHandle (int index) { - state |= HANDLE; - int parentHandle = parent.handle; - int windowHandle= OS.GetControlOwner(parentHandle); - handle= OS.createDataBrowserControl(windowHandle); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - MacUtil.addControl(handle, parentHandle); - MacUtil.initLocation(handle); - - /* Single or Multiple Selection */ - int mode= OS.kDataBrowserSelectOnlyOne; - if ((style & SWT.MULTI) != 0) - mode= OS.kDataBrowserDragSelect | OS.kDataBrowserCmdTogglesSelection; - OS.SetDataBrowserSelectionFlags(handle, mode); - - /* hide the neader */ - OS.SetDataBrowserListViewHeaderBtnHeight(handle, (short) 0); - - /* enable scrollbars */ - OS.SetDataBrowserHasScrollBars(handle, (style & SWT.H_SCROLL) != 0, (style & SWT.V_SCROLL) != 0); - if ((style & SWT.H_SCROLL) == 0) - OS.AutoSizeDataBrowserListViewColumns(handle); - - int columnDesc= OS.newColumnDesc(COL_ID, OS.kDataBrowserTextType, - OS.kDataBrowserListViewSelectionColumn | OS.kDataBrowserDefaultPropertyFlags, - (short)0, (short)2000); - OS.AddDataBrowserListViewColumn(handle, columnDesc, 10000); -} -ScrollBar createScrollBar (int type) { - return createStandardBar (type); +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateDataBrowserControl (window, null, OS.kDataBrowserListView, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + int selectionFlags = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserSelectOnlyOne : OS.kDataBrowserCmdTogglesSelection; + OS.SetDataBrowserSelectionFlags (handle, selectionFlags); + OS.SetDataBrowserListViewHeaderBtnHeight (handle, (short) 0); + OS.SetDataBrowserHasScrollBars (handle, (style & SWT.H_SCROLL) != 0, (style & SWT.V_SCROLL) != 0); + //NOT DONE + if ((style & SWT.H_SCROLL) == 0) OS.AutoSizeDataBrowserListViewColumns (handle); + DataBrowserListViewColumnDesc column = new DataBrowserListViewColumnDesc (); + column.headerBtnDesc_version = OS.kDataBrowserListViewLatestHeaderDesc; + column.propertyDesc_propertyID = COLUMN_ID; + column.propertyDesc_propertyType = OS.kDataBrowserTextType; + column.propertyDesc_propertyFlags = OS.kDataBrowserListViewSelectionColumn | OS.kDataBrowserDefaultPropertyFlags; + //NOT DONE + column.headerBtnDesc_maximumWidth= 0x7FFF; + column.headerBtnDesc_initialOrder= OS.kDataBrowserOrderIncreasing; + OS.AddDataBrowserListViewColumn (handle, column, 0); + //NOT DONE + OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short)800); + + /* + * Feature in the Macintosh. Scroll bars are not created until + * the widget has a minimum size. The fix is to force the scroll + * bars to be created by temporarily giving the widget a size and + * then restoring it to zero. + * + * NOTE: The widget must be visible and SizeControl() must be used + * to resize the widget to a minimim size or the widget will not + * create the scroll bars. This work around currently flashes. + */ + OS.SizeControl (handle, (short) 0xFF, (short) 0xFF); + OS.SizeControl (handle, (short) 0, (short) 0); } -/* AW -int defaultBackground () { - return getDisplay ().listBackground; + +void createWidget () { + super.createWidget (); + items = new String [4]; } -int defaultFont () { - return getDisplay ().listFont; + +ScrollBar createScrollBar (int style) { + return createStandardBar (style); } -int defaultForeground () { - return getDisplay ().listForeground; + +int defaultThemeFont () { + return OS.kThemeViewsFont; } -*/ -/** - * 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 && index < fData.size()) { - Pair p= (Pair) fData.get(index); - if (p != null) - OS.SetDataBrowserSelectedItems(handle, 1, new int[] { p.fId }, OS.kDataBrowserItemsRemove); - } + if (0 < index && index < itemCount) { + ignoreSelect = true; + int [] id = new int [] {index + 1}; + OS.SetDataBrowserSelectedItems (handle, id.length, id, OS.kDataBrowserItemsRemove); + ignoreSelect = false; + } } -/** - * Deselects the items at the given zero-relative indices in the receiver. - * If the item at the given zero-relative index in the receiver - * is selected, it is deselected. If the item at the index - * was not selected, it remains deselected. The range of the - * indices is inclusive. Indices that are out of range are ignored. - * - * @param start the start index of the items to deselect - * @param end the end index of the items to deselect - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void deselect (int start, int end) { checkWidget(); - if (start > end) return; - int[] ids= getIds(start, end); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsRemove); + //NOT DONE - range check + int length = end - start + 1; + if (length <= 0) return; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = end - i + 1; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, length, ids, OS.kDataBrowserItemsRemove); + ignoreSelect = false; } -/** - * Deselects the items at the given zero-relative indices in the receiver. - * If the item at the given zero-relative index in the receiver - * is selected, it is deselected. If the item at the index - * was not selected, it remains deselected. Indices that are out - * of range and duplicate indices are ignored. - * - * @param indices the array of indices for the items to deselect - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void deselect (int [] indices) { checkWidget(); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); - int[] ids= getIds(indices); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsRemove); + //NOT DONE - range check + int length = indices.length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = indices [length - i - 1] + 1; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, length, ids, OS.kDataBrowserItemsRemove); + ignoreSelect = false; } -/** - * Deselects all selected items in the receiver. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void deselectAll () { + checkWidget (); + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsRemove); + ignoreSelect = false; +} + +public Rectangle getClientArea () { checkWidget(); - int n= fData.size(); - if (n <= 0) return; - int[] ids= getIds(0, n-1); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsRemove); + Rect rect = new Rect (), inset = new Rect (); + OS.GetControlBounds (handle, rect); + OS.GetDataBrowserScrollBarInset (handle, inset); + return new Rectangle (inset.left, inset.top, rect.right - rect.left + inset.right, rect.bottom - rect.top + inset.bottom); } -/** - * Returns the zero-relative index of the item which is currently - * has the focus in the receiver, or -1 if no item is has focus. - * - * @return the index of the selected item - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getFocusIndex () { checkWidget(); - /* AW - return OS.XmListGetKbdItemPos (handle) - 1; - */ - return -1; + int [] first = new int [1], last = new int [1]; + if (OS.GetDataBrowserSelectionAnchor (handle, first, last) != OS.noErr) return -1; + return first [0] - 1; } -/** - * Returns the item at the given, zero-relative index in the - * receiver. Throws an exception if the index is out of range. - * - * @param index the index of the item to return - * @return the item at the given index - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li> - * </ul> - */ + public String getItem (int index) { checkWidget(); - int size= fData.size(); - if (!(0 <= index && index < size)) - error (SWT.ERROR_INVALID_RANGE); - Pair p= (Pair) fData.get(index); - return p.fValue; + if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE); + return items [index]; } -/** - * Returns the number of items contained in the receiver. - * - * @return the number of items - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int getItemCount () { checkWidget(); - return fData.size(); + return itemCount; } -/** - * Returns the height of the area which would be used to - * display <em>one</em> of the items in the tree. - * - * @return the height of one item - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int getItemHeight () { - checkWidget(); - return 15; // AW FIXME + checkWidget (); + short [] height = new short [1]; + if (OS.GetDataBrowserTableViewRowHeight (handle, height) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT); + } + return height [0]; } -/** - * Returns an array of <code>String</code>s which are the items - * in the receiver. - * <p> - * Note: This is not the actual structure used by the receiver - * to maintain its list of items, so modifying the array will - * not affect the receiver. - * </p> - * - * @return the items in the receiver's list - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li> - * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li> - * </ul> - */ + public String [] getItems () { checkWidget(); - String[] result= new String[fData.size()]; - Iterator iter= fData.iterator(); - for (int i= 0; iter.hasNext(); i++) { - Pair p= (Pair) iter.next(); - result[i]= p.fValue; - } + String [] result = new String [itemCount]; + System.arraycopy (items, 0, result, 0, itemCount); return result; } -/** - * Returns an array of <code>String</code>s that are currently - * selected in the receiver. An empty array indicates that no - * items are selected. - * <p> - * Note: This is not the actual structure used by the receiver - * to maintain its selection, so modifying the array will - * not affect the receiver. - * </p> - * @return an array representing the selection - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li> - * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li> - * </ul> - */ + public String [] getSelection () { - checkWidget(); - int[] ids= MacUtil.getSelectionIDs(handle, OS.kDataBrowserNoItem, false); - String[] result= new String[ids.length]; - for (int i= 0; i < ids.length; i++) - result[i]= get(ids[i]); + checkWidget (); + int ptr = OS.NewHandle (0); + if (OS.GetDataBrowserItems (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, ptr) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_SELECTION); + } + int count = OS.GetHandleSize (ptr) / 4; + String [] result = new String [count]; + OS.HLock (ptr); + int [] start = new int [1]; + OS.memcpy (start, ptr, 4); + int [] id = new int [1]; + for (int i=0; i<count; i++) { + OS.memcpy (id, start [0] + (i * 4), 4); + result [i] = items [id [0] - 1]; + } + OS.HUnlock (ptr); + OS.DisposeHandle (ptr); return result; } -/** - * Returns the number of selected items contained in the receiver. - * - * @return the number of selected items - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int getSelectionCount () { - checkWidget(); - int[] result= new int[1]; - if (OS.GetDataBrowserItemCount(handle, OS.kDataBrowserNoItem, false, OS.kDataBrowserItemIsSelected, result) != OS.kNoErr) + checkWidget (); + int [] count = new int [1]; + if (OS.GetDataBrowserItemCount (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, count) != OS.noErr) { error (SWT.ERROR_CANNOT_GET_COUNT); - return result[0]; + } + return count [0]; } -/** - * Returns the zero-relative index of the item which is currently - * selected in the receiver, or -1 if no item is selected. - * - * @return the index of the selected item - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int getSelectionIndex () { checkWidget(); - int[] ids= MacUtil.getSelectionIDs(handle, OS.kDataBrowserNoItem, false); - if (ids.length > 0) - return getIndex(ids[0]); - return -1; + int [] first = new int [1], last = new int [1]; + if (OS.GetDataBrowserSelectionAnchor (handle, first, last) != OS.noErr) return -1; + return first [0] - 1; } -/** - * Returns the zero-relative indices of the items which are currently - * selected in the receiver. The array is empty if no items are selected. - * <p> - * Note: This is not the actual structure used by the receiver - * to maintain its selection, so modifying the array will - * not affect the receiver. - * </p> - * @return the array of indices of the selected items - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li> - * </ul> - */ + public int [] getSelectionIndices () { - checkWidget(); - int[] ids= MacUtil.getSelectionIDs(handle, OS.kDataBrowserNoItem, false); - int[] result= new int[ids.length]; - for (int i= 0; i < ids.length; i++) - result[i]= getIndex(ids[i]); + checkWidget (); + int ptr = OS.NewHandle (0); + if (OS.GetDataBrowserItems (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, ptr) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_SELECTION); + } + int count = OS.GetHandleSize (ptr) / 4; + int [] result = new int [count]; + OS.HLock (ptr); + int [] start = new int [1]; + OS.memcpy (start, ptr, 4); + int [] id = new int [1]; + for (int i=0; i<count; i++) { + OS.memcpy (id, start [0] + (i * 4), 4); + result [i] = id [0] - 1; + } + OS.HUnlock (ptr); + OS.DisposeHandle (ptr); 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[] top= new int[1]; - int[] left= new int[1]; - OS.GetDataBrowserScrollPosition(handle, top, left); - return top[0] / getItemHeight(); + int[] top = new int [1], left = new int [1]; + OS.GetDataBrowserScrollPosition (handle, top, left); + return top [0] / getItemHeight (); } + void hookEvents () { super.hookEvents (); Display display= getDisplay(); - OS.setDataBrowserCallbacks(handle, display.fDataBrowserDataProc, - display.fDataBrowserCompareProc, display.fDataBrowserItemNotificationProc); + DataBrowserCallbacks callbacks = new DataBrowserCallbacks (); + callbacks.version = OS.kDataBrowserLatestCallbacks; + OS.InitDataBrowserCallbacks (callbacks); + callbacks.v1_itemDataCallback = display.itemDataProc; + callbacks.v1_itemNotificationCallback = display.itemNotificationProc; + OS.SetDataBrowserCallbacks (handle, callbacks); } -/** - * 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) { + +int itemDataProc (int browser, int id, int property, int itemData, int setValue) { + int index = id - 1; + switch (property) { + case COLUMN_ID: { + String text = items [index]; + char [] buffer = new char [text.length ()]; + text.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + OS.SetDataBrowserItemDataText (itemData, ptr); + OS.CFRelease (ptr); + break; + } + } + return OS.noErr; +} + +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + int result = super.kEventMouseDown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * Feature in the Macintosh. For some reason, when the user + * clicks on the data browser, focus is assigned, then lost + * and then reassigned causing kEvenControlSetFocusPart events. + * The fix is to ignore kEvenControlSetFocusPart when the user + * clicks and send the focus events from kEventMouseDown. + */ + Display display = getDisplay (); + Control oldFocus = display.getFocusControl (); + display.ignoreFocus = true; + result = OS.CallNextEventHandler (nextHandler, theEvent); + display.ignoreFocus = false; + if (oldFocus != this) { + if (oldFocus != null) oldFocus.sendFocusEvent (false); + if (isEnabled ()) sendFocusEvent (true); + } + return result; +} + +int kEventRawKeyDown (int nextHandler, int theEvent, int userData) { + int result = super.kEventRawKeyDown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * Feature in the Macintosh. For some reason, when the user hits an + * up or down arrow to traverse the items in a Data Browser, the item + * scrolls to the left such that the white space that is normally + * visible to the right of the every item is scrolled out of view. + * The fix is to do the arrow traversal in Java and not call the + * default handler. + */ + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + switch (keyCode [0]) { + case 125: { /* Down */ + int index = getSelectionIndex (); + setSelection (Math.min (itemCount - 1, index + 1)); + return OS.noErr; + } + case 126: { /* Up*/ + int index = getSelectionIndex (); + setSelection (Math.max (0, index - 1)); + return OS.noErr; + } + } + return OS.eventNotHandledErr; +} + +int kEventRawKeyRepeat (int nextHandler, int theEvent, int userData) { + int result = super.kEventRawKeyRepeat (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * Feature in the Macintosh. For some reason, when the user hits an + * up or down arrow to traverse the items in a Data Browser, the item + * scrolls to the left such that the white space that is normally + * visible to the right of the every item is scrolled out of view. + * The fix is to do the arrow traversal in Java and not call the + * default handler. + */ + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + switch (keyCode [0]) { + case 125: { /* Down */ + int index = getSelectionIndex (); + setSelection (Math.min (itemCount - 1, index + 1)); + return OS.noErr; + } + case 126: { /* Up*/ + int index = getSelectionIndex (); + setSelection (Math.max (0, index - 1)); + return OS.noErr; + } + } + return OS.eventNotHandledErr; +} + +int itemNotificationProc (int browser, int id, int message) { + switch (message) { + case OS.kDataBrowserItemSelected: + case OS.kDataBrowserItemDeselected: { + if (ignoreSelect) break; + int [] first = new int [1], last = new int [1]; + OS.GetDataBrowserSelectionAnchor (handle, first, last); + boolean selected = false; + if ((style & SWT.MULTI) != 0) { + int modifiers = OS.GetCurrentEventKeyModifiers (); + if ((modifiers & OS.shiftKey) != 0) { + if (message == OS.kDataBrowserItemSelected) { + selected = first [0] == id || last [0] == id; + } else { + selected = id == anchorFirst || id == anchorLast; + } + } else { + if ((modifiers & OS.cmdKey) != 0) { + selected = true; + } else { + selected = first [0] == last [0]; + } + } + } else { + selected = message == OS.kDataBrowserItemSelected; + } + if (selected) { + anchorFirst = first [0]; + anchorLast = last [0]; + postEvent (SWT.Selection); + } + break; + } + case OS.kDataBrowserItemDoubleClicked: { + postEvent (SWT.DefaultSelection); + break; + } + } + return OS.noErr; +} + +public int indexOf (String item) { checkWidget(); - return getIndex(string, 0); + if (item == null) error (SWT.ERROR_NULL_ARGUMENT); + for (int i=0; i<itemCount; i++) { + if (items [i] == item) return i; + } + return -1; } -/** - * Searches the receiver's list starting at the given, - * zero-relative index until an item is found that is equal - * to the argument, and returns the index of that item. If - * no item is found or the starting index is out of range, - * returns -1. - * - * @param string the search item - * @return the index of the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li> - * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li> - * </ul> - */ + public int indexOf (String string, int start) { checkWidget(); - return getIndex(string, start); + if (string == null) error (SWT.ERROR_NULL_ARGUMENT); + for (int i=start; i<itemCount; i++) { + if (items [i] == string) return i; + } + 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 visibility state of the item at the index - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public boolean isSelected (int index) { checkWidget(); - if (index >= 0 && index < fData.size()) { - Pair p= (Pair) fData.get(index); - if (p != null) - return OS.IsDataBrowserItemSelected(handle, p.fId); - } - return false; + return OS.IsDataBrowserItemSelected (handle, index + 1); } -/** - * Removes the item from the receiver at the given - * zero-relative index. - * - * @param index the index for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void remove (int index) { checkWidget(); - if (index == -1) error (SWT.ERROR_INVALID_RANGE); - int size= fData.size(); - if (!(0 <= index && index < size)) { - error (SWT.ERROR_INVALID_RANGE); + if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE); + int [] id = new int [] {itemCount}; + if (OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, id.length, id, 0) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_REMOVED); } - Pair p= (Pair) fData.remove(index); - OS.RemoveDataBrowserItems(handle, OS.kDataBrowserNoItem, 1, new int[] { p.fId }, 0); + System.arraycopy (items, index + 1, items, index, --itemCount - index); + items [itemCount] = null; + OS.UpdateDataBrowserItems (handle, 0, 0, null, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); } -/** - * Removes the items from the receiver which are - * between the given zero-relative start and end - * indices (inclusive). - * - * @param start the start of the range - * @param end the end of the range - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void remove (int start, int end) { checkWidget(); - if (start > end) return; - int n= fData.size(); - if (start < 0 || start >= n || end < 0 || end >= n) + if (!(0 <= start && start <= end && end < itemCount)) { error (SWT.ERROR_INVALID_RANGE); - int[] ids= getIds(start, end); - if (OS.RemoveDataBrowserItems(handle, OS.kDataBrowserNoItem, ids.length, ids, 0) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_REMOVED); + } + int length = end - start + 1; + for (int i=0; i<length; i++) remove (start); } -/** - * Searches the receiver's list starting at the first item - * until an item is found that is equal to the argument, - * and removes that item from the list. - * - * @param string the item to remove - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void remove (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - Pair p= getPair(string); - if (p == null) error (SWT.ERROR_INVALID_ARGUMENT); - fData.remove(p); - if (OS.RemoveDataBrowserItems(handle, OS.kDataBrowserNoItem, 1, new int[] { p.fId }, 0) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_REMOVED); + 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> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void remove (int [] indices) { - checkWidget(); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); - int[] ids= getIds(indices); - if (OS.RemoveDataBrowserItems(handle, OS.kDataBrowserNoItem, ids.length, ids, 0) != OS.kNoErr) - error (SWT.ERROR_ITEM_NOT_REMOVED); + int [] newIndices = new int [indices.length]; + System.arraycopy (indices, 0, newIndices, 0, indices.length); + sort (newIndices); + int last = -1; + for (int i=0; i<newIndices.length; i++) { + int index = newIndices [i]; + if (index != last || i == 0) remove (index); + last = index; + } } -/** - * 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(); - fData.clear(); - OS.RemoveDataBrowserItems(handle, OS.kDataBrowserNoItem, 0, null, 0); + OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, 0, null, 0); + items = new String [4]; + itemCount = anchorFirst = anchorLast = 0; } -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver's selection changes. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ + public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -817,450 +532,171 @@ public void removeSelectionListener(SelectionListener listener) { eventTable.unhook(SWT.Selection, listener); eventTable.unhook(SWT.DefaultSelection,listener); } -/** - * Selects the item at the given zero-relative index in the receiver's - * list. If the item at the index was already selected, it remains - * selected. Indices that are out of range are ignored. - * - * @param index the index of the item to select - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void select (int index) { checkWidget(); - if (index == -1) return; - Pair p= (Pair) fData.get(index); - if (p != null) - OS.SetDataBrowserSelectedItems(handle, 1, new int[] { p.fId }, OS.kDataBrowserItemsAssign); + if (0 <= index && index < itemCount) { + int [] id = new int [] {index + 1}; + ignoreSelect = true; + int operation = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserItemsAssign: OS.kDataBrowserItemsAdd; + OS.SetDataBrowserSelectedItems (handle, id.length, id, operation); + ignoreSelect = false; + } } -/** - * Selects the items at the given zero-relative indices in the receiver. - * If the item at the index was already selected, it remains - * selected. The range of the indices is inclusive. Indices that are - * out of range are ignored. - * - * @param start the start of the range - * @param end the end of the range - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void select (int start, int end) { checkWidget(); - if (start > end) return; - if ((style & SWT.SINGLE) != 0) { - /* AW - int [] argList = {OS.XmNitemCount, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - int index = Math.min (argList[1] - 1, end) + 1; - if (index != 0 && index >= start) OS.XmListSelectPos (handle, index, false); - */ - return; - } - int[] ids= getIds(start, end); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsAssign); + //NOT DONE - range check + int length = end - start + 1; + if (length <= 0) return; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = end - i + 1; + ignoreSelect = true; + int operation = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserItemsAssign: OS.kDataBrowserItemsAdd; + OS.SetDataBrowserSelectedItems (handle, length, ids, operation); + ignoreSelect = false; } -/** - * Selects the items at the given zero-relative indices in the receiver. - * If the item at the given zero-relative index in the receiver - * is not selected, it is selected. If the item at the index - * was selected, it remains selected. Indices that are out - * of range and duplicate indices are ignored. - * - * @param indices the array of indices for the items to select - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void select (int [] indices) { checkWidget(); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); - if ((style & SWT.SINGLE) != 0) { - /* AW - int [] argList = {OS.XmNitemCount, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - int count = argList [1]; - for (int i = 0; i < indices.length; i++) { - int index = indices [i]; - if (0 <= index && index < count) { - select (index); - return; - } - } - */ - return; - } - int[] ids= getIds(indices); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsAssign); + //NOT DONE - range check + int length = indices.length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = indices [length - i - 1] + 1; + ignoreSelect = true; + int operation = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserItemsAssign: OS.kDataBrowserItemsAdd; + OS.SetDataBrowserSelectedItems (handle, ids.length, ids, operation); + ignoreSelect = false; } + void select (String [] items) { checkWidget(); - int[] ids= getIds(items); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsAssign); + if (items == null) error (SWT.ERROR_NULL_ARGUMENT); + //NOT DONE - range check + int length = items.length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = indexOf (items [length - i - 1]) + 1; + ignoreSelect = true; + int operation = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserItemsAssign: OS.kDataBrowserItemsAdd; + OS.SetDataBrowserSelectedItems (handle, length, ids, operation); + ignoreSelect = false; } -/** - * Selects all the items in the receiver. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void selectAll () { - checkWidget(); + checkWidget (); if ((style & SWT.SINGLE) != 0) return; - int n= fData.size(); - if (n <= 0) return; - int[] ids= getIds(0, n-1); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsAssign); + ignoreSelect = false; } -void setFocusIndex (int index) { - /* AW - OS.XmListSetKbdItemPos (handle, index + 1); - */ - System.out.println("List.setFocusIndex: nyi"); -} -/** - * Sets the text of the item in the receiver's list at the given - * zero-relative index to the string argument. This is equivalent - * to <code>remove</code>'ing the old item at the index, and then - * <code>add</code>'ing the new item at that index. - * - * @param index the index for the item - * @param string the new text for the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li> - * <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li> - * </ul> - */ + public void setItem (int index, String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - if (index == -1) error (SWT.ERROR_INVALID_RANGE); - int size= fData.size(); - if (!(0 <= index && index < size)) { - error (SWT.ERROR_INVALID_RANGE); - } - Pair p= (Pair) fData.get(index); - p.fValue= string; - OS.UpdateDataBrowserItems(handle, OS.kDataBrowserNoItem, 1, new int[] { p.fId }, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); + if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE); + int [] id = new int [] {index + 1}; + items [index] = string; + OS.UpdateDataBrowserItems (handle, OS.kDataBrowserNoItem, id.length, id, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); } -/** - * Sets the receiver's items to be the given array of items. - * - * @param items the array of items - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @exception SWTError <ul> - * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li> - * </ul> - */ + public void setItems (String [] items) { checkWidget(); if (items == null) error (SWT.ERROR_NULL_ARGUMENT); - - fData.clear(); - int count= items.length; - int[] ids= new int[count]; - for (int i= 0; i < count; i++) { - Pair p= new Pair(items[i]); - fData.add(p); - ids[i]= p.fId; - } - if (OS.AddDataBrowserItems(handle, OS.kDataBrowserNoItem, ids.length, ids, 0) != OS.kNoErr) + OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, 0, null, 0); + if (OS.AddDataBrowserItems(handle, OS.kDataBrowserNoItem, items.length, null, 0) != OS.noErr) { error (SWT.ERROR_ITEM_NOT_ADDED); + } + this.items = new String [items.length]; + System.arraycopy (items, 0, this.items, 0, items.length); + itemCount = items.length; } -/** - * Selects the item at the given zero-relative index in the receiver. - * If the item at the index was already selected, it remains selected. - * The current selected is first cleared, then the new items are selected. - * Indices that are out of range are ignored. - * - * @param index the index of the item to select - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * @see List#deselectAll() - * @see List#select(int) - */ + public void setSelection (int index) { - if ((style & SWT.MULTI) != 0) deselectAll (); - select (index); + checkWidget(); + if (0 <= index && index < itemCount) { + int [] id = new int [] {index + 1}; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, id.length, id, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + showIndex (index); + } } -/** - * Selects the items at the given zero-relative indices in the receiver. - * The current selected if first cleared, then the new items are selected. - * - * @param start the start index of the items to select - * @param end the end index of the items to select - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see Table#deselectAll() - * @see Table#select(int,int) - */ + public void setSelection (int start, int end) { - if ((style & SWT.MULTI) != 0) deselectAll (); - select (start, end); + checkWidget (); + int length = end - start + 1; + if (length <= 0) return; + int count = length; + int [] ids = new int [length]; + for (int i=start; i<=end; i++) { + if (0 <= i && i < itemCount) ids [--count] = i + 1; + } + if (count != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + if (ids.length > 0) showIndex (ids [0] - 1); } -/** - * Selects the items at the given zero-relative indices in the receiver. - * The current selection is first cleared, then the new items are selected. - * - * @param indices the indices of the items to select - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see List#deselectAll() - * @see List#select(int[]) - */ -public void setSelection(int[] indices) { - if ((style & SWT.MULTI) != 0) deselectAll (); - select (indices); + +public void setSelection (int [] indices) { + if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); + int length = indices.length; + int count = length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) { + int index = indices [i]; + if (0 <= index && index < itemCount) ids [--count] = index + 1; + } + if (count != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + if (ids.length > 0) showIndex (ids [0] - 1); } -/** - * Sets the receiver's selection to be the given array of items. - * The current selected is first cleared, then the new items are - * selected. - * - * @param items the array of items - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see List#deselectAll() - * @see List#select(int) - */ + public void setSelection (String [] items) { checkWidget(); - int[] ids= getIds(items); - OS.SetDataBrowserSelectedItems(handle, ids.length, ids, OS.kDataBrowserItemsAssign); + if (items == null) error (SWT.ERROR_NULL_ARGUMENT); + int length = items.length; + int count = length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) { + int index = indexOf (items [i]); + if (0 <= index && index < itemCount) ids [--count] = index + 1; + } + if (count != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + if (ids.length > 0) showIndex (ids [0] - 1); } -/** - * 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(); - int[] top= new int[1]; - int[] left= new int[1]; - OS.GetDataBrowserScrollPosition(handle, top, left); - top[0]= index * getItemHeight() + 4; - OS.SetDataBrowserScrollPosition(handle, top[0], left[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 IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the 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[] ids= MacUtil.getSelectionIDs(handle, OS.kDataBrowserNoItem, false); - if (ids.length > 0 && ids[0] != 0) - OS.RevealDataBrowserItem(handle, ids[0], COL_ID, false); + int [] top = new int [1], left = new int [1]; + OS.GetDataBrowserScrollPosition (handle, top, left); + top [0] = index * getItemHeight (); + OS.SetDataBrowserScrollPosition (handle, top [0], left [0]); } -//////////////////////////////////// -// Mac stuff -//////////////////////////////////// - - int processSelection (Object callData) { - //System.out.println("List.processSelection: " + getSelectionIndex()); - return super.processSelection(callData); - } - - int sendKeyEvent (int type, MacEvent mEvent, Event event) { - //processEvent (type, new MacEvent(eRefHandle)); - return OS.eventNotHandledErr; - } - - int handleItemCallback(int rowID, int colID, int item) { - - if (colID != COL_ID) { - //System.out.println("List.handleItemCallback: wrong column id: " + colID); - return OS.kNoErr; - } - - String s= get(rowID); - if (s == null) { - System.out.println("List.handleItemCallback: can't find row with id: " + rowID); - return -1; - } - - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(s); - OS.SetDataBrowserItemDataText(item, sHandle); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } - return OS.kNoErr; +void showIndex (int index) { + if (0 <= index && index < itemCount) { + short [] width = new short [1]; + OS.GetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, width); + Rect rect = new Rect (), inset = new Rect (); + OS.GetControlBounds (handle, rect); + OS.GetDataBrowserScrollBarInset (handle, inset); + OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short)(rect.right - rect.left - inset.left - inset.right)); + OS.RevealDataBrowserItem (handle, index + 1, COLUMN_ID, (byte) OS.kDataBrowserRevealWithoutSelecting); + OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short)width [0]); } +} - int handleCompareCallback(int item1ID, int item2ID, int item) { - if (getIndex(item1ID) < getIndex(item2ID)) - return 1; - return 0; - } - - int handleItemNotificationCallback(int item, int message) { - return OS.kNoErr; - } - - /** - * Returns string value of row with the given ID - */ - private String get(int id) { - Iterator iter= fData.iterator(); - while (iter.hasNext()) { - Pair p= (Pair) iter.next(); - if (p.fId == id) - return p.fValue; - } - return null; - } +public void showSelection () { + checkWidget(); + int index = getSelectionIndex (); + if (index >= 0) showIndex (index); +} - /** - * Returns the index of row with the given ID - */ - private int getIndex(int id) { - Iterator iter= fData.iterator(); - for (int i= 0; iter.hasNext(); i++) { - Pair p= (Pair) iter.next(); - if (p.fId == id) - return i; - } - return -1; - } - - /** - * Returns the index of the first row that matches the given string - */ - private int getIndex(String s, int start) { - if (s == null) error (SWT.ERROR_NULL_ARGUMENT); - int n= fData.size(); - for (int i= start; i < n; i++) { - Pair p= (Pair) fData.get(i); - if (s.equals(p.fValue)) - return i; - } - return -1; - } - - /** - * Returns the ID of the first row that matches the given string - */ - private Pair getPair(String s) { - Iterator iter= fData.iterator(); - while (iter.hasNext()) { - Pair p= (Pair) iter.next(); - if (s.equals(p.fValue)) - return p; - } - return null; - } - - /** - * Returns the ID of the first row that matches the given string - */ - private int getID(String s) { - Iterator iter= fData.iterator(); - while (iter.hasNext()) { - Pair p= (Pair) iter.next(); - if (s.equals(p.fValue)) - return p.fId; - } - return 0; - } - - private int[] getIds(int[] indices) { - int count= fData.size(); - int[] ids= new int[indices.length]; - for (int i= 0; i < indices.length; i++) { - int index= indices[i]; - if (!(0 <= index && index < count)) break; - Pair p= (Pair) fData.get(index); - ids[i]= p.fId; - } - return ids; - } - - private int[] getIds(String[] items) { - int count= items.length; - int[] ids= new int[count]; - for (int i=0; i<count; i++) { - int id= getID(items[i]); - ids[i]= id; - } - return ids; - } - - private int[] getIds(int start, int end) { - int n= fData.size(); - if (start < 0 && start >= n) - error (SWT.ERROR_INVALID_RANGE); - if (end >= n) - error (SWT.ERROR_INVALID_RANGE); - int count= end-start+1; - int[] ids= new int[count]; - for (int i= 0; i < count; i++) { - Pair p= (Pair) fData.get(start+i); - ids[i]= p.fId; - } - return ids; - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java index a18b206563..396e1dd8ef 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java @@ -11,189 +11,32 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.internal.carbon.*; -/** - * Instances of this class are user interface objects that contain - * menu items. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>BAR, DROP_DOWN, POP_UP</dd> - * <dt><b>Events:</b></dt> - * <dd>Help, Hide, Show </dd> - * </dl> - * <p> - * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified. - * </p><p> - * IMPORTANT: This class is <em>not</em> intended to be subclassed. - * </p> - */ public class Menu extends Widget { + int handle; + short id, lastIndex; int x, y; - short lastIndex; boolean hasLocation; MenuItem cascade, defaultItem; Decorations parent; -/** - * 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. - * - * @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).getShell (), SWT.POP_UP); } -/** - * Constructs a new instance of this class given its parent - * (which must be a <code>Decorations</code>) and a style value - * 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 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 Widget#checkSubclass - * @see Widget#getStyle - */ public Menu (Decorations parent, int style) { super (parent, checkStyle (style)); this.parent = parent; createWidget (); } -/** - * 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. - * - * @param parent 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. - * - * @param parent 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); } -/** - * 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); -} - static Control checkNull (Control control) { if (control == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); return control; @@ -213,119 +56,97 @@ static int checkStyle (int style) { return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0); } +public void _setVisible (boolean visible) { + if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return; + if (!visible) return; + int left = x, top = y; + if (!hasLocation) { + org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point (); + OS.GetGlobalMouse (where); + left = where.h; top = where.v; + } + int index = defaultItem != null ? indexOf (defaultItem) + 1 : lastIndex; + int result = OS.PopUpMenuSelect (handle, (short)top, (short)left, (short)(index)); + lastIndex = OS.LoWord (result); +} + +public void addHelpListener (HelpListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Help, typedListener); +} + +public void 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 () { - state |= HIDDEN; - Display display= getDisplay(); - int menuHandle[]= new int[1]; - if (OS.CreateNewMenu(display.nextMenuId(), 0, menuHandle) == OS.kNoErr) - handle= menuHandle[0]; - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - OS.RetainMenu(handle); - int[] mask = new int[] { - OS.kEventClassMenu, OS.kEventMenuOpening, - OS.kEventClassMenu, OS.kEventMenuClosed - }; - //OS.InstallEventHandler(OS.GetMenuEventTarget(handle), display.fMenuProc, mask.length / 2, mask, handle, null); - OS.InstallEventHandler(OS.GetMenuEventTarget(handle), display.fMenuProc, mask, handle); + Display display = getDisplay (); + int menuProc = display.menuProc; + display.addMenu (this); + int outMenuRef [] = new int [1]; + OS.CreateNewMenu (id, 0, outMenuRef); + if (outMenuRef [0] == 0) { + display.removeMenu (this); + error (SWT.ERROR_NO_HANDLES); + } + handle = outMenuRef [0]; } void createItem (MenuItem item, int index) { checkWidget (); int count = OS.CountMenuItems (handle); if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE); - parent.add (item); - boolean success = false; - /* - if (OS.IsWinCE) { - int flags = OS.MF_BYPOSITION; - if ((style & SWT.SEPARATOR) != 0) flags |= OS.MF_SEPARATOR; - success = OS.InsertMenu (handle, index, flags, item.id, null); - } else { - int hHeap = OS.GetProcessHeap (); - int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof); - MENUITEMINFO info = new MENUITEMINFO (); - info.cbSize = MENUITEMINFO.sizeof; - info.fMask = OS.MIIM_ID | OS.MIIM_TYPE; - info.wID = item.id; - info.fType = item.widgetStyle (); - info.dwTypeData = pszText; - success = OS.InsertMenuItem (handle, index, true, info); - if (pszText != 0) OS.HeapFree (hHeap, 0, pszText); - } - */ - - /* - if ((style & SWT.SEPARATOR) != 0) return OS.MFT_SEPARATOR; - if ((style & SWT.RADIO) != 0) return OS.MFT_RADIOCHECK; - return OS.MFT_STRING; - */ - - int attributes= 0; - if ((item.style & SWT.SEPARATOR) != 0) - attributes= OS.kMenuItemAttrSeparator; - if (OS.InsertMenuItemTextWithCFString(handle, 0, (short) index, attributes, item.id) == OS.kNoErr) - success= true; - - if (!success) { - parent.remove (item); + Display display = getDisplay (); + display.addMenuItem (item); + int attributes = 0; + if ((item.style & SWT.SEPARATOR) != 0) attributes = OS.kMenuItemAttrSeparator; + int result = OS.InsertMenuItemTextWithCFString (handle, 0, (short) index, attributes, item.id); + if (result != OS.noErr) { + display.removeMenuItem (item); error (SWT.ERROR_ITEM_NOT_ADDED); } - /* AW - redraw (); - */ -} - -void createWidget () { - createHandle (); - parent.add (this); - register (); -} - -void destroyAcceleratorTable () { - /* AW - parent.destroyAcceleratorTable (); - */ + if ((style & SWT.BAR) != 0) { +// Display display = getDisplay (); +// short menuID = display.nextMenuId (); +// int outMenuRef [] = new int [1]; +// if (OS.CreateNewMenu (menuID, 0, outMenuRef) != OS.noErr) { +// error (SWT.ERROR_NO_HANDLES); +// } +// OS.SetMenuItemHierarchicalMenu (handle, (short) (index + 1), outMenuRef [0]); + } } void destroyItem (MenuItem item) { - /* AW - if (!OS.RemoveMenu (handle, item.id, OS.MF_BYCOMMAND)) { + short [] outIndex = new short [1]; + if (OS.GetIndMenuItemWithCommandID (handle, item.id, 1, null, outIndex) != OS.noErr) { error (SWT.ERROR_ITEM_NOT_REMOVED); } - */ - short[] index= new short[1]; - OS.GetIndMenuItemWithCommandID(handle, item.id, 1, null, index); - if (index[0] >= 1) { - OS.DeleteMenuItem(handle, index[0]); - } else - error (SWT.ERROR_ITEM_NOT_REMOVED); - - redraw (); + if ((style & SWT.BAR) != 0) { +// int [] outMenuRef = new int [1]; +// OS.GetMenuItemHierarchicalMenu (handle, outIndex [0], outMenuRef); +// if (outMenuRef [0] != 0) { +// OS.DeleteMenu (OS.GetMenuID (outMenuRef [0])); +// OS.DisposeMenu (outMenuRef [0]); +// } + } + OS.DeleteMenuItem (handle, outIndex [0]); } void destroyWidget () { - int hMenu = handle; + int theMenu = handle; releaseHandle (); - if (hMenu != 0) { - /* AW - OS.DestroyMenu (hMenu); - */ - OS.DisposeMenu (hMenu); + if (theMenu != 0) { + OS.DeleteMenu (OS.GetMenuID (theMenu)); + OS.DisposeMenu (theMenu); } } -/** - * 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; @@ -337,107 +158,39 @@ public Display getDisplay () { return parent.getDisplay (); } -/** - * Returns <code>true</code> if the receiver is enabled, and - * <code>false</code> otherwise. A disabled control is typically - * not selectable from the user interface and draws with an - * inactive or "grayed" look. - * - * @return the receiver's enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public boolean getEnabled () { - checkWidget (); - /* AW + checkWidget(); return (state & DISABLED) == 0; - */ - return OS.IsMenuItemEnabled(handle, (short)0); -} - -/** - * Returns the item at the given, zero-relative index in the - * receiver. Throws an exception if the index is out of range. - * - * @param index the index of the item to return - * @return the item at the given index - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ +} + public MenuItem getItem (int index) { checkWidget (); - int[] commandID= new int[1]; - if (OS.GetMenuItemCommandID(handle, (short)(index+1), commandID) != OS.kNoErr) + int [] outCommandID= new int [1]; + if (OS.GetMenuItemCommandID (handle, (short)(index+1), outCommandID) != OS.noErr) { error (SWT.ERROR_INVALID_RANGE); - return parent.findMenuItem (commandID[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> - */ + } + Display display = getDisplay (); + return display.findMenuItem (outCommandID[0]); +} + public int getItemCount () { checkWidget (); return OS.CountMenuItems (handle); } -/** - * Returns an array of <code>MenuItem</code>s which are the items - * in the receiver. - * <p> - * Note: This is not the actual structure used by the receiver - * to maintain its list of items, so modifying the array will - * not affect the receiver. - * </p> - * - * @return the items in the receiver - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public MenuItem [] getItems () { checkWidget (); - int index = 0; - int length = OS.CountMenuItems(handle); + Display display = getDisplay (); + int length = OS.CountMenuItems (handle); MenuItem [] items = new MenuItem [length]; - /* AW - MENUITEMINFO info = new MENUITEMINFO (); - info.cbSize = MENUITEMINFO.sizeof; - info.fMask = OS.MIIM_ID; - while (OS.GetMenuItemInfo (handle, index, true, info)) { - */ - int[] commandID= new int[1]; - while (OS.GetMenuItemCommandID(handle, (short)(index+1), commandID) == OS.kNoErr) { - if (index == items.length) { - MenuItem [] newItems = new MenuItem [index + 4]; - System.arraycopy (newItems, 0, items, 0, index); - items = newItems; + int [] outCommandID= new int [1]; + for (int i=0; i<items.length; i++) { + if (OS.GetMenuItemCommandID (handle, (short)(i+1), outCommandID) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_ITEM); } - items [index] = parent.findMenuItem (commandID [0]); - if (items [index] != null) - index++; + items [i] = display.findMenuItem (outCommandID [0]); } - if (index == items.length) return items; - MenuItem [] result = new MenuItem [index]; - System.arraycopy (result, 0, items, 0, index); - return result; + return items; } String getNameText () { @@ -453,157 +206,77 @@ String 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 (); } -/** - * Returns <code>true</code> if the receiver is visible, and - * <code>false</code> otherwise. - * <p> - * If one of the receiver's ancestors is not visible or some - * other condition makes the receiver not visible, this method - * may still indicate that it is considered visible even though - * it may not actually be showing. - * </p> - * - * @return the receiver's visibility state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public boolean getVisible () { checkWidget (); if ((style & SWT.BAR) != 0) { return this == parent.menuShell ().menuBar; } - return (state & HIDDEN) == 0; -} - -/** - * Searches the receiver's list starting at the first item - * (index 0) until an item is found that is equal to the - * argument, and returns the index of that item. If no item - * is found, returns -1. - * - * @param item the search item - * @return the index of the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the 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> - */ + if ((style & SWT.POP_UP) != 0) { + Display display = getDisplay (); + Menu [] popups = display.popups; + if (popups == null) return false; + for (int i=0; i<popups.length; i++) { + if (popups [i] == this) return true; + } + } + MenuTrackingData outData = new MenuTrackingData (); + return OS.GetMenuTrackingData (handle, outData) == OS.noErr; +} + +void hookEvents () { + super.hookEvents (); + Display display = getDisplay (); + int menuProc = display.menuProc; + int [] mask = new int [] { + OS.kEventClassMenu, OS.kEventMenuOpening, + OS.kEventClassMenu, OS.kEventMenuClosed, + }; + int menuTarget = OS.GetMenuEventTarget (handle); + OS.InstallEventHandler (menuTarget, menuProc, mask.length / 2, mask, 0, null); +} + +int kEventMenuClosed (int nextHandler, int theEvent, int userData) { + sendEvent (SWT.Hide); + return OS.eventNotHandledErr; +} + +int kEventMenuOpening (int nextHandler, int theEvent, int userData) { + sendEvent (SWT.Show); + return OS.eventNotHandledErr; +} + public int indexOf (MenuItem item) { checkWidget (); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); - - /* AW - int index = 0; - MENUITEMINFO info = new MENUITEMINFO (); - info.cbSize = MENUITEMINFO.sizeof; - info.fMask = OS.MIIM_ID; - while (OS.GetMenuItemInfo (handle, index, true, info)) { - if (info.wID == item.id) return index; - index++; - } - */ - - int[] menu= new int[1]; - short[] index= new short[1]; - if (OS.GetIndMenuItemWithCommandID(handle, item.id, 1, menu, index) == OS.kNoErr) { - if (handle == menu[0]) // ensure that we found item not in submenu - return index[0]; - } + int [] outMenu = new int [1]; + short [] outIndex = new short [1]; + if (OS.GetIndMenuItemWithCommandID (handle, item.id, 1, outMenu, outIndex) == OS.noErr) { + return handle == outMenu [0] ? outIndex [0] - 1 : 0; + } return -1; } -/** - * Returns <code>true</code> if the receiver is enabled and all - * of the receiver's ancestors are enabled, and <code>false</code> - * otherwise. A disabled control is typically not selectable from the - * user interface and draws with an inactive or "grayed" look. - * - * @return the receiver's enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #getEnabled - */ public boolean isEnabled () { checkWidget (); Menu parentMenu = getParentMenu (); @@ -611,72 +284,11 @@ public boolean 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 processHide (Object callData) { - //sendEvent (SWT.Hide); - state |= HIDDEN; - postEvent (SWT.Hide); // fix for #23947 - return 0; -} - -int processShow (Object callData) { - state &= ~HIDDEN; - sendEvent (SWT.Show); - return 0; -} - -void redraw () { - if ((style & SWT.BAR) != 0) { - //AW OS.DrawMenuBar (parent.handle); - return; - } - /* AW - if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) { - return; - } - boolean hasCheck = false, hasImage = false; - MenuItem [] items = getItems (); - for (int i=0; i<items.length; i++) { - MenuItem item = items [i]; - if (item.getImage () != null) { - if ((hasImage = true) && hasCheck) break; - } - if ((item.getStyle () & (SWT.CHECK | SWT.RADIO)) != 0) { - if ((hasCheck = true) && hasImage) break; - } - } - if (OS.IsWinCE) return; - MENUINFO lpcmi = new MENUINFO (); - lpcmi.cbSize = MENUINFO.sizeof; - lpcmi.fMask = OS.MIM_STYLE; - OS.GetMenuInfo (handle, lpcmi); - if (hasImage && !hasCheck) { - lpcmi.dwStyle |= OS.MNS_CHECKORBMP; - } else { - lpcmi.dwStyle &= ~OS.MNS_CHECKORBMP; - } - OS.SetMenuInfo (handle, lpcmi); - */ -} - void releaseChild () { super.releaseChild (); if (cascade != null) cascade.setMenu (null); @@ -689,34 +301,15 @@ void releaseWidget () { MenuItem [] items = getItems (); for (int i=0; i<items.length; i++) { MenuItem item = items [i]; - if (!item.isDisposed ()) { - item.releaseWidget (); - item.releaseHandle (); - } + if (!item.isDisposed ()) item.releaseResources (); } super.releaseWidget (); - if (parent != null) parent.remove (this); + Display display = getDisplay (); + display.removeMenu (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 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); @@ -724,23 +317,6 @@ public void removeHelpListener (HelpListener listener) { eventTable.unhook (SWT.Help, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when the menu events are generated for the control. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see MenuListener - * @see #addMenuListener - */ public void removeMenuListener (MenuListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -749,117 +325,40 @@ public void removeMenuListener (MenuListener 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 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 (); - /* AW - state &= ~DISABLED; - if (!enabled) state |= DISABLED; - */ - if (enabled) - OS.EnableMenuItem(handle, (short)0); - else - OS.DisableMenuItem(handle, (short)0); -} - -/** - * Sets the receiver's location to the point specified by - * the arguments which are relative to the display. - * <p> - * Note: This is different from most widgets where the - * location of the widget is relative to the parent. - * </p> - * - * @param x the new x coordinate for the receiver - * @param y the new y coordinate for the receiver - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + checkWidget(); + if (enabled) { + state &= ~DISABLED; + OS.EnableMenuItem (handle, (short)0); + } else { + state |= DISABLED; + OS.DisableMenuItem (handle, (short)0); + } +} + public void setLocation (int x, int y) { checkWidget (); - this.x = x; this.y = y; + this.x = x; + this.y = y; hasLocation = true; } -/** - * Marks the receiver as visible if the argument is <code>true</code>, - * and marks it invisible otherwise. - * <p> - * If one of the receiver's ancestors is not visible or some - * other condition makes the receiver not visible, marking - * it visible may not actually cause it to be displayed. - * </p> - * - * @param visible the new visibility state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public void setVisible (boolean visible) { checkWidget (); if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return; - if (!visible) return; - int nX = x, nY = y; - if (!hasLocation) { - MacPoint where= new MacPoint(); - OS.GetGlobalMouse (where.getData()); - nX = where.getX(); nY = where.getY(); + Display display = getDisplay (); + if (visible) { + display.addPopup (this); + } else { + display.removePopup (this); + _setVisible (false); } - int index = defaultItem != null ? indexOf (defaultItem) + 1 : lastIndex; - Display d= getDisplay(); - d.fInContextMenu= true; - int result = OS.PopUpMenuSelect (handle, (short)nY, (short)nX, (short)(index)); - d.fInContextMenu= false; - lastIndex = OS.LoWord (result); } -/////////////////////////////////////////////////// -// Mac stuff -/////////////////////////////////////////////////// - - void handleMenu(int menuResult) { - int index= OS.LoWord(menuResult)-1; - if (index >= 0 && index < getItemCount()) { - MenuItem item= getItem(index); - if (item != null) - item.handleMenuSelect(); - } - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java index 4a16a206c6..1bfba74015 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java @@ -12,127 +12,36 @@ import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; import org.eclipse.swt.internal.carbon.*; -/** - * 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> - */ public class MenuItem extends Item { Menu parent, menu; int id, accelerator; - int cIconHandle; - -/** - * 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; parent.createItem (this, parent.getItemCount ()); } -/** - * Constructs a new instance of this class given its parent - * (which must be a <code>Menu</code>), a style value - * describing its behavior and appearance, and the index - * at which to place it in the items maintained by its parent. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * 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 index to store the receiver in its parent - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - * - * @see SWT#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; parent.createItem (this, index); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the arm events are generated for the control, by sending - * it one of the messages defined in the <code>ArmListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ArmListener - * @see #removeArmListener - */ +public void _setEnabled (boolean enabled) { + short [] outIndex = new short [1]; + OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex); + int outMenuRef [] = new int [1]; + OS.GetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outMenuRef); + if (enabled) { + if (outMenuRef [0] != 0) OS.EnableMenuItem (outMenuRef [0], (short) 0); + OS.EnableMenuCommand (parent.handle, id); + } else { + if (outMenuRef [0] != 0) OS.DisableMenuItem (outMenuRef [0], (short) 0); + OS.DisableMenuCommand (parent.handle, id); + } +} + public void addArmListener (ArmListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -140,25 +49,6 @@ public void addArmListener (ArmListener 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); @@ -166,30 +56,6 @@ public void addHelpListener (HelpListener listener) { addListener (SWT.Help, typedListener); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the control is selected, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * 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 - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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); @@ -206,19 +72,6 @@ static int checkStyle (int style) { return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0); } -/** - * Return the widget accelerator. An accelerator is the bit-wise - * OR of zero or more modifier masks and a key. Examples: - * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>. - * - * @return the accelerator - * - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public int getAccelerator () { checkWidget (); return accelerator; @@ -230,38 +83,11 @@ public Display getDisplay () { return parent.getDisplay (); } -/** - * Returns <code>true</code> if the receiver is enabled, and - * <code>false</code> otherwise. A disabled control is typically - * not selectable from the user interface and draws with an - * inactive or "grayed" look. - * - * @return the receiver's enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public boolean getEnabled () { - checkWidget (); - return OS.IsMenuCommandEnabled (parent.handle, id); -} - -/** - * 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> - */ + checkWidget(); + return (state & DISABLED) == 0; +} + public Menu getMenu () { checkWidget (); return menu; @@ -272,46 +98,22 @@ String getNameText () { 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)) == 0) return false; char [] outMark = new char [1]; - if (OS.GetMenuCommandMark (parent.handle, id, outMark) != OS.kNoErr) { + if (OS.GetMenuCommandMark (parent.handle, id, outMark) != OS.noErr) { error (SWT.ERROR_CANNOT_GET_SELECTION); } return outMark [0] != 0; } -void handleMenuSelect () { +int kEventProcessCommand (int nextHandler, int theEvent, int userData) { if ((style & SWT.CHECK) != 0) { setSelection (!getSelection ()); } else { @@ -323,33 +125,14 @@ void handleMenuSelect () { } } } + int [] modifiers = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers); Event event = new Event (); - /* AW - if (OS.GetKeyState (OS.VK_MENU) < 0) event.stateMask |= SWT.ALT; - if (OS.GetKeyState (OS.VK_SHIFT) < 0) event.stateMask |= SWT.SHIFT; - if (OS.GetKeyState (OS.VK_CONTROL) < 0) event.stateMask |= SWT.CONTROL; - if (OS.GetKeyState (OS.VK_LBUTTON) < 0) event.stateMask |= SWT.BUTTON1; - if (OS.GetKeyState (OS.VK_MBUTTON) < 0) event.stateMask |= SWT.BUTTON2; - if (OS.GetKeyState (OS.VK_RBUTTON) < 0) event.stateMask |= SWT.BUTTON3; - */ + setInputState (event, (short) 0, OS.GetCurrentEventButtonState (), modifiers [0]); postEvent (SWT.Selection, event); + return OS.noErr; } -/** - * Returns <code>true</code> if the receiver is enabled and all - * of the receiver's ancestors are enabled, and <code>false</code> - * otherwise. A disabled control is typically not selectable from the - * user interface and draws with an inactive or "grayed" look. - * - * @return the receiver's enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #getEnabled - */ public boolean isEnabled () { return getEnabled () && parent.isEnabled (); } @@ -400,40 +183,29 @@ void releaseChild () { void releaseWidget () { if (menu != null) { menu.releaseWidget (); - menu.releaseHandle (); + menu.destroyWidget (); + } else { + if ((parent.style & SWT.BAR) != 0) { +// short [] outIndex = new short [1]; +// if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) == OS.noErr) { +// int [] outMenuRef = new int [1]; +// OS.GetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outMenuRef); +// if (outMenuRef [0] != 0) { +// OS.DeleteMenu (OS.GetMenuID (outMenuRef [0])); +// OS.DisposeMenu (outMenuRef [0]); +// } +// } + } } menu = null; super.releaseWidget (); accelerator = 0; - if (this == parent.defaultItem) { - parent.defaultItem = null; - } - Decorations shell = parent.parent; - shell.remove (this); + if (this == parent.defaultItem) parent.defaultItem = null; + Display display = getDisplay (); + display.removeMenuItem (this); parent = null; - if (cIconHandle != 0) { - Image.disposeCIcon (cIconHandle); - cIconHandle = 0; - } -} - -/** - * Removes the listener from the collection of listeners who will - * be notified when the arm events are generated for the control. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ArmListener - * @see #addArmListener - */ +} + public void removeArmListener (ArmListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -441,23 +213,6 @@ public void removeArmListener (ArmListener listener) { eventTable.unhook (SWT.Arm, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when the help events are generated for the control. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see HelpListener - * @see #addHelpListener - */ public void removeHelpListener (HelpListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -465,23 +220,6 @@ public void removeHelpListener (HelpListener listener) { eventTable.unhook (SWT.Help, listener); } -/** - * Removes the listener from the collection of listeners who will - * be notified when the control is selected. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ public void removeSelectionListener (SelectionListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -501,23 +239,10 @@ void selectRadio () { 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.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>. - * - * @param accelerator an integer that is the bit-wise OR of masks and a key - * - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public void setAccelerator (int accelerator) { checkWidget (); short [] outIndex = new short [1]; - if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.kNoErr) { + if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.noErr) { return; } boolean update = (this.accelerator == 0 && accelerator != 0) || (this.accelerator != 0 && accelerator == 0); @@ -526,10 +251,6 @@ public void setAccelerator (int accelerator) { int inModifiers = OS.kMenuNoModifiers, inGlyph = OS.kMenuNullGlyph, inKey = 0; if (accelerator != 0) { inKey = accelerator & ~(SWT.SHIFT | SWT.CONTROL | SWT.ALT | SWT.COMMAND); - if (MacUtil.KEEP_MAC_SHORTCUTS) { - if ((accelerator & SWT.COMMAND) != 0) - if (inKey == 'H' || inKey == 'Q') return; - } inGlyph = keyGlyph (inKey); int virtualKey = Display.untranslateKey (inKey); if (inKey == ' ') virtualKey = 49; @@ -551,81 +272,27 @@ public void setAccelerator (int accelerator) { if (update) updateText (); } -/** - * 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 (); - short [] outIndex = new short [1]; - OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex); - int outMenuRef [] = new int [1]; - OS.GetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outMenuRef); if (enabled) { - if (outMenuRef [0] != 0) OS.EnableMenuItem (outMenuRef [0], (short) 0); - OS.EnableMenuCommand (parent.handle, id); + state &= ~DISABLED; } else { - if (outMenuRef [0] != 0) OS.DisableMenuItem (outMenuRef [0], (short) 0); - OS.DisableMenuCommand (parent.handle, id); + state |= DISABLED; } + _setEnabled (enabled); } -/** - * Sets the image the receiver will display to the argument. - * <p> - * Note: This feature is not available on all window systems (for example, Window NT), - * in which case, calling this method will silently do nothing. - * - * @param menu 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; super.setImage (image); - if (cIconHandle != 0) Image.disposeCIcon (cIconHandle); - cIconHandle = Image.carbon_createCIcon (image); - if (cIconHandle != 0) { - short [] outIndex = new short[1]; - if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) == OS.kNoErr) { - OS.SetMenuItemIconHandle (parent.handle, outIndex [0], (byte)4, cIconHandle); - } - } + short [] outIndex = new short [1]; + if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.noErr) return; + int imageHandle = image != null ? image.handle : 0; + byte type = image != null ? (byte)OS.kMenuCGImageRefType : (byte)OS.kMenuNoIcon; + OS.SetMenuItemIconHandle (parent.handle, outIndex [0], type, imageHandle); } -/** - * 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. - * - * @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 (); @@ -644,25 +311,47 @@ public void setMenu (Menu menu) { } /* Assign the new menu */ - if (this.menu == menu) return; - if (this.menu != null) this.menu.cascade = null; + Menu oldMenu = this.menu; + if (oldMenu == menu) return; + if (oldMenu != null) oldMenu.cascade = null; + this.menu = menu; + + /* Update the menu in the OS */ short [] outIndex = new short [1]; - if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.kNoErr) { - error (SWT.ERROR_CANNOT_SET_MENU); - } - int inHierMenu = menu != null ? menu.handle : 0; - if (OS.SetMenuItemHierarchicalMenu (parent.handle, outIndex [0], inHierMenu) != OS.kNoErr) { + if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.noErr) { error (SWT.ERROR_CANNOT_SET_MENU); } - if ((this.menu = menu) != null) { + int outMenuRef [] = new int [1]; + if (menu == null) { + if ((parent.style & SWT.BAR) != 0) { +// Display display = getDisplay (); +// short menuID = display.nextMenuId (); +// if (OS.CreateNewMenu (menuID, 0, outMenuRef) != OS.noErr) { +// error (SWT.ERROR_NO_HANDLES); +// } + } + } else { menu.cascade = this; + if ((parent.style & SWT.BAR) != 0) { + if (oldMenu == null) { +// OS.GetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outMenuRef); +// if (outMenuRef [0] != 0) { +// OS.DeleteMenu (OS.GetMenuID (outMenuRef [0])); +// OS.DisposeMenu (outMenuRef [0]); +// } + } + } + outMenuRef [0] = menu.handle; int [] outString = new int [1]; - if (OS.CopyMenuItemTextAsCFString (parent.handle, outIndex [0], outString) != OS.kNoErr) { + if (OS.CopyMenuItemTextAsCFString (parent.handle, outIndex [0], outString) != OS.noErr) { error (SWT.ERROR_CANNOT_SET_MENU); } - OS.SetMenuTitleWithCFString (inHierMenu, outString [0]); + OS.SetMenuTitleWithCFString (outMenuRef [0], outString [0]); OS.CFRelease (outString [0]); } + if (OS.SetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outMenuRef [0]) != OS.noErr) { + error (SWT.ERROR_CANNOT_SET_MENU); + } } boolean setRadioSelection (boolean value) { @@ -674,24 +363,11 @@ boolean setRadioSelection (boolean value) { 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)) == 0) return; int inMark = selected ? ((style & SWT.RADIO) != 0) ? OS.diamondMark : OS.checkMark : 0; - if (OS.SetMenuCommandMark (parent.handle, id, (char) inMark) != OS.kNoErr) { + if (OS.SetMenuCommandMark (parent.handle, id, (char) inMark) != OS.noErr) { error (SWT.ERROR_CANNOT_SET_SELECTION); } } @@ -707,7 +383,7 @@ public void setText (String string) { void updateText () { if ((style & SWT.SEPARATOR) != 0) return; short [] outIndex = new short [1]; - if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.kNoErr) { + if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.noErr) { error (SWT.ERROR_CANNOT_SET_TEXT); } char [] buffer = new char [text.length ()]; @@ -721,8 +397,7 @@ void updateText () { j--; } } - //int str = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); - int str = OS.CFStringCreateWithCharacters (new String(buffer, 0, j)); + int str = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); if (str == 0) error (SWT.ERROR_CANNOT_SET_TEXT); OS.SetMenuItemTextWithCFString (parent.handle, outIndex [0], str); int [] outHierMenu = new int [1]; @@ -731,3 +406,4 @@ void updateText () { OS.CFRelease (str); } } + diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MessageBox.java index 15e2f30edf..1fe7f41ebc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MessageBox.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MessageBox.java @@ -11,87 +11,17 @@ import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.internal.carbon.*; -/** - * Instances of this class are used used to inform or warn the user. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING</dd> - * <dd>OK, OK | CANCEL</dd> - * <dd>YES | NO, YES | NO | CANCEL</dd> - * <dd>RETRY | CANCEL</dd> - * <dd>ABORT | RETRY | IGNORE</dd> - * <dt><b>Events:</b></dt> - * <dd>(none)</dd> - * </dl> - * <p> - * 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> - */ public class MessageBox extends Dialog { String message = ""; -/** - * Constructs a new instance of this class given only its - * parent. - * <p> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ + public MessageBox (Shell parent) { this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL); } -/** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * lists the style constants that are applicable to the class. - * Style bits are also inherited from superclasses. - * </p> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the dialog on the currently active - * display if there is one. If there is no current display, the - * dialog is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ public MessageBox (Shell parent, int style) { super (parent, checkStyle (style)); + checkSubclass (); } static int checkStyle (int style) { @@ -105,179 +35,141 @@ static int checkStyle (int style) { return style; } -/** - * Returns the dialog's message, which is a description of - * the purpose for which it was opened. This message will be - * visible on the dialog while it is open. - * - * @return the message - */ public String getMessage () { return message; } -/** - * Makes the dialog visible and brings it to the front - * of the display. - * - * @return the ID of the button that was selected to dismiss the - * message box (e.g. SWT.OK, SWT.CANCEL, etc...) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li> - * </ul> - */ -public int open () { - - /* Compute the MessageBox style */ - /* AW - int buttonBits = 0; - if ((style & SWT.OK) == SWT.OK) buttonBits = OS.MB_OK; - if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) buttonBits = OS.MB_OKCANCEL; - if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) buttonBits = OS.MB_YESNO; - if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) buttonBits = OS.MB_YESNOCANCEL; - if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) buttonBits = OS.MB_RETRYCANCEL; - if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) buttonBits = OS.MB_ABORTRETRYIGNORE; - if (buttonBits == 0) buttonBits = OS.MB_OK; - - 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 modalBits = 0; - if ((style & SWT.PRIMARY_MODAL) != 0) modalBits = OS.MB_APPLMODAL; - if ((style & SWT.APPLICATION_MODAL) != 0) modalBits = OS.MB_TASKMODAL; - if ((style & SWT.SYSTEM_MODAL) != 0) modalBits = OS.MB_SYSTEMMODAL; - - int bits = buttonBits | iconBits | modalBits; - */ - - short alertType; - if ((style & SWT.ICON_ERROR) != 0) - alertType= OS.kAlertStopAlert; - else if ((style & SWT.ICON_INFORMATION) != 0) - alertType= OS.kAlertNoteAlert; - else if ((style & SWT.ICON_QUESTION) != 0) - alertType= OS.kAlertNoteAlert; - else if ((style & SWT.ICON_WARNING) != 0) - alertType= OS.kAlertCautionAlert; - else if ((style & SWT.ICON_WORKING) != 0) - alertType= OS.kAlertNoteAlert; - else - alertType= OS.kAlertPlainAlert; +int getCFString (String id) { + String string = SWT.getMessage(id); + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + return OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); +} +public int open () { + short alertType = OS.kAlertPlainAlert; + if ((style & SWT.ICON_ERROR) != 0) alertType = OS.kAlertStopAlert; + if ((style & SWT.ICON_INFORMATION) != 0) alertType = OS.kAlertNoteAlert; + if ((style & SWT.ICON_QUESTION) != 0) alertType = OS.kAlertNoteAlert; + if ((style & SWT.ICON_WARNING) != 0) alertType = OS.kAlertCautionAlert; + if ((style & SWT.ICON_WORKING) != 0) alertType = OS.kAlertNoteAlert; - /* - * Feature in Windows. System modal is not supported - * on Windows 95 and NT. The fix is to convert system - * modal to task modal. - */ - /* AW - if ((bits & OS.MB_SYSTEMMODAL) != 0) { - bits |= OS.MB_TASKMODAL; - bits &= ~OS.MB_SYSTEMMODAL; + int error = 0; + int explanation = 0; + String errorString = (title != "") ? title : ((message != "") ? message : null); + String explanationString = (title == "") ? null : ((message != "") ? message : null); + if (errorString != null) { + char [] buffer = new char [errorString.length ()]; + errorString.getChars (0, buffer.length, buffer, 0); + error = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + } + if (explanationString != null) { + char [] buffer = new char [explanationString.length ()]; + explanationString.getChars (0, buffer.length, buffer, 0); + explanation = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); } - */ - - /* - * Bug in Windows. In order for MB_TASKMODAL to work, - * the parent HWND of the MessageBox () call must be NULL. - * The fix is to force the parent to be NULL when this - * style is set. - */ - /* AW - int hwndOwner = 0; - if (parent != null && (bits & OS.MB_TASKMODAL) == 0) { - hwndOwner = parent.handle; - } - */ - - /* - * Feature in Windows. The focus window is not saved and - * and restored automatically by the call to MessageBox(). - * The fix is to save and restore the focus window. - */ - /* AW - int hwndFocus = OS.GetFocus (); - */ - - /* Open the message box */ - /* Use the character encoding for the default locale */ - /* AW - TCHAR buffer1 = new TCHAR (0, message, true); - TCHAR buffer2 = new TCHAR (0, title, true); - int code = OS.MessageBox (hwndOwner, buffer1, buffer2, bits); - */ - int errorMessage= 0; - int[] dialogRef= new int[1]; - try { - errorMessage= OS.CFStringCreateWithCharacters(message); - OS.CreateStandardAlert(alertType, errorMessage, 0, 0, dialogRef); - } finally { - if (errorMessage != 0) - OS.CFRelease(errorMessage); + AlertStdCFStringAlertParamRec param = new AlertStdCFStringAlertParamRec (); + param.version = OS.kStdCFStringAlertVersionOne; + param.position = (short)OS.kWindowAlertPositionParentWindowScreen; + int defaultStr = 0, cancelStr = 0, otherStr = 0; + int mask = (SWT.YES | SWT.NO | SWT.OK | SWT.CANCEL | SWT.ABORT | SWT.RETRY | SWT.IGNORE); + int bits = style & mask; + switch (bits) { + case SWT.OK: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = OS.kAlertDefaultOKText; + break; + case SWT.CANCEL: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = defaultStr = getCFString ("SWT_Cancel"); + break; + case SWT.OK | SWT.CANCEL: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = OS.kAlertDefaultOKText; + param.cancelButton = (short)OS.kAlertStdAlertCancelButton; + param.cancelText = OS.kAlertDefaultCancelText; + break; + case SWT.YES: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = defaultStr = getCFString ("SWT_Yes"); + break; + case SWT.NO: + param.cancelButton = (short)OS.kAlertStdAlertOKButton; + param.cancelText = defaultStr = getCFString ("SWT_No"); + break; + case SWT.YES | SWT.NO: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = defaultStr = getCFString ("SWT_Yes"); + param.cancelButton = (short)OS.kAlertStdAlertCancelButton; + param.cancelText = cancelStr = getCFString ("SWT_No"); + break; + case SWT.YES | SWT.NO | SWT.CANCEL: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = defaultStr = getCFString ("SWT_Yes"); + param.otherText = cancelStr = getCFString ("SWT_No"); + param.cancelButton = (short)OS.kAlertStdAlertCancelButton; + param.cancelText = OS.kAlertDefaultCancelText; + break; + case SWT.RETRY | SWT.CANCEL: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = defaultStr = getCFString ("SWT_Retry"); + param.cancelButton = (short)OS.kAlertStdAlertCancelButton; + param.cancelText = OS.kAlertDefaultCancelText; + break; + case SWT.ABORT | SWT.RETRY | SWT.IGNORE: + param.defaultButton = (short)OS.kAlertStdAlertOKButton; + param.defaultText = defaultStr = getCFString ("SWT_Abort"); + param.otherText = cancelStr = getCFString ("SWT_Retry"); + param.cancelButton = (short)OS.kAlertStdAlertCancelButton; + param.cancelText = otherStr = getCFString ("SWT_Ignore"); + break; } - short[] itemHit= new short[1]; - if (dialogRef[0] != 0) - OS.RunStandardAlert(dialogRef[0], 0, itemHit); - - System.out.println("Alert code: " + itemHit[0]); - - /* Restore focus */ - /* AW - OS.SetFocus (hwndFocus); - */ + int [] dialogRef= new int [1]; + int result = OS.CreateStandardAlert (alertType, error, explanation, param, dialogRef); + if (error != 0) OS.CFRelease(error); + if (explanation != 0) OS.CFRelease(explanation); + if (defaultStr != 0) OS.CFRelease(defaultStr); + if (cancelStr != 0) OS.CFRelease(cancelStr); + if (otherStr != 0) OS.CFRelease(otherStr); - /* - * This code is intentionally commented. On some - * platforms, the owner window is repainted right - * away when a dialog window exits. This behavior - * is currently unspecified. - */ -// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner); - - /* Compute and return the result */ - /* AW - if (code != 0) { - int type = bits & 0x0F; - if (type == OS.MB_OK) return SWT.OK; - if (type == OS.MB_OKCANCEL) { - return (code == OS.IDOK) ? SWT.OK : SWT.CANCEL; - } - if (type == OS.MB_YESNO) { - return (code == OS.IDYES) ? SWT.YES : SWT.NO; - } - if (type == OS.MB_YESNOCANCEL) { - if (code == OS.IDYES) return SWT.YES; - if (code == OS.IDNO) return SWT.NO; - return SWT.CANCEL; - } - if (type == OS.MB_RETRYCANCEL) { - return (code == OS.IDRETRY) ? SWT.RETRY : SWT.CANCEL; - } - if (type == OS.MB_ABORTRETRYIGNORE) { - if (code == OS.IDRETRY) return SWT.RETRY; - if (code == OS.IDABORT) return SWT.ABORT; - return SWT.IGNORE; + if (dialogRef[0] != 0) { + short [] outItemHit = new short [1]; + OS.RunStandardAlert(dialogRef[0], 0, outItemHit); + if (outItemHit [0] != 0) { + switch (bits) { + case SWT.OK: + return SWT.OK; + case SWT.CANCEL: + return SWT.CANCEL; + case SWT.OK | SWT.CANCEL: + if (outItemHit [0] == OS.kAlertStdAlertOKButton) return SWT.OK; + return SWT.CANCEL; + case SWT.YES: + return SWT.YES; + case SWT.NO: + return SWT.NO; + case SWT.YES | SWT.NO: + if (outItemHit [0] == OS.kAlertStdAlertOKButton) return SWT.YES; + return SWT.NO; + case SWT.YES | SWT.NO | SWT.CANCEL: + if (outItemHit [0] == OS.kAlertStdAlertOKButton) return SWT.YES; + if (outItemHit [0] == OS.kAlertStdAlertOtherButton) return SWT.NO; + return SWT.CANCEL; + case SWT.RETRY | SWT.CANCEL: + if (outItemHit [0] == OS.kAlertStdAlertOKButton) return SWT.RETRY; + return SWT.CANCEL; + case SWT.ABORT | SWT.RETRY | SWT.IGNORE: + if (outItemHit [0] == OS.kAlertStdAlertOKButton) return SWT.ABORT; + if (outItemHit [0] == OS.kAlertStdAlertOtherButton) return SWT.RETRY; + return SWT.IGNORE; + } } } - */ return SWT.CANCEL; } -/** - * Sets the dialog's message, which is a description of - * the purpose for which it was opened. This message will be - * visible on the dialog while it is open. - * - * @param string the message - */ public void setMessage (String string) { message = string; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ProgressBar.java index bbc5e41744..a5120c725f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ProgressBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ProgressBar.java @@ -7,251 +7,78 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; + import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -/** - * Instances of the receiver represent is an unselectable - * user interface object that is used to display progress, - * typically in the form of a bar. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>SMOOTH, HORIZONTAL, VERTICAL</dd> - * <dt><b>Events:</b></dt> - * <dd>(none)</dd> - * </dl> - * <p> - * 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> - */ -public /*final*/ class ProgressBar extends Control { +public class ProgressBar extends Control { - // AW - private static final int SIZE= 16; - private int fTopMargin; - private int fBottomMargin; - // AW - -/** - * 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 Widget#checkSubclass - * @see Widget#getStyle - */ public ProgressBar (Composite parent, int style) { super (parent, checkStyle (style)); } + static int checkStyle (int style) { return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0); } + public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); - int border = getBorderWidth (); - int width = border * 2, height = border * 2; + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricNormalProgressBarThickness, outMetric); + int width = 0, height = 0; if ((style & SWT.HORIZONTAL) != 0) { - width += SIZE * 10; - height += SIZE; + height = outMetric [0]; + width = height * 10; } else { - width += SIZE; - height += SIZE * 10; + width = outMetric [0]; + height = width * 10; } - if (wHint != SWT.DEFAULT) width = wHint + (border * 2); - if (hHint != SWT.DEFAULT) height = hHint + (border * 2); + if (wHint != SWT.DEFAULT) width = wHint; + if (hHint != SWT.DEFAULT) height = hHint; return new Point (width, height); } -void createHandle (int index) { - state |= HANDLE; - int parentHandle = parent.handle; - handle = MacUtil.newControl(parentHandle, (short)0, (short)0, (short)100, OS.kControlProgressBarProc); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - if ((style & SWT.INDETERMINATE) != 0) - OS.SetControlData(handle, (short)0, OS.kControlProgressBarIndeterminateTag, -1); -} -/* AW -void disableButtonPress () { - int xWindow = OS.XtWindow (handle); - if (xWindow == 0) return; - int xDisplay = OS.XtDisplay (handle); - if (xDisplay == 0) return; - int event_mask = OS.XtBuildEventMask (handle); - XSetWindowAttributes attributes = new XSetWindowAttributes (); - attributes.event_mask = event_mask & ~OS.ButtonPressMask; - OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWEventMask, attributes); -} -void disableTraversal () { - int [] argList = {OS.XmNtraversalOn, 0}; - OS.XtSetValues (handle, argList, argList.length / 2); + +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateProgressBarControl (window, null, 0, 0, 100, (style & SWT.INDETERMINATE) != 0, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; } -*/ -/** - * 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(); - return OS.GetControl32BitMaximum(handle); + return OS.GetControl32BitMaximum (handle); } -/** - * 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(); - return OS.GetControl32BitMinimum(handle); + return OS.GetControl32BitMinimum (handle); } -/** - * Returns the single <em>selection</em> that is the receiver's position. - * - * @return the selection - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getSelection () { checkWidget(); - return OS.GetControl32BitValue(handle); -} -/* AW -void propagateWidget (boolean enabled) { - super.propagateWidget (enabled); - /* - * ProgressBars never participate in focus traversal when - * either enabled or disabled. - */ - /* AW - if (enabled) { - disableTraversal (); - disableButtonPress (); - } -} -void realizeChildren () { - super.realizeChildren (); - disableButtonPress (); + return OS.GetControl32BitValue (handle); } -*/ -/** - * Sets the maximum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new maximum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setMaximum (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitMaximum(handle, value); + OS.SetControl32BitMaximum (handle, value); } -/** - * Sets the minimum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new minimum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setMinimum (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitMinimum(handle, value); + OS.SetControl32BitMinimum (handle, value); } -/** - * Sets the single <em>selection</em> that is the receiver's - * position to the argument which must be greater than or equal - * to zero. - * - * @param value the new selection (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setSelection (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitValue(handle, value); -} - -//////////////////////////////////////////////////////// -// Mac stuff -//////////////////////////////////////////////////////// - -/** - * Overridden from Control since we want to center the bar within its area. - */ -void handleResize(int hndl, MacRect bounds) { - if ((style & SWT.HORIZONTAL) != 0) { // horizontal - int diff= bounds.getHeight()-SIZE; - fTopMargin= diff/2; - fBottomMargin= diff-fTopMargin; - bounds.inset(0, fTopMargin, 0, fBottomMargin); - } else { // vertical - int diff= bounds.getWidth()-SIZE; - fTopMargin= diff/2; - fBottomMargin= diff-fTopMargin; - bounds.inset(fTopMargin, 0, fBottomMargin, 0); - } - super.handleResize(hndl, bounds); -} - -void internalGetControlBounds(int hndl, MacRect bounds) { - super.internalGetControlBounds(hndl, bounds); - if ((style & SWT.HORIZONTAL) != 0) { // horizontal - bounds.inset(0, -fTopMargin, 0, -fBottomMargin); - } else { // vertical - bounds.inset(-fTopMargin, 0, -fBottomMargin, 0); - } + OS.SetControl32BitValue (handle, value); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java index 5b5c0036a8..fc128775e3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java @@ -7,135 +7,24 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.CGPoint; +import org.eclipse.swt.internal.carbon.Rect; + 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</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> - */ -public /*final*/ class Sash extends Control { - boolean dragging; - int startX, startY, lastX, lastY; +public class Sash extends Control { - private static int H_ARROW; - private static int V_ARROW; - - static { - short[] h= new short[] { - (short) 0x0300, - (short) 0x0300, - (short) 0x0300, - (short) 0x0300, - (short) 0x0300, - (short) 0x2310, - (short) 0x6318, - (short) 0xFB7C, - (short) 0x6318, - (short) 0x2310, - (short) 0x0300, - (short) 0x0300, - (short) 0x0300, - (short) 0x0300, - (short) 0x0300, - (short) 0x0000 - }; - H_ARROW= OS.NewCursor((short)6, (short)7, h, h); - - h= new short[] { - (short) 0x0100, - (short) 0x0380, - (short) 0x07C0, - (short) 0x0100, - (short) 0x0100, - (short) 0x0000, - (short) 0xFFFE, - (short) 0xFFFE, - (short) 0x0000, - (short) 0x0100, - (short) 0x0100, - (short) 0x07C0, - (short) 0x0380, - (short) 0x0100, - (short) 0x0000, - (short) 0x0000 - }; - V_ARROW= OS.NewCursor((short)7, (short)6, h, h); - } + Cursor sizeCursor; -/** - * 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 Sash (Composite parent, int style) { super (parent, checkStyle (style)); + int cursorStyle = (style & SWT.VERTICAL) != 0 ? SWT.CURSOR_SIZEWE : SWT.CURSOR_SIZENS; + sizeCursor = new Cursor (getDisplay (), cursorStyle); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the control is selected, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid. - * If the reciever 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 - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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); @@ -143,185 +32,120 @@ public void addSelectionListener(SelectionListener 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; + int width = 0, height = 0; if ((style & SWT.HORIZONTAL) != 0) { - width += DEFAULT_WIDTH; height += 3; + width += DEFAULT_WIDTH; height += 5; } else { - width += 3; height += DEFAULT_HEIGHT; + width += 5; height += DEFAULT_HEIGHT; } - if (wHint != SWT.DEFAULT) width = wHint + (border * 2); - if (hHint != SWT.DEFAULT) height = hHint + (border * 2); + if (wHint != SWT.DEFAULT) width = wHint; + if (hHint != SWT.DEFAULT) height = hHint; return new Point (width, height); } -void createHandle (int index) { - state |= HANDLE; - int border = (style & SWT.BORDER) != 0 ? 1 : 0; - /* AW - int [] argList = { - OS.XmNborderWidth, border, - OS.XmNmarginWidth, 0, - OS.XmNmarginHeight, 0, - OS.XmNresizePolicy, OS.XmRESIZE_NONE, - OS.XmNancestorSensitive, 1, - }; - */ - handle = MacUtil.createDrawingArea(parent.handle, -1, true, 0, 0, border); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); -} -int defaultBackground () { - return getDisplay ().labelBackground; -} -void drawBand (int x, int y, int width, int height) { - MacRect bounds= new MacRect(); - OS.GetControlBounds(parent.handle, bounds.getData()); - x+= bounds.getX(); - y+= bounds.getY(); - - int port= OS.GetPort(); - OS.SetPortWindowPort(OS.GetControlOwner(handle)); - OS.InvertRect((short)x, (short)y, (short)width, (short)height); - OS.SetPort(port); -} -void hookEvents () { - super.hookEvents (); - Display display= getDisplay(); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneDrawProcTag, display.fUserPaneDrawProc); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneHitTestProcTag, display.fUserPaneHitTestProc); +void createHandle () { + int features = OS.kControlSupportsEmbedding | OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateUserPaneControl (window, null, features, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; } -int processMouseDown (MacMouseEvent mmEvent) { - super.processMouseDown (mmEvent); - - Point mp= MacUtil.toControl(parent.handle, mmEvent.getWhere()); - startX = mp.x; startY = mp.y; - - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - int width = bounds.getWidth(), height = bounds.getHeight(); - - MacRect parentBounds= new MacRect(); - OS.GetControlBounds(parent.handle, parentBounds.getData()); - - lastX = bounds.getX()-parentBounds.getX(); - lastY = bounds.getY()-parentBounds.getY(); - - Event event = new Event (); - event.detail = SWT.DRAG; - //event.time = xEvent.time; - event.x = lastX; event.y = lastY; - event.width = width; event.height = height; - sendEvent (SWT.Selection, event); - if (event.doit) { - dragging = true; - drawBand (lastX = event.x, lastY = event.y, width, height); - } - return 0; +void drawWidget (int control) { + drawBackground (handle, background); } -int processMouseMove (MacMouseEvent mmEvent) { - super.processMouseMove (mmEvent); - - getDisplay().setCursor((style & SWT.VERTICAL) != 0 ? H_ARROW : V_ARROW); - - if (!dragging || (mmEvent.getButton() != 1)) return 0; - Point mp= MacUtil.toControl(parent.handle, mmEvent.getWhere()); - - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - int width = bounds.getWidth(), height = bounds.getHeight(); - - MacRect parentBounds= new MacRect(); - OS.GetControlBounds(parent.handle, parentBounds.getData()); - - int x = bounds.getX()-parentBounds.getX(), y = bounds.getY()-parentBounds.getY(); - int newX = lastX, newY = lastY; - if ((style & SWT.VERTICAL) != 0) { - newX = Math.min (Math.max (0, x + (mp.x - startX)), parentBounds.getWidth() - width); - } else { - newY = Math.min (Math.max (0, y + (mp.y - startY)), parentBounds.getHeight() - height); - } - if (newX == lastX && newY == lastY) return 0; - drawBand (lastX, lastY, width, height); - Event event = new Event (); - event.detail = SWT.DRAG; - //event.time = xEvent.time; - event.x = newX; event.y = newY; - event.width = width; event.height = height; - sendEvent (SWT.Selection, event); - if (event.doit) { - lastX = event.x; lastY = event.y; - drawBand (lastX, lastY, width, height); - } - return 0; +int kEventControlSetCursor (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlSetCursor (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + setCursor (sizeCursor.handle); + return OS.noErr; } -int processMouseUp (MacMouseEvent mmEvent) { - super.processMouseUp (mmEvent); - - if (mmEvent.getButton() != 1) return 0; - if (!dragging) return 0; - dragging = false; - - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - int width = bounds.getWidth(), height = bounds.getHeight(); +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + int result = super.kEventMouseDown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + int startX = rect.left; + int startY = rect.top; + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + OS.GetControlBounds (parent.handle, rect); Event event = new Event (); - //event.time = xEvent.time; - event.x = lastX; event.y = lastY; - event.width = width; event.height = height; - drawBand (lastX, lastY, width, height); + event.x = startX -= rect.left; + event.y = startY -= rect.top; + event.width = width; + event.height = height; sendEvent (SWT.Selection, event); - return 0; -} -int processPaint (Object callData) { + update (); + if (!event.doit) return result; - GC gc= new GC(this); - MacControlEvent me= (MacControlEvent) callData; - Rectangle r= gc.carbon_focus(me.getDamageRegionHandle()); + org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); + OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, pt.sizeof, null, pt); + int window = OS.GetControlOwner (handle); + OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect); + int offsetX = pt.h - rect.left; + int offsetY = pt.v - rect.top; + OS.GetControlBounds (handle, rect); + offsetX -= rect.left; + offsetY -= rect.top; - if (! r.isEmpty()) { - Point e= getSize(); - - // erase background - gc.fillRectangle(0, 0, e.x, e.y); - - gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GRAY)); - if (e.x < e.y) { // vertical - gc.fillRectangle ((e.x-1)/2, (e.y-20)/2, 1, 20); - } else { // horizontal - gc.fillRectangle ((e.x-20)/2, (e.y-1)/2, 20, 1); + int port = OS.GetWindowPort (window); + int [] outModifiers = new int [1]; + short [] outResult = new short [1]; + org.eclipse.swt.internal.carbon.Point outPt = new org.eclipse.swt.internal.carbon.Point (); + while (outResult [0] != OS.kMouseTrackingMouseUp) { + OS.TrackMouseLocationWithOptions (port, 0, OS.kEventDurationForever, outPt, outModifiers, outResult); + switch (outResult [0]) { + case OS.kMouseTrackingMouseDown: + case OS.kMouseTrackingMouseUp: + case OS.kMouseTrackingMouseDragged: { + OS.GetControlBounds (parent.handle, rect); + int x = outPt.h - rect.left; + int y = outPt.v - rect.top; + int newX = startX, newY = startY; + if ((style & SWT.VERTICAL) != 0) { + int clientWidth = rect.right - rect.left; + newX = Math.min (Math.max (0, x - offsetX), clientWidth - width); + } else { + int clientHeight = rect.bottom - rect.top; + newY = Math.min (Math.max (0, y - offsetY), clientHeight - height); + } + event = new Event (); + event.x = newX; + event.y = newY; + event.width = width; + event.height = height; + event.detail = 0; //outResult [0] == OS.kMouseTrackingMouseDragged ? SWT.DRAG : 0; + sendEvent (SWT.Selection, event); + if (event.doit) setBounds (newX, newY, width, height); + update (); + break; + } + default: + outResult [0] = OS.kMouseTrackingMouseUp; + break; } } - - gc.carbon_unfocus(); - gc.dispose(); - - return 0; + return result; } -/** - * Removes the listener from the collection of listeners who will - * be notified when the control is selected. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ + +void releaseWidget () { + super.releaseWidget (); + if (sizeCursor != null) sizeCursor.dispose (); + sizeCursor = null; +} + public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java index 466e679e60..26a5b923d5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java @@ -7,86 +7,29 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; + import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; -/** - * Instances of the receiver represent a selectable user - * interface object that present a range of continuous - * numeric values. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>HORIZONTAL, VERTICAL</dd> - * <dt><b>Events:</b></dt> - * <dd>Selection</dd> - * </dl> - * <p> - * 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> - */ -public /*final*/ class Scale extends Control { - - private int increment= 1; - private int pageIncrement= 10; - -/** - * 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 class Scale extends Control { + int increment = 1; + int pageIncrement = 10; + public Scale (Composite parent, int style) { super (parent, checkStyle (style)); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver's value changes, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #removeSelectionListener - */ +int actionProc (int theControl, int partCode) { + Event event = new Event (); + sendEvent (SWT.Selection); + Display display = getDisplay (); + display.update (); + return 0; +} + public void addSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -94,172 +37,65 @@ public void addSelectionListener(SelectionListener 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; - Display display = getDisplay (); - int hScroll = display.scrolledMarginX; - int vScroll = display.scrolledMarginY; + int width = 0, height = 0; if ((style & SWT.HORIZONTAL) != 0) { - width += hScroll * 10; - height += vScroll; + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricHSliderHeight, outMetric); + height = outMetric [0]; + width = height * 10; } else { - width += hScroll; - height += vScroll * 10; + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricVSliderWidth, outMetric); + width = outMetric [0]; + height = width * 10; } - if (wHint != SWT.DEFAULT) width = wHint + (border * 2); - if (hHint != SWT.DEFAULT) height = hHint + (border * 2); + if (wHint != SWT.DEFAULT) width = wHint; + if (hHint != SWT.DEFAULT) height = hHint; return new Point (width, height); } -void createHandle (int index) { - state |= HANDLE; - /* AW - int [] argList = { - OS.XmNtitleString, 0, - OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0, - OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL, - OS.XmNprocessingDirection, ((style & SWT.H_SCROLL) != 0) ? OS.XmMAX_ON_RIGHT : OS.XmMAX_ON_BOTTOM, - OS.XmNancestorSensitive, 1, - }; - */ - int parentHandle = parent.handle; - short procID= (short)(OS.kControlSliderProc + OS.kControlSliderLiveFeedback + OS.kControlSliderNonDirectional); - handle= MacUtil.newControl(parentHandle, (short)0, (short)0, (short)100, procID); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + +void createHandle () { + Display display = getDisplay (); + int actionProc = display.actionProc; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateSliderControl (window, null, 0, 0, 100, OS.kControlSliderDoesNotPoint, (short)0, true, actionProc, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [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(); return increment; } -/** - * 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(); - return OS.GetControl32BitMaximum(handle); + return OS.GetControl32BitMaximum (handle); } -/** - * 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(); - return OS.GetControl32BitMinimum(handle); + return OS.GetControl32BitMinimum (handle); } -/** - * 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(); return pageIncrement; } -/** - * Returns the single <em>selection</em> that is the receiver's position. - * - * @return the selection - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getSelection () { checkWidget(); - return OS.GetControl32BitValue(handle); -} -void hookEvents () { - super.hookEvents (); - /* AW - int windowProc = getDisplay ().windowProc; - OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection); - */ - OS.SetControlAction(handle, getDisplay().fControlActionProc); + return OS.GetControl32BitValue (handle); } -int processSelection (Object callData) { - - MacControlEvent macEvent= (MacControlEvent) callData; - Event event = new Event (); - if (macEvent.getPartCode() == OS.kControlIndicatorPart) { // end of drag or continuos drag - if (macEvent.isMouseDown()) { - event.detail = SWT.DRAG; // continuos drag - } else { - /* - * Do not set the detail field to SWT.DRAG - * to indicate that the dragging has ended. - */ - } - } - - sendEvent (SWT.Selection, event); - - /* AW FIXME: may be we need the following here too... - if (macEvent.isMouseDown()) { - int wHandle= OS.GetControlOwner(handle); - if (wHandle != 0) { - getDisplay().updateWindow(wHandle); - } - } - */ - return 0; -} -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver's value changes. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -267,95 +103,39 @@ public void removeSelectionListener(SelectionListener listener) { 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(); if (value < 1) return; - increment= value; + increment = value; } -/** - * Sets the maximum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new maximum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setMaximum (int value) { checkWidget(); - if (value < 0) return; - if (OS.GetControl32BitValue(handle) > value) - OS.SetControl32BitValue(handle, value); - OS.SetControl32BitMaximum(handle, value); + int minimum = OS.GetControl32BitMinimum (handle); + if (0 <= minimum && minimum < value) { + OS.SetControl32BitMaximum (handle, value); + } } -/** - * Sets the minimum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new minimum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setMinimum (int value) { checkWidget(); - if (value < 0) return; - if (OS.GetControl32BitValue(handle) < value) - OS.SetControl32BitValue(handle, value); - OS.SetControl32BitMinimum(handle, value); + int maximum = OS.GetControl32BitMaximum (handle); + if (0 <= maximum && maximum < value) { + OS.SetControl32BitMinimum (handle, value); + } } -/** - * Sets the amount that the receiver's value will be - * modified by when the page increment/decrement areas - * are selected to the argument, which must be at least - * one. - * - * @return the page increment (must be greater than zero) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setPageIncrement (int value) { checkWidget(); if (value < 1) return; - pageIncrement= value; + pageIncrement = value; } -/** - * Sets the single <em>selection</em> that is the receiver's - * value to the argument which must be greater than or equal - * to zero. - * - * @param value the new selection (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setSelection (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitValue(handle, value); + OS.SetControl32BitValue (handle, value); } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java index b4055f1a14..839ba34afb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java @@ -6,121 +6,31 @@ package org.eclipse.swt.widgets; * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html */ + +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; -import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; -/** - * Instances of this class are selectable user interface - * objects that represent a range of positive, numeric values. - * <p> - * At any given moment, a given scroll bar will have a - * single <em>selection</em> that is considered to be its - * value, which is constrained to be within the range of - * values the scroll bar represents (that is, between its - * <em>minimum</em> and <em>maximum</em> values). - * </p><p> - * Typically, scroll bars will be made up of five areas: - * <ol> - * <li>an arrow button for decrementing the value</li> - * <li>a page decrement area for decrementing the value by a larger amount</li> - * <li>a <em>thumb</em> for modifying the value by mouse dragging</li> - * <li>a page increment area for incrementing the value by a larger amount</li> - * <li>an arrow button for incrementing the value</li> - * </ol> - * Based on their style, scroll bars are either <code>HORIZONTAL</code> - * (which have 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 - */ -public /*final*/ class ScrollBar extends Widget { +public class ScrollBar extends Widget { + int handle; Scrollable parent; - private int increment= 1; - private int pageIncrement= 10; - boolean visible= true; - + boolean dragging; + int increment = 1; + int pageIncrement = 10; + ScrollBar () { - /* Do Nothing */ + /* Do nothing */ } + ScrollBar (Scrollable parent, int style) { super (parent, checkStyle (style)); this.parent = parent; - createWidget (0); -} -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver's value changes, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values: - * <code>0</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 - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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 - */ + createWidget (); +} + public void addSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -128,482 +38,251 @@ public void addSelectionListener(SelectionListener 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); } -void createHandle (int index) { - state |= HANDLE; - handle= 0; - if ((style & SWT.H_SCROLL) != 0) { - handle= parent.hScrollBar; - } else if ((style & SWT.V_SCROLL) != 0) { - handle= parent.vScrollBar; + +int actionProc (int theControl, int partCode) { + Event event = new Event (); + int value = OS.GetControl32BitValue (handle); + switch (partCode) { + case OS.kControlUpButtonPart: + value -= increment; + event.detail = SWT.ARROW_UP; + break; + case OS.kControlPageUpPart: + value -= pageIncrement; + event.detail = SWT.PAGE_UP; + break; + case OS.kControlPageDownPart: + value += pageIncrement; + event.detail = SWT.PAGE_DOWN; + break; + case OS.kControlDownButtonPart: + value += increment; + event.detail = SWT.ARROW_DOWN; + break; + case OS.kControlIndicatorPart: + dragging = true; + event.detail = SWT.DRAG; + break; + default: + return 0; } - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + OS.SetControl32BitValue (handle, value); + sendEvent (SWT.Selection, event); + if (dragging) { + Display display = getDisplay (); + display.update (); + } + return 0; } -/** -* Gets the Display. -*/ + +void destroyWidget () { + int theControl = handle; + releaseHandle (); + if (theControl != 0) { + OS.DisposeControl (theControl); + } +} + +void createHandle () { + Display display = getDisplay (); + int actionProc = display.actionProc; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.scrolledHandle); + OS.CreateScrollBarControl (window, null, 0, 0, 90, 10, true, actionProc, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; +} + +void createWidget () { + super.createWidget (); + setZOrder (); +} + +void deregister () { + super.deregister (); + WidgetTable.remove (handle); +} + public Display getDisplay () { Scrollable parent = this.parent; if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getDisplay (); } -/** - * Returns <code>true</code> if the receiver is enabled, and - * <code>false</code> otherwise. A disabled control is typically - * not selectable from the user interface and draws with an - * inactive or "grayed" look. - * - * @return the enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public boolean getEnabled () { checkWidget(); - return OS.IsControlEnabled(handle); -} -/** - * 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> - */ + return (state & DISABLED) == 0; +} + public int getIncrement () { checkWidget(); return increment; } -/** - * 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(); - return OS.GetControl32BitMaximum(handle) + OS.GetControlViewSize(handle); -} -/** - * 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> - */ + int maximum = OS.GetControl32BitMaximum (handle); + int viewSize = OS.GetControlViewSize (handle); + return maximum + viewSize; +} + public int getMinimum () { checkWidget(); - return OS.GetControl32BitMinimum(handle); -} -/** - * 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> - */ + return OS.GetControl32BitMinimum (handle); +} + public int getPageIncrement () { checkWidget(); return pageIncrement; } -/** - * Returns the receiver's parent, which must be scrollable. - * - * @return the receiver's parent - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Scrollable getParent () { - checkWidget(); + checkWidget (); return parent; } -/** - * Returns the single <em>selection</em> that is the receiver's value. - * - * @return the selection - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getSelection () { checkWidget(); - return OS.GetControl32BitValue(handle); -} -/** - * 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> - */ + return OS.GetControl32BitValue (handle); +} + public Point getSize () { checkWidget(); - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - return bounds.getSize(); -} -/** - * Answers the size of the receiver's thumb relative to the - * difference between its maximum and minimum values. - * - * @return the thumb value - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ScrollBar - */ + Rect rect = getControlSize (handle); + return new Point (rect.right - rect.left, rect.bottom - rect.top); +} + public int getThumb () { checkWidget(); - return OS.GetControlViewSize(handle); -} -/** - * 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> - */ + return OS.GetControlViewSize (handle); +} + public boolean getVisible () { checkWidget(); - return OS.IsControlVisible(handle); + return (state & HIDDEN) == 0; } -/* AW + void hookEvents () { - int windowProc = parent.getDisplay ().windowProc; - OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, SWT.Selection); -} -*/ -/** - * Returns <code>true</code> if the receiver is enabled and 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 - */ + super.hookEvents (); + Display display = getDisplay (); + int controlProc = display.controlProc; + int [] mask = new int [] { + OS.kEventClassControl, OS.kEventControlDraw, + }; + int controlTarget = OS.GetControlEventTarget (handle); + OS.InstallEventHandler (controlTarget, controlProc, mask.length / 2, mask, handle, null); +} + 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 - */ + return OS.IsControlEnabled (handle); +} + public boolean isVisible () { checkWidget(); - return getVisible () && parent.isVisible (); -} -/* AW -void manageChildren () { - OS.XtManageChild (handle); -} -*/ -int processSelection (Object callData) { - - MacControlEvent macEvent= (MacControlEvent) callData; - int partCode= macEvent.getPartCode(); - boolean mouseDown= macEvent.isMouseDown(); - - if ((partCode != OS.kControlIndicatorPart) && !mouseDown) - return 0; - - Event event= new Event (); - - switch (partCode) { - case OS.kControlUpButtonPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - increment); - event.detail = SWT.ARROW_UP; - break; - case OS.kControlPageUpPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - pageIncrement); - event.detail = SWT.PAGE_UP; - break; - case OS.kControlPageDownPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) + pageIncrement); - event.detail = SWT.PAGE_DOWN; - break; - case OS.kControlDownButtonPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) + increment); - event.detail = SWT.ARROW_DOWN; - break; - case OS.kControlIndicatorPart: // end of drag or continuos drag - if (mouseDown) { - event.detail = SWT.DRAG; // continuos drag - } else { - /* - * Do not set the detail field to SWT.DRAG - * to indicate that the dragging has ended. - */ - } - break; - } + return OS.HIViewIsVisible (handle); +} - sendEvent (SWT.Selection, event); - // flush display - getDisplay().update(); +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + int status = super.kEventMouseDown (nextHandler, theEvent, userData); + if (status == OS.noErr) return status; + dragging = false; + status = OS.CallNextEventHandler (nextHandler, theEvent); + if (dragging) { + Event event = new Event (); + sendEvent (SWT.Selection, event); + } + dragging = false; + return status; +} - return OS.kNoErr; +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 processWheel(int eRefHandle) { - int[] t= new int[1]; - OS.GetEventParameter(eRefHandle, OS.kEventParamMouseWheelDelta, OS.typeSInt32, null, null, t); - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - (increment * t[0])); - Event event= new Event (); - event.detail= t[0] > 0 ? SWT.ARROW_UP : SWT.ARROW_DOWN; - sendEvent (SWT.Selection, event); - getDisplay().update(); - return OS.kNoErr; + +void register () { + super.register (); + WidgetTable.put (handle, this); } + void releaseChild () { super.releaseChild (); - if (parent.horizontalBar == this) parent.horizontalBar = null; - if (parent.verticalBar == this) parent.verticalBar = null; + //NOT DONE - layout parent +} + +void releaseHandle () { + super.releaseHandle (); + handle = 0; } + void releaseWidget () { super.releaseWidget (); parent = null; } -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver's value changes. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ -public void removeSelectionListener(SelectionListener listener) { + +public void setIncrement (int value) { checkWidget(); - if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable == null) return; - eventTable.unhook(SWT.Selection, listener); - eventTable.unhook(SWT.DefaultSelection,listener); + if (value < 1) return; + increment = value; } -/** - * 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) - OS.EnableControl(handle); - else - OS.DisableControl(handle); -} -/** - * Sets the amount that the receiver's value will be - * modified by when the up/down (or right/left) arrows - * are pressed to the argument, which must be at least - * one. - * - * @param value the new increment (must be greater than zero) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setIncrement (int value) { - checkWidget(); - if (value < 1) return; - increment= value; -} -/** - * Sets the maximum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new maximum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + if (enabled) { + if ((state & DISABLED) == 0) return; + state &= ~DISABLED; + OS.EnableControl (handle); + } else { + if ((state & DISABLED) != 0) return; + state |= DISABLED; + OS.DisableControl (handle); + } +} + public void setMaximum (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitMaximum(handle, value-OS.GetControlViewSize(handle)); -} -/** - * Sets the minimum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new minimum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + int minimum = OS.GetControl32BitMinimum (handle); + int viewSize = OS.GetControlViewSize (handle); + if (value - minimum - viewSize < 0) return; + OS.SetControl32BitMaximum (handle, value - viewSize); +} + public void setMinimum (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitMinimum(handle, value); -} -/** - * Sets the amount that the receiver's value will be - * modified by when the page increment/decrement areas - * are selected to the argument, which must be at least - * one. - * - * @return the page increment (must be greater than zero) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + int maximum = OS.GetControl32BitMinimum (handle); + int viewSize = OS.GetControlViewSize (handle); + if (maximum - value - viewSize < 0) return; + OS.SetControl32BitMinimum (handle, value); +} + public void setPageIncrement (int value) { checkWidget(); if (value < 1) return; - pageIncrement= value; -} -/** - * Sets the single <em>selection</em> that is the receiver's - * value to the argument which must be greater than or equal - * to zero. - * - * @param value the new selection (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setSelection (int selection) { + pageIncrement = value; +} + +public void setSelection (int value) { checkWidget(); - if (selection < 0) return; - OS.SetControl32BitValue(handle, selection); -} -/** - * Sets the size of the receiver's thumb relative to the - * difference between its maximum and minimum values to the - * argument which must be at least one. - * - * @param value the new thumb value (must be at least one) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ScrollBar - */ + if (value < 0) return; + OS.SetControl32BitValue (handle, value); +} + public void setThumb (int value) { checkWidget(); if (value < 1) return; - int oldMaximum= OS.GetControl32BitMaximum(handle) + OS.GetControlViewSize(handle); - OS.SetControlViewSize(handle, value); - OS.SetControl32BitMaximum(handle, oldMaximum-value); -} -/** - * Sets the receiver's selection, minimum value, maximum - * value, thumb, increment and page increment all at once. - * <p> - * Note: This is equivalent to setting the values individually - * using the appropriate methods, but may be implemented in a - * more efficient fashion on some platforms. - * </p> - * - * @param selection the new selection value - * @param minimum the new minimum value - * @param maximum the new maximum value - * @param thumb the new thumb value - * @param increment the new increment value - * @param pageIncrement the new pageIncrement value - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + OS.SetControlViewSize (handle, value); +} + public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) { checkWidget(); if (selection < 0) return; @@ -613,52 +292,30 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i if (maximum - minimum - thumb < 0) return; if (increment < 1) return; if (pageIncrement < 1) return; - OS.SetControl32BitMinimum(handle, minimum); - OS.SetControl32BitMaximum(handle, maximum-thumb); - OS.SetControlViewSize(handle, thumb); - OS.SetControl32BitValue(handle, selection); - this.increment= increment; - this.pageIncrement= pageIncrement; -} -/** - * 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> - */ + OS.SetControl32BitMinimum (handle, minimum); + OS.SetControl32BitMaximum (handle, maximum - thumb); + OS.SetControlViewSize (handle, thumb); + OS.SetControl32BitValue (handle, selection); + this.increment = increment; + this.pageIncrement = pageIncrement; +} + public void setVisible (boolean visible) { checkWidget(); - -// this.visible= visible; -// if (OS.IsControlVisible(handle) != visible) { -// OS.HIViewSetVisible(handle, visible); -// parent.relayout123(); -// sendEvent(visible ? SWT.Show : SWT.Hide); -// } - - if (this.visible != visible) { - this.visible= visible; - int topHandle = topHandle (); - if (OS.IsControlVisible(topHandle) != visible) { - OS.HIViewSetVisible(topHandle, visible); - parent.relayout123(); - sendEvent (visible ? SWT.Show : SWT.Hide); - } - } -} - -void internalSetBounds(MacRect bounds) { - OS.SetControlBounds(handle, bounds.getData()); + if (visible) { + if ((state & HIDDEN) == 0) return; + state &= ~HIDDEN; + } else { + if ((state & HIDDEN) != 0) return; + state |= HIDDEN; + } + OS.HIViewSetVisible (handle, visible); + sendEvent (visible ? SWT.Show : SWT.Hide); + parent.layoutControl(); +} + +void setZOrder () { + OS.HIViewAddSubview (parent.scrolledHandle, handle); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java index f515dbde63..c58fadacc1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java @@ -7,498 +7,188 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; + 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> - */ public abstract class Scrollable extends Control { - int scrolledHandle /* formHandle */; + int scrolledHandle; int hScrollBar, vScrollBar; 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); } -/** - * Given a desired <em>client area</em> for the receiver - * (as described by the arguments), returns the bounding - * rectangle which would be required to produce that client - * area. - * <p> - * In other words, it returns a rectangle such that, if the - * receiver's bounds were set to that rectangle, the area - * of the receiver which is capable of displaying data - * (that is, not covered by the "trimmings") would be the - * rectangle described by the arguments (relative to the - * receiver's parent). - * </p> - * - * @return the required bounds to produce the given client area - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #getClientArea - */ + public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget(); - int border = getBorderWidth (); - int trimX = x - border, trimY = y - border; - int trimWidth = width + (border * 2), trimHeight = height + (border * 2); - if (horizontalBar != null) { - Display display = getDisplay (); - trimY -= display.scrolledInsetY; - trimHeight += display.scrolledInsetY + display.scrolledMarginY; - if (verticalBar == null) { - trimX -= display.scrolledInsetX; - trimWidth += display.scrolledInsetX * 2; - trimHeight -= display.scrolledInsetY * 2; - } - } - if (verticalBar != null) { - Display display = getDisplay (); - trimX -= display.scrolledInsetX; - trimWidth += display.scrolledInsetX + display.scrolledMarginX; - if (horizontalBar == null) { - trimY -= display.scrolledInsetY; - trimHeight += display.scrolledInsetY * 2; - trimWidth -= display.scrolledInsetX * 2; - } - } - return new Rectangle (trimX, trimY, trimWidth, trimHeight); + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricScrollBarWidth, outMetric); + if (horizontalBar != null) height += outMetric [0]; + if (verticalBar != null) width += outMetric [0]; + Rect inset = inset (); + x -= inset.left; + y -= inset.top; + width += inset.left + inset.right; + height += inset.top + inset.bottom; + return new Rectangle (x, y, width, height); } + ScrollBar createScrollBar (int type) { return new ScrollBar (this, type); } + ScrollBar createStandardBar (int style) { - if (scrolledHandle == 0) return null; + short [] count = new short [1]; + OS.CountSubControls (handle, count); + if (count [0] == 0) return null; + int [] outControl = new int [1]; + int index = (style & SWT.HORIZONTAL) != 0 ? 1 : 2; + int status = OS.GetIndexedSubControl (handle, (short)index, outControl); + if (status != OS.noErr) return null; ScrollBar bar = new ScrollBar (); bar.parent = this; bar.style = style; - bar.state |= HANDLE; - System.out.println("Scrollable.createStandardBar: nyi"); - /* AW - int [] argList = {OS.XmNhorizontalScrollBar, 0, OS.XmNverticalScrollBar, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - if (style == SWT.H_SCROLL) bar.handle = argList [1]; - if (style == SWT.V_SCROLL) bar.handle = argList [3]; - */ - bar.hookEvents (); + bar.handle = outControl [0]; bar.register (); + bar.hookEvents (); return bar; } -void createWidget (int index) { - super.createWidget (index); + +void createWidget () { + super.createWidget (); if ((style & SWT.H_SCROLL) != 0) horizontalBar = createScrollBar (SWT.H_SCROLL); if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL); } + void deregister () { super.deregister (); - /* AW - if (formHandle != 0) WidgetTable.remove (formHandle); - */ if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle); } -/* AW -void enableWidget (boolean enabled) { - super.enableWidget (enabled); - if (formHandle != 0) enableHandle (enabled, formHandle); - if (scrolledHandle != 0) { - enableHandle (enabled, scrolledHandle); - int [] argList = { - OS.XmNhorizontalScrollBar, 0, - OS.XmNverticalScrollBar, 0, - }; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - if (argList [1] != 0) enableHandle (enabled, argList [1]); - if (argList [3] != 0) enableHandle (enabled, argList [3]); - } -} -*/ -/** - * Returns a rectangle which describes the area of the - * receiver which is capable of displaying data (that is, - * not covered by the "trimmings"). - * - * @return the client area - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #computeTrim - */ + public Rectangle getClientArea () { checkWidget(); - /* AW - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - return new Rectangle (0, 0, argList [1], argList [3]); - */ - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - Rectangle r= new Rectangle (0, 0, bounds.getWidth(), bounds.getHeight()); - /* - if (r.isEmpty()) { - System.out.println("Scrollable.getClientArea(" + this + "): " + r); - //new Exception().printStackTrace(); - } - */ - return r; + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + return new Rectangle (0, 0, rect.right - rect.left, rect.bottom - rect.top); } -/** - * 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 (); + +boolean hasBorder () { + return (style & SWT.BORDER) != 0; } -void manageChildren () { - /* AW - if (scrolledHandle != 0) { - OS.XtSetMappedWhenManaged (scrolledHandle, false); - OS.XtManageChild (scrolledHandle); - } - if (formHandle != 0) { - OS.XtSetMappedWhenManaged (formHandle, false); - OS.XtManageChild (formHandle); - } - */ - super.manageChildren (); - /* AW - if (formHandle != 0) { - int [] argList = {OS.XmNborderWidth, 0}; - OS.XtGetValues (formHandle, argList, argList.length / 2); - OS.XtResizeWidget (formHandle, 1, 1, argList [1]); - OS.XtSetMappedWhenManaged (formHandle, true); - } - if (scrolledHandle != 0) { - int [] argList = {OS.XmNborderWidth, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - OS.XtResizeWidget (scrolledHandle, 1, 1, argList [1]); - OS.XtSetMappedWhenManaged (scrolledHandle, true); + +void hookEvents () { + super.hookEvents (); + if ((state & CANVAS) != 0 && scrolledHandle != 0) { + Display display = getDisplay (); + int controlProc = display.controlProc; + int [] mask = new int [] { + OS.kEventClassControl, OS.kEventControlDraw, + }; + int controlTarget = OS.GetControlEventTarget (scrolledHandle); + OS.InstallEventHandler (controlTarget, controlProc, mask.length / 2, mask, scrolledHandle, null); } - */ } -/* AW -void propagateWidget (boolean enabled) { - super.propagateWidget (enabled); - if (formHandle != 0) propagateHandle (enabled, formHandle); - if (scrolledHandle != 0) { - propagateHandle (enabled, scrolledHandle); - int [] argList = { - OS.XmNhorizontalScrollBar, 0, - OS.XmNverticalScrollBar, 0, - }; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - if (argList [1] != 0) propagateHandle (enabled, argList [1]); - if (argList [3] != 0) propagateHandle (enabled, argList [3]); + +boolean hooksKeys () { + return hooks (SWT.KeyDown) || hooks (SWT.KeyUp) || hooks (SWT.Traverse); +} + +Rect inset () { + if ((state & CANVAS) != 0) { + Rect rect = new Rect (); + int [] outMetric = new int [1]; + if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) { + OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric); + rect.left += outMetric [0]; + rect.top += outMetric [0]; + rect.right += outMetric [0]; + rect.bottom += outMetric [0]; + } + if (hasBorder ()) { + OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric); + rect.left += outMetric [0]; + rect.top += outMetric [0]; + rect.right += outMetric [0]; + rect.bottom += outMetric [0]; + } + return rect; } + return EMPTY_RECT; +} + +void layoutControl () { + if (scrolledHandle != 0) { + int vWidth = 0, hHeight = 0; + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricScrollBarWidth, outMetric); + boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible (); + boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible (); + if (isVisibleHBar) hHeight = outMetric [0]; + if (isVisibleVBar) vWidth = outMetric [0]; + Rect rect = new Rect (); + OS.GetControlBounds (scrolledHandle, rect); + Rect inset = inset (); + int width = Math.max (0, rect.right - rect.left - vWidth - inset.left - inset.right); + int height = Math.max (0, rect.bottom - rect.top - hHeight - inset.top - inset.bottom); + if (isVisibleHBar) { + setBounds (horizontalBar.handle, inset.left, inset.top + height, width, hHeight, true, true, false); + } + if (isVisibleVBar) { + setBounds (verticalBar.handle, inset.left + width, inset.top, vWidth, height, true, true, false); + } + setBounds (handle, inset.left, inset.top, width, height, true, true, false); + } } -*/ + void register () { super.register (); - /* AW - if (formHandle != 0) WidgetTable.put (formHandle, this); - */ if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this); } + void releaseHandle () { super.releaseHandle (); - scrolledHandle = /* AW formHandle = */ 0; + scrolledHandle = 0; } + void releaseWidget () { - if (horizontalBar != null) { - horizontalBar.releaseWidget (); - horizontalBar.releaseHandle (); - } - if (verticalBar != null) { - verticalBar.releaseWidget (); - verticalBar.releaseHandle (); - } + if (horizontalBar != null) horizontalBar.releaseResources (); + if (verticalBar != null) verticalBar.releaseResources (); horizontalBar = verticalBar = null; super.releaseWidget (); } -/* AW -void setBackgroundPixel (int pixel) { - super.setBackgroundPixel (pixel); - if (scrolledHandle != 0) { - int [] argList1 = { - OS.XmNhorizontalScrollBar, 0, - OS.XmNverticalScrollBar, 0, - }; - OS.XtGetValues (scrolledHandle, argList1, argList1.length / 2); - if (argList1 [1] != 0) OS.XmChangeColor (argList1 [1], pixel); - if (argList1 [3] != 0) OS.XmChangeColor (argList1 [3], pixel); + +int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) { + int result = super.setBounds(control, x, y, width, height, move, resize, false); + if ((result & MOVED) != 0) { + if (events) sendEvent (SWT.Move); } + if ((result & RESIZED) != 0) { + if (control == scrolledHandle) layoutControl (); + if (events) sendEvent (SWT.Resize); + } + return result; } -*/ + int topHandle () { if (scrolledHandle != 0) return scrolledHandle; - /* AW - if (formHandle != 0) return formHandle; - */ return handle; } -//////////////////////////// -// Mac Stuff -//////////////////////////// - - int createScrollView(int parentControlHandle, int style) { - - Display display= getDisplay(); - - int pos= -1; - - if (OS.IsValidControlHandle(parentControlHandle)) { - } else if (OS.IsValidWindowPtr(parentControlHandle)) { - int[] root= new int[1]; - if (OS.CreateRootControl(parentControlHandle, root) == OS.kNoErr) { - //OS.GetRootControl(parentControlHandle, root); - parentControlHandle= root[0]; - } else { - OS.HIViewFindByID(OS.HIViewGetRoot(parentControlHandle), 0, root); - parentControlHandle= root[0]; - pos= -1; // below growbox - } - } else - System.out.println("createScrollView: shouldn't happen"); - - int controlHandle = MacUtil.createDrawingArea(parentControlHandle, pos, true, 0, 0, 0); - - /* - OS.InstallEventHandler(OS.GetControlEventTarget(controlHandle), display.fControlProc, - new int[] { - OS.kEventClassControl, OS.kEventControlBoundsChanged - }, - controlHandle - ); - */ - - if ((style & SWT.H_SCROLL) != 0) { - int hs= MacUtil.newControl(controlHandle, (short)0, (short)0, (short)100, OS.kControlScrollBarLiveProc); - OS.SetControlAction(hs, display.fControlActionProc); - hScrollBar= hs; - } - - if ((style & SWT.V_SCROLL) != 0) { - int vs= MacUtil.newControl(controlHandle, (short)0, (short)0, (short)100, OS.kControlScrollBarLiveProc); - OS.SetControlAction(vs, display.fControlActionProc); - vScrollBar= vs; - } - - return controlHandle; - } - - /** - * Overridden from Control. - * x and y are relative to window! - */ - void handleResize(int handle, MacRect bounds) { - super.handleResize(handle, bounds); - relayout123(); - } - - void relayout123() { - if (MacUtil.HIVIEW) - newRelayout(); - else - oldRelayout(); - } - - private void newRelayout() { - - int hndl= scrolledHandle; - if (hndl == 0) - return; - - MacRect bounds= new MacRect(); - OS.GetControlBounds(hndl, bounds.getData()); - - boolean visible= OS.IsControlVisible(hndl); - - int x= 0; // bounds.getX(); - int y= 0; // bounds.getY(); - int w= bounds.getWidth(); - int h= bounds.getHeight(); - - int s= 15; - int ww= w; - int hh= h; - int style= getStyle(); - - if (ww < 0 || hh < 0) { - System.out.println("******* Scrollable.newRelayout: " + ww + " " + hh); - return; - } - - ScrollBar hsb= null; - if ((style & SWT.H_SCROLL) != 0) { - hsb= getHorizontalBar(); - if (hsb != null) { - if (visible && !OS.IsControlVisible(hsb.handle)) - ; - else - hh-= s; - } - } - - ScrollBar vsb= null; - if ((style & SWT.V_SCROLL) != 0) { - vsb= getVerticalBar(); - if (vsb != null) { - if (visible && !OS.IsControlVisible(vsb.handle)) - ; - else - ww-= s; - } - } - - if (hsb != null) - OS.HIViewSetFrame(hsb.handle, x, y+h-s, ww, s); - - if (vsb != null) - OS.HIViewSetFrame(vsb.handle, x+w-s, y, s, hh); - - OS.HIViewSetFrame(handle, x, y, ww, hh); - - //if (ww != w && hh != h) - // OS.InvalWindowRect(OS.GetControlOwner(handle), new MacRect(x+w-s, y+h-s, s, s).getData()); - } - - private void oldRelayout() { - - int hndl= scrolledHandle; - if (hndl == 0) - return; - - MacRect bounds= new MacRect(); - OS.GetControlBounds(hndl, bounds.getData()); - - boolean visible= OS.IsControlVisible(hndl); - - int x= bounds.getX(); - int y= bounds.getY(); - int w= bounds.getWidth(); - int h= bounds.getHeight(); - - int s= 15; - int ww= w; - int hh= h; - int style= getStyle(); - - if (ww < 0 || hh < 0) { - System.out.println("******* Scrollable.oldRelayout: " + ww + " " + hh); - return; - } - - ScrollBar hsb= null; - if ((style & SWT.H_SCROLL) != 0) { - hsb= getHorizontalBar(); - if (hsb != null) { - if (visible && !OS.IsControlVisible(hsb.handle)) - ; - else - hh-= s; - } - } - - ScrollBar vsb= null; - if ((style & SWT.V_SCROLL) != 0) { - vsb= getVerticalBar(); - if (vsb != null) { - if (visible && !OS.IsControlVisible(vsb.handle)) - ; - else - ww-= s; - } - } - - if (hsb != null) - hsb.internalSetBounds(new MacRect(x, y+h-s, ww, s)); - - if (vsb != null) - vsb.internalSetBounds(new MacRect(x+w-s, y, s, hh)); - - OS.SetControlBounds(handle, new MacRect(x, y, ww, hh).getData()); - - if (ww != w && hh != h) - OS.InvalWindowRect(OS.GetControlOwner(handle), new MacRect(x+w-s, y+h-s, s, s).getData()); - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java index eef67768be..2db10cf070 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java @@ -7,228 +7,38 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; + +import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; -import org.eclipse.swt.internal.carbon.*; - -/** - * Instances of this class represent the "windows" - * which the desktop or "window manager" is managing. - * Instances that do not have a parent (that is, they - * are built using the constructor, which takes a - * <code>Display</code> as the argument) are described - * as <em>top level</em> shells. Instances that do have - * a parent are described as <em>secondary</em> or - * <em>dialog</em> shells. - * <p> - * Instances are always displayed in one of the maximized, - * minimized or normal states: - * <ul> - * <li> - * When an instance is marked as <em>maximized</em>, the - * window manager will typically resize it to fill the - * entire visible area of the display, and the instance - * is usually put in a state where it can not be resized - * (even if it has style <code>RESIZE</code>) until it is - * no longer maximized. - * </li><li> - * When an instance is in the <em>normal</em> state (neither - * maximized or minimized), its appearance is controlled by - * the style constants which were specified when it was created - * and the restrictions of the window manager (see below). - * </li><li> - * When an instance has been marked as <em>minimized</em>, - * its contents (client area) will usually not be visible, - * and depending on the window manager, it may be - * "iconified" (that is, replaced on the desktop by a small - * simplified representation of itself), relocated to a - * distinguished area of the screen, or hidden. Combinations - * of these changes are also possible. - * </li> - * </ul> - * </p> - * <p> - * Note: The styles supported by this class must be treated - * as <em>HINT</em>s, since the window manager for the - * desktop on which the instance is visible has ultimate - * control over the appearance and behavior of decorations - * and modality. For example, some window managers only - * support resizable windows and will always assume the - * RESIZE style, even if it is not set. In addition, if a - * modality style is not supported, it is "upgraded" to a - * more restrictive modality style that is supported. For - * example, if <code>PRIMARY_MODAL</code> is not supported, - * it would be upgraded to <code>APPLICATION_MODAL</code>. - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd> - * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd> - * <dt><b>Events:</b></dt> - * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd> - * </dl> - * Class <code>SWT</code> provides two "convenience constants" - * for the most commonly required style combinations: - * <dl> - * <dt><code>SHELL_TRIM</code></dt> - * <dd> - * the result of combining the constants which are required - * to produce a typical application top level shell: (that - * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>) - * </dd> - * <dt><code>DIALOG_TRIM</code></dt> - * <dd> - * the result of combining the constants which are required - * to produce a typical application dialog shell: (that - * is, <code>TITLE | CLOSE | BORDER</code>) - * </dd> - * </dl> - * </p> - * <p> - * Note: Only one of the styles APPLICATION_MODAL, MODELESS, - * PRIMARY_MODAL and SYSTEM_MODAL may be specified. - * </p><p> - * IMPORTANT: This class is not intended to be subclassed. - * </p> - * - * @see Decorations - * @see SWT - */ -public /*final*/ class Shell extends Decorations { - Display display; - int shellHandle; - /* AW - boolean reparented, realized; - */ - boolean realized; +import org.eclipse.swt.graphics.*; - int oldX, oldY, oldWidth, oldHeight; +public class Shell extends Decorations { + Display display; + int shellHandle, windowGroup; + boolean resized; Control lastActive; - // AW - private boolean fIsEnabled= true; - // AW - -/** - * 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#NO_TRIM - * @see SWT#SHELL_TRIM - * @see SWT#DIALOG_TRIM - * @see SWT#MODELESS - * @see SWT#PRIMARY_MODAL - * @see SWT#APPLICATION_MODAL - * @see SWT#SYSTEM_MODAL - */ + 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.SHELL_TRIM); } -/** - * Constructs a new instance of this class given the display - * to create it on and a style value describing its behavior - * and appearance. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * 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#NO_TRIM - * @see SWT#SHELL_TRIM - * @see SWT#DIALOG_TRIM - * @see SWT#MODELESS - * @see SWT#PRIMARY_MODAL - * @see SWT#APPLICATION_MODAL - * @see SWT#SYSTEM_MODAL - */ + public Shell (Display display, int style) { this (display, null, style, 0); } + Shell (Display display, Shell parent, int style, int handle) { super (); - + checkSubclass (); if (display == null) display = Display.getCurrent (); if (display == null) display = Display.getDefault (); if (!display.isValidThread ()) { @@ -238,75 +48,13 @@ Shell (Display display, Shell parent, int style, int handle) { this.parent = parent; this.display = display; this.handle = handle; - createWidget (0); + createWidget (); } -/** - * Constructs a new instance of this class given only its - * parent. It is created with style <code>SWT.DIALOG_TRIM</code>. - * <p> - * Note: Currently, null can be passed in for the parent. - * This has the effect of creating the shell on the currently active - * display if there is one. If there is no current display, the - * shell is created on a "default" display. <b>Passing in null as - * the parent is not considered to be good coding style, - * and may not be supported in a future release of SWT.</b> - * </p> - * - * @param parent a shell which will be the parent of the new instance - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ + public Shell (Shell parent) { this (parent, SWT.DIALOG_TRIM); } -/** - * Constructs a new instance of this class given its parent - * and a style value describing its behavior and appearance. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * 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 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#MODELESS - * @see SWT#PRIMARY_MODAL - * @see SWT#APPLICATION_MODAL - * @see SWT#SYSTEM_MODAL - */ + public Shell (Shell parent, int style) { this (parent != null ? parent.getDisplay () : null, parent, style, 0); } @@ -321,29 +69,6 @@ static int checkStyle (int style) { return bits; } -public static Shell macosx_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); @@ -354,520 +79,167 @@ public void addShellListener(ShellListener listener) { addListener(SWT.Iconify,typedListener); addListener(SWT.Deiconify,typedListener); } -void adjustTrim () { - /* AW - if (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) { - return; - } - */ - - /* Query the trim insets */ - /* AW - int shellWindow = OS.XtWindow (shellHandle); - if (shellWindow == 0) return; - int xDisplay = OS.XtDisplay (shellHandle); - if (xDisplay == 0) return; - */ - - /* Find the direct child of the root window */ - /* AW - int [] unused = new int [1]; - int [] rootWindow = new int [1]; - int [] parent = new int [1]; - int [] ptr = new int [1]; - int trimWindow = shellWindow; - OS.XQueryTree (xDisplay, trimWindow, rootWindow, parent, ptr, unused); - if (ptr [0] != 0) OS.XFree (ptr [0]); - if (parent [0] == 0) return; - while (parent [0] != rootWindow [0]) { - trimWindow = parent [0]; - OS.XQueryTree (xDisplay, trimWindow, unused, parent, ptr, unused); - if (ptr [0] != 0) OS.XFree (ptr [0]); - if (parent [0] == 0) return; - } - */ - /* - * Translate the coordinates of the shell window to the - * coordinates of the direct child of the root window - */ - /* AW - if (shellWindow == trimWindow) return; - */ - - /* Query the border width of the direct child of the root window */ - /* - int [] trimBorder = new int [1]; - int [] trimWidth = new int [1]; - int [] trimHeight = new int [1]; - OS.XGetGeometry (xDisplay, trimWindow, unused, unused, unused, trimWidth, trimHeight, trimBorder, unused); - */ - - /* Query the border width of the direct child of the shell window */ - /* - int [] shellBorder = new int [1]; - int [] shellWidth = new int [1]; - int [] shellHeight = new int [1]; - OS.XGetGeometry (xDisplay, shellWindow, unused, unused, unused, shellWidth, shellHeight, shellBorder, unused); - */ - - /* Calculate the trim */ - /* - int width = (trimWidth [0] + (trimBorder [0] * 2)) - (shellWidth [0] + (shellBorder [0] * 2)); - int height = (trimHeight [0] + (trimBorder [0] * 2)) - (shellHeight [0] + (shellBorder [0] * 2)); - */ - - /* Update the trim guesses to match the query */ - /* - boolean hasTitle = false, hasResize = false, hasBorder = false; - if ((style & SWT.NO_TRIM) == 0) { - hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0; - hasResize = (style & SWT.RESIZE) != 0; - hasBorder = (style & SWT.BORDER) != 0; - } - if (hasTitle) { - if (hasResize) { - display.titleResizeTrimWidth = width; - display.titleResizeTrimHeight = height; - return; - } - if (hasBorder) { - display.titleBorderTrimWidth = width; - display.titleBorderTrimHeight = height; - return; - } - display.titleTrimWidth = width; - display.titleTrimHeight = height; - return; - } - if (hasResize) { - display.resizeTrimWidth = width; - display.resizeTrimHeight = height; - return; - } - if (hasBorder) { - display.borderTrimWidth = width; - display.borderTrimHeight = height; - return; - } - */ -} -/** - * Requests that the window manager close the receiver in - * the same way it would be closed when the user clicks on - * the "close box" or performs some other platform specific - * key or mouse combination that indicates the window - * should be removed. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #dispose - */ public void close () { checkWidget(); closeWidget (); } + void closeWidget () { - - // remove focus - getDisplay().setMacFocusHandle(shellHandle, 0); - - if (!isEnabled ()) return; - Control widget = parent; - while (widget != null && !(widget.getShell ().isModal ())) { - widget = widget.parent; - } - if (widget == null) { - Shell [] shells = getShells (); - for (int i=0; i<shells.length; i++) { - Shell shell = shells [i]; - if (shell != this && shell.isModal () && shell.isVisible ()) { - shell.bringToTop (); - return; - } - } - } Event event = new Event (); sendEvent (SWT.Close, event); if (event.doit && !isDisposed ()) dispose (); } + public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget(); Rectangle trim = super.computeTrim (x, y, width, height); - int trimWidth = trimWidth (), trimHeight = trimHeight (); - trim.x -= trimWidth / 2; trim.y -= trimHeight - (trimWidth / 2); - trim.width += trimWidth; trim.height += trimHeight + imeHeight (); + Rect rect = new Rect (); + OS.GetWindowStructureWidths (shellHandle, rect); + trim.x -= rect.left; + trim.y -= rect.top; + trim.width += rect.left + rect.right; + trim.height += rect.top + rect.bottom; return trim; } -void createHandle (int index) { - state |= HANDLE | CANVAS; - - int decorations = 0; - /* AW + +void createHandle () { + state |= CANVAS | GRAB | HIDDEN; + int attributes = OS.kWindowStandardHandlerAttribute; // | OS.kWindowCompositingAttribute; if ((style & SWT.NO_TRIM) == 0) { - if ((style & SWT.MIN) != 0) decorations |= NSWindow.MiniaturizableWindowMask; - if ((style & SWT.MAX) != 0) decorations |= OS.MWM_DECOR_MAXIMIZE; - if ((style & SWT.RESIZE) != 0) decorations |= NSWindow.ResizableWindowMask; - if ((style & SWT.BORDER) != 0) decorations |= NSWindow.BorderlessWindowMask; - if ((style & SWT.MENU) != 0) decorations |= OS.MWM_DECOR_MENU; - if ((style & SWT.TITLE) != 0) decorations |= NSWindow.TitledWindowMask; - } - */ - - if (MacUtil.HIVIEW) - decorations |= OS.kWindowCompositingAttribute; - - if (style == SWT.NONE) { - } else if ((style & SWT.NO_TRIM) == 0) { - if ((style & SWT.CLOSE) != 0) decorations |= OS.kWindowCloseBoxAttribute; - if ((style & SWT.MIN) != 0) decorations |= OS.kWindowCollapseBoxAttribute; - if ((style & SWT.MAX) != 0) decorations |= OS.kWindowFullZoomAttribute; - if ((style & SWT.RESIZE) != 0) decorations |= OS.kWindowResizableAttribute | OS.kWindowLiveResizeAttribute; - //if ((style & SWT.BORDER) == 0) decorations |= OS.kWindowNoShadowAttribute; - //} else { - // decorations |= OS.kWindowNoShadowAttribute; - } - - /* AW - int inputMode = OS.MWM_INPUT_MODELESS; - if ((style & SWT.PRIMARY_MODAL) != 0) inputMode = OS.MWM_INPUT_PRIMARY_APPLICATION_MODAL; - if ((style & SWT.APPLICATION_MODAL) != 0) inputMode = OS.MWM_INPUT_FULL_APPLICATION_MODAL; - if ((style & SWT.SYSTEM_MODAL) != 0) inputMode = OS.MWM_INPUT_SYSTEM_MODAL; - */ - int inputMode = OS.kWindowModalityNone; - if ((style & SWT.PRIMARY_MODAL) != 0) inputMode = OS.kWindowModalityWindowModal; - if ((style & SWT.APPLICATION_MODAL) != 0) inputMode = OS.kWindowModalityAppModal; - if ((style & SWT.SYSTEM_MODAL) != 0) inputMode = OS.kWindowModalitySystemModal; - - /* AW - int [] argList1 = { - OS.XmNmwmInputMode, inputMode, - OS.XmNmwmDecorations, decorations, - OS.XmNoverrideRedirect, (style & SWT.ON_TOP) != 0 ? 1 : 0, - OS.XmNtitle, ptr, - }; - byte [] appClass = display.appClass; - */ - - MacRect bounds= new MacRect(100, 100, 100, 100); - int windowClass= 0; - short themeBrush= OS.kThemeBrushDialogBackgroundActive; - if (parent == null && (style & SWT.ON_TOP) == 0) { - /* AW - int xDisplay = display.xDisplay; - int widgetClass = OS.TopLevelShellWidgetClass (); - shellHandle = OS.XtAppCreateShell (display.appName, appClass, widgetClass, xDisplay, argList1, argList1.length / 2); - */ - if ((style & SWT.NO_TRIM) != 0) - windowClass= OS.kHelpWindowClass; - else { - windowClass= OS.kDocumentWindowClass; - //themeBrush= OS.kThemeBrushDocumentWindowBackground; - } - } else { - /* AW - int widgetClass = OS.TransientShellWidgetClass (); -// if ((style & SWT.ON_TOP) != 0) { -// widgetClass = OS.OverrideShellWidgetClass (); -// } - */ - /* AW - int parentHandle = display.shellHandle; - if (parent != null) parentHandle = parent.handle; - shellHandle = OS.XtCreatePopupShell (appClass, widgetClass, parentHandle, argList1, argList1.length / 2); - */ - if (style == SWT.NONE) { - //System.out.println("Shell.createHandle: SWT.NONE"); - windowClass= OS.kHelpWindowClass; - } else if ((style & SWT.NO_TRIM) != 0 && (style & SWT.ON_TOP) != 0) { - //System.out.println("Shell.createHandle: SWT.NO_TRIM | SWT.ON_TOP"); - windowClass= OS.kHelpWindowClass; - } else if ((style & SWT.NO_TRIM) != 0) { - //System.out.println("Shell.createHandle: SWT.NO_TRIM"); - windowClass= OS.kHelpWindowClass; - } else if (inputMode == OS.kWindowModalityAppModal) { - //System.out.println("Shell.createHandle: kMovableModalWindowClass"); - windowClass= OS.kMovableModalWindowClass; - } else if (inputMode == OS.kWindowModalitySystemModal) { - //System.out.println("Shell.createHandle: kModalWindowClass"); - windowClass= OS.kModalWindowClass; - } else if ((style & SWT.ON_TOP) != 0) { - //System.out.println("Shell.createHandle: SWT.ON_TOP"); - //windowClass= OS.kFloatingWindowClass; - windowClass= OS.kHelpWindowClass; - decorations= 0; - } else { - //System.out.println("Shell.createHandle: kDocumentWindowClass"); - windowClass= OS.kDocumentWindowClass; + if ((style & SWT.CLOSE) != 0) attributes |= OS.kWindowCloseBoxAttribute; + if ((style & SWT.MIN) != 0) attributes |= OS.kWindowCollapseBoxAttribute; + if ((style & SWT.MAX) != 0) attributes |= OS.kWindowFullZoomAttribute; + if ((style & SWT.RESIZE) != 0) { + attributes |= OS.kWindowResizableAttribute | OS.kWindowLiveResizeAttribute; } } - - // check whether window class supports a given decoration - if ((decorations & OS.kWindowCloseBoxAttribute) != 0 && - windowClass != OS.kDocumentWindowClass && - windowClass != OS.kFloatingWindowClass && - windowClass != OS.kUtilityWindowClass) { - decorations&= ~OS.kWindowCloseBoxAttribute; - } - if ((decorations & OS.kWindowFullZoomAttribute) != 0 && - windowClass != OS.kDocumentWindowClass && - windowClass != OS.kFloatingWindowClass && - windowClass != OS.kUtilityWindowClass) { - decorations&= ~OS.kWindowFullZoomAttribute; - } - if ((decorations & OS.kWindowCollapseBoxAttribute) != 0 && - windowClass != OS.kDocumentWindowClass) { - decorations&= ~OS.kWindowCollapseBoxAttribute; - } - if ((decorations & OS.kWindowCollapseBoxAttribute) != 0 && - windowClass != OS.kDocumentWindowClass && - windowClass != OS.kMovableModalWindowClass && - windowClass != OS.kFloatingWindowClass && - windowClass != OS.kUtilityWindowClass && - windowClass != OS.kSheetWindowClass) { - decorations&= ~OS.kWindowCollapseBoxAttribute; - } - - int[] wHandle= new int[1]; - if (OS.CreateNewWindow(windowClass, decorations | OS.kWindowStandardHandlerAttribute, bounds.getData(), wHandle) == OS.kNoErr) - shellHandle= wHandle[0]; - else { - System.out.println("Shell.createHandle: can't create window with these attributes; creating default window"); - if (OS.CreateNewWindow(OS.kDocumentWindowClass, OS.kWindowStandardHandlerAttribute, bounds.getData(), wHandle) == OS.kNoErr) - shellHandle= wHandle[0]; + int windowClass = OS.kDocumentWindowClass; + if ((style & (SWT.CLOSE | SWT.TITLE)) == 0) windowClass = OS.kSheetWindowClass; +// int windowClass = parent == null ? OS.kDocumentWindowClass : OS.kSheetWindowClass; +// if ((style & SWT.APPLICATION_MODAL) != 0) windowClass = OS.kMovableModalWindowClass; +// if ((style & SWT.SYSTEM_MODAL) != 0) windowClass = OS.kModalWindowClass; + Rect rect = new Rect (); + OS.GetAvailableWindowPositioningBounds (OS.GetMainDevice (), rect); + int width = (rect.right - rect.left) * 5 / 8; + int height = (rect.bottom - rect.top) * 5 / 8; + OS.SetRect (rect, (short) 0, (short) 0, (short) width, (short) height); + int [] outWindow = new int [1]; + attributes &= OS.GetAvailableWindowAttributes (windowClass); + OS.CreateNewWindow (windowClass, attributes, rect, outWindow); + if (outWindow [0] == 0) error (SWT.ERROR_NO_HANDLES); + shellHandle = outWindow [0]; + if ((style & SWT.ON_TOP) != 0) { + OS.SetWindowActivationScope (shellHandle, OS.kWindowActivationScopeNone); + } + OS.RepositionWindow (shellHandle, 0, OS.kWindowCascadeOnMainScreen); + OS.SetThemeWindowBackground (shellHandle, (short) OS.kThemeBrushDialogBackgroundActive, false); + int [] theRoot = new int [1]; + OS.CreateRootControl (shellHandle, theRoot); + OS.GetRootControl (shellHandle, theRoot); + if (theRoot [0] == 0) error (SWT.ERROR_NO_HANDLES); + if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) { + createScrolledHandle (theRoot [0]); + } else { + createHandle (theRoot [0]); } - - if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES); - - if (themeBrush != 0) - OS.SetThemeWindowBackground(shellHandle, themeBrush, false); - - // set modality - if (inputMode != OS.kWindowModalityNone) { - int parentShellHandle= 0; - if (parent != null) parentShellHandle = parent.handle; - //System.out.println("Shell.createHandle: OS.SetWindowModality: " + inputMode); - OS.SetWindowModality(shellHandle, inputMode, parentShellHandle); + int [] outGroup = new int [1]; + OS.CreateWindowGroup (OS.kWindowGroupAttrHideOnCollapse, outGroup); + if (outGroup [0] == 0) error (SWT.ERROR_NO_HANDLES); + windowGroup = outGroup [0]; + if (parent != null) { + Shell shell = parent.getShell (); + int parentGroup = shell.windowGroup; + OS.SetWindowGroup (shellHandle, parentGroup); + OS.SetWindowGroupParent (windowGroup, parentGroup); + } else { + int parentGroup = OS.GetWindowGroupOfClass (windowClass); + OS.SetWindowGroupParent (windowGroup, parentGroup); } + OS.SetWindowGroupOwner (windowGroup, shellHandle); +} - /* Create scrolled handle */ - createScrolledHandle (shellHandle); - - /* - * Feature in Motif. There is no way to get the single pixel - * border surrounding a TopLevelShell or a TransientShell. - * Also, attempts to set a border on either the shell handle - * or the main window handle fail. The fix is to set the border - * on the client area. - */ - /* AW - if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) { - int [] argList2 = {OS.XmNborderWidth, 1}; - OS.XtSetValues (handle, argList2, argList2.length / 2); - } - */ +void createWidget () { + super.createWidget (); + layoutControl (); } + void deregister () { super.deregister (); - WidgetTable.remove (shellHandle); -} -void destroyWidget () { - /* - * Hide the shell before calling XtDestroyWidget () - * so that the shell will disappear without having - * to dispatch events. Otherwise, the user will be - * able to interact with the trimmings between the - * time that the shell is destroyed and the next - * event is dispatched. - */ - /* AW - if (OS.XtIsRealized (shellHandle)) { - if (OS.XtIsTopLevelShell (shellHandle)) { - OS.XtUnmapWidget (shellHandle); - } else { - OS.XtPopdown (shellHandle); - } - } - */ - OS.HideWindow(shellHandle); - super.destroyWidget (); + int [] theRoot = new int [1]; + OS.GetRootControl (shellHandle, theRoot); + WidgetTable.remove (theRoot [0]); } public void dispose () { - /* - * Note: It is valid to attempt to dispose a widget - * more than once. If this happens, fail silently. - */ if (isDisposed()) return; - - /* - * This code is intentionally commented. On some - * platforms, the owner window is repainted right - * away when the dialog window exits. This behavior - * is currently unspecified. - */ -// if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); -// Display oldDisplay = display; - - /* - * Feature in Motif. When an override-redirected shell - * is disposed, Motif does not assign a new active top - * level shell. The parent shell appears to be active, - * but XGetInputFocus returns the root window, not the - * parent. The fix is to make the parent be the active - * top level shell when the child shell is disposed. - */ - /* AW - Composite parent = this.parent; - int [] argList = {OS.XmNoverrideRedirect, 0}; - OS.XtGetValues (shellHandle, argList, argList.length / 2); - */ super.dispose (); - /* AW - if (parent != null && argList [1] != 0) { - Shell shell = parent.getShell (); - shell.bringToTop (); - } - */ +} - /* - * This code intentionally commented. - */ -// if (oldDisplay != null) oldDisplay.update (); +void destroyWidget () { + int theWindow = shellHandle; +// OS.HideWindow (shellHandle); + releaseHandle (); + if (theWindow != 0) OS.DisposeWindow (theWindow); } -void enableWidget (boolean enabled) { - super.enableWidget (enabled); - enableHandle (enabled, shellHandle); + +Cursor findCursor () { + return cursor; } -/** - * Moves the receiver to the top of the drawing order for - * the display on which it was created (so that all other - * shells on that display, which are not the receiver's - * children will be drawn behind it) and forces the window - * manager to make the shell active. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @since 2.0 - * @see Control#moveAbove - * @see Control#setFocus - * @see Control#setVisible - * @see Display#getActiveShell - * @see Decorations#setDefaultButton - * @see Shell#open - * @see Shell#setActive - */ + public void forceActive () { checkWidget (); - OS.SelectWindow(shellHandle); + OS.SetFrontProcess (new int [] {0, OS.kCurrentProcess}); + OS.SelectWindow (shellHandle); } -public int getBorderWidth () { + +public Rectangle getClientArea () { checkWidget(); - /* AW - int [] argList = {OS.XmNborderWidth, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - return argList [1]; - */ - return 0; + Rect rect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowContentRgn, rect); + return new Rectangle (0, 0, rect.right - rect.left, rect.bottom - rect.top); } + public Rectangle getBounds () { checkWidget(); - /* AW - short [] root_x = new short [1], root_y = new short [1]; - OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y); - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - int border = argList [5]; - */ - - MacRect contentBounds= new MacRect(); - OS.GetWindowBounds(shellHandle, OS.kWindowContentRgn, contentBounds.getData()); - - MacRect bounds= new MacRect(); - OS.GetControlBounds(scrolledHandle, bounds.getData()); - int trimWidth = trimWidth (), trimHeight = trimHeight (); - int border= 0; - /* AW - int width = argList [1] + trimWidth + (border * 2); - int height = argList [3] + trimHeight + (border * 2); - return new Rectangle (root_x [0], root_y [0], width, height); - */ - int width = bounds.getWidth() + trimWidth + (border * 2); - int height = bounds.getHeight() + trimHeight + (border * 2); - Rectangle r= new Rectangle (contentBounds.getX(), contentBounds.getY(), width, height); - return r; - - /* - OS.GetWindowBounds(shellHandle, OS.kWindowContentRgn, bounds.getData()); - Rectangle r= bounds.toRectangle(); - System.out.println("Shell.getBounds: fixme " + r); // should be the contentView - return r; - */ + Rect rect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); + return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } + public Display getDisplay () { if (display == null) error (SWT.ERROR_WIDGET_DISPOSED); return display; } -// AW -public boolean getEnabled () { - checkWidget(); - return fIsEnabled; -} -// AW -/** - * 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 SWT.NONE; } + public Point getLocation () { checkWidget(); - /* AW - short [] root_x = new short [1], root_y = new short [1]; - OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y); - return new Point (root_x [0], root_y [0]); - */ - // returns the location of the contentArea - MacRect bounds= new MacRect(); - OS.GetWindowBounds(shellHandle, OS.kWindowContentRgn, bounds.getData()); - return bounds.getLocation(); + Rect rect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); + return new Point (rect.left, rect.top); +} + +public boolean getMaximized () { + checkWidget(); + //NOT DONE + return super.getMaximized (); } + +public boolean getMinimized () { + checkWidget(); + return OS.IsWindowCollapsed (shellHandle); +} + public Shell getShell () { checkWidget(); return this; } -/** - * Returns an array containing all shells which are - * descendents of the receiver. - * <p> - * @return the dialog shells - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Shell [] getShells () { checkWidget(); int count = 0; @@ -892,348 +264,198 @@ public Shell [] getShells () { } return result; } + public Point getSize () { checkWidget(); - //System.out.println("Shell.getSize: " + shellHandle); - /* AW - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - int border = argList [5]; - */ - MacRect bounds= new MacRect(); - OS.GetControlBounds(scrolledHandle, bounds.getData()); - int trimWidth = trimWidth (), trimHeight = trimHeight (); - int border = 0; - /* AW - int width = argList [1] + trimWidth + (border * 2); - int height = argList [3] + trimHeight + (border * 2); - return new Point (width, height); - */ - int width = bounds.getWidth() + trimWidth + (border * 2); - int height = bounds.getHeight() + trimHeight + (border * 2); - Point p= new Point (width, height); - //System.out.println(" Shell.getSize: " + p); - return p; + Rect rect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); + return new Point (rect.right - rect.left, rect.bottom - rect.top); } + public boolean getVisible () { checkWidget(); - /* AW - if (!OS.XtIsRealized (handle)) return false; - int xDisplay = OS.XtDisplay (handle); - if (xDisplay == 0) return false; - int xWindow = OS.XtWindow (handle); - if (xWindow == 0) return false; - XWindowAttributes attributes = new XWindowAttributes (); - OS.XGetWindowAttributes (xDisplay, xWindow, attributes); - if (attributes.map_state == OS.IsViewable) return true; - int [] argList = {OS.XmNmappedWhenManaged, 0}; - OS.XtGetValues (shellHandle, argList, argList.length / 2); - return minimized && attributes.map_state == OS.IsUnviewable && argList [1] != 0; - */ - return OS.IsWindowVisible(shellHandle); + return OS.IsWindowVisible (shellHandle); +} + +boolean hasBorder () { + return false; } + void hookEvents () { super.hookEvents (); - /* AW + int mouseProc = display.mouseProc; int windowProc = display.windowProc; - OS.XtAddEventHandler (shellHandle, OS.StructureNotifyMask, false, windowProc, SWT.Resize); - if (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) return; - OS.XtAddEventHandler (shellHandle, OS.FocusChangeMask, false, windowProc, SWT.FocusIn); - int [] argList = {OS.XmNdeleteResponse, OS.XmDO_NOTHING}; - OS.XtSetValues (shellHandle, argList, argList.length / 2); - int xDisplay = OS.XtDisplay (shellHandle); - if (xDisplay != 0) { - int atom = OS.XmInternAtom (xDisplay, WM_DELETE_WINDOW, false); - OS.XmAddWMProtocolCallback (shellHandle, atom, windowProc, SWT.Dispose); - } - */ - Display display= getDisplay(); - int ref= OS.GetWindowEventTarget(shellHandle); - int[] mask= new int[] { + int[] mask1 = new int [] { OS.kEventClassWindow, OS.kEventWindowActivated, - OS.kEventClassWindow, OS.kEventWindowDeactivated, OS.kEventClassWindow, OS.kEventWindowBoundsChanged, OS.kEventClassWindow, OS.kEventWindowClose, - OS.kEventClassWindow, OS.kEventWindowDrawContent, - - // the window only tracks the down and mouse wheel events; - // up, dragged, and move events are handled by the application because - // we need to get these events even if the mouse is outside of the window. + OS.kEventClassWindow, OS.kEventWindowCollapsed, + OS.kEventClassWindow, OS.kEventWindowDeactivated, + OS.kEventClassWindow, OS.kEventWindowExpanded, + OS.kEventClassWindow, OS.kEventWindowHidden, + OS.kEventClassWindow, OS.kEventWindowShown, + }; + int windowTarget = OS.GetWindowEventTarget (shellHandle); + OS.InstallEventHandler (windowTarget, windowProc, mask1.length / 2, mask1, shellHandle, null); + int [] mask2 = new int [] { OS.kEventClassMouse, OS.kEventMouseDown, + OS.kEventClassMouse, OS.kEventMouseDragged, +// OS.kEventClassMouse, OS.kEventMouseEntered, +// OS.kEventClassMouse, OS.kEventMouseExited, + OS.kEventClassMouse, OS.kEventMouseMoved, + OS.kEventClassMouse, OS.kEventMouseUp, OS.kEventClassMouse, OS.kEventMouseWheelMoved, }; - OS.InstallEventHandler(ref, display.fWindowProc, mask, shellHandle); -} -int imeHeight () { - /* AW - if (!IsDBLocale) return 0; -// realizeWidget (); - int [] argList1 = {OS.XmNheight, 0}; - OS.XtGetValues (shellHandle, argList1, argList1.length / 2); - int [] argList2 = {OS.XmNheight, 0}; - OS.XtGetValues (scrolledHandle, argList2, argList2.length / 2); - return argList1 [1] - argList2 []; - */ - return 0; + OS.InstallEventHandler (windowTarget, mouseProc, mask2.length / 2, mask2, shellHandle, null); } + public boolean isEnabled () { checkWidget(); return getEnabled (); } -boolean isModal () { - checkWidget(); - /* AW - int [] argList = {OS.XmNmwmInputMode, 0}; - OS.XtGetValues (shellHandle, argList, argList.length / 2); - return (argList [1] != -1 && argList [1] != OS.MWM_INPUT_MODELESS); - */ - int[] modalityKind= new int[1]; - if (OS.GetWindowModality(shellHandle, modalityKind, null) == OS.kNoErr) - return modalityKind[0] != OS.kWindowModalityNone; - return false; -} + public boolean isVisible () { checkWidget(); - return getVisible (); + if (getVisible ()) return true; + return parent != null && parent.isVisible (); } -void manageChildren () { - /* AW - OS.XtSetMappedWhenManaged (shellHandle, false); - */ - super.manageChildren (); - int width = MacUtil.getDisplayWidth() * 5 / 8; - int height = MacUtil.getDisplayHeight() * 5 / 8; - OS.SizeWindow(shellHandle, (short)width, (short)height, true); + +int kEventWindowActivated (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowActivated (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + Display display = getDisplay (); + display.updateMenuBar (this); + sendEvent (SWT.Activate); + restoreFocus (); + return result; } -/** - * Moves the receiver to the top of the drawing order for - * the display on which it was created (so that all other - * shells on that display, which are not the receiver's - * children will be drawn behind it), marks it visible, - * and sets focus to its default button (if it has one) - * and asks the window manager to make the shell active. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see Control#moveAbove - * @see Control#setFocus - * @see Control#setVisible - * @see Display#getActiveShell - * @see Decorations#setDefaultButton - * @see Shell#setActive - * @see Shell#forceActive - */ -public void open () { - checkWidget(); - setVisible (true); + +int kEventWindowBoundsChanged (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowBoundsChanged (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + int [] attributes = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamAttributes, OS.typeUInt32, null, attributes.length * 4, null, attributes); + if ((attributes [0] & OS.kWindowBoundsChangeOriginChanged) != 0) { + sendEvent (SWT.Move); + } + if ((attributes [0] & OS.kWindowBoundsChangeSizeChanged) != 0) { + resized = true; + layoutControl (); + sendEvent (SWT.Resize); + if (layout != null) layout.layout (this, false); + } + return result; } -int processDispose (Object callData) { + +int kEventWindowClose (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowClose (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; closeWidget (); - return 0; + return OS.noErr; } -int processResize (Object callData) { - - MacRect bounds= new MacRect(); - - // outside bounds and location - OS.GetWindowBounds(shellHandle, OS.kWindowStructureRgn, bounds.getData()); - int x= bounds.getX(); - int y= bounds.getY(); +int kEventWindowCollapsed (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowCollapsed (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + sendEvent (SWT.Iconify); + return result; +} - // inside bounds and location - OS.GetWindowBounds(shellHandle, OS.kWindowContentRgn, bounds.getData()); - int w= bounds.getWidth(); - int h= bounds.getHeight(); - - boolean positionChanged= (oldX != x || oldY != y); - boolean sizeChanged= (oldWidth != w || oldHeight != h); +int kEventWindowDeactivated (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowDeactivated (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + sendEvent (SWT.Deactivate); + saveFocus (); + if (savedFocus != null) { + /* + * Bug in the Macintosh. When ClearKeyboardFocus() is called, + * the control that has focus gets two kEventControlSetFocus + * events indicating that focus was lost. The fix is to ignore + * both of these and send the focus lost event explicitly.
*/ + display.ignoreFocus = true; + OS.ClearKeyboardFocus (shellHandle); + display.ignoreFocus = false; + savedFocus.sendFocusEvent (false); + } + Display display = getDisplay (); + display.updateMenuBar (null); + return result; +} - if (scrolledHandle != 0 && sizeChanged) { - handleResize(scrolledHandle, new MacRect(0, 0, w, h)); - } - - if (positionChanged) { - //System.out.println("Shell.send: SWT.Move"); - sendEvent(SWT.Move); - } - - if (sizeChanged) { - //System.out.println("Shell.send: SWT.Resize"); - sendEvent (SWT.Resize); - if (layout != null) - layout (false); - } - - if (!OS.IsWindowVisible(shellHandle)) - return 0; +int kEventWindowExpanded (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowExpanded (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + sendEvent (SWT.Deiconify); + return result; +} - - if (x != 0) oldX = x; - if (y != 0) oldY = y; - oldWidth = w; - oldHeight = h; - - /* AW - XConfigureEvent xEvent = new XConfigureEvent (); - OS.memmove (xEvent, callData, XConfigureEvent.sizeof); - switch (xEvent.type) { - case OS.ReparentNotify: { - if (reparented) return 0; - reparented = true; - short [] root_x = new short [1], root_y = new short [1]; - OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y); - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0}; - OS.XtGetValues (scrolledHandle, argList, argList.length / 2); - xEvent.x = root_x [0]; xEvent.y = root_y [0]; - xEvent.width = argList [1]; xEvent.height = argList [3]; - // fall through - } - case OS.ConfigureNotify: - if (!reparented) return 0; - if (oldX != xEvent.x || oldY != xEvent.y) sendEvent (SWT.Move); - if (oldWidth != xEvent.width || oldHeight != xEvent.height) { - sendEvent (SWT.Resize); - if (layout != null) layout (false); - } - if (xEvent.x != 0) oldX = xEvent.x; - if (xEvent.y != 0) oldY = xEvent.y; - oldWidth = xEvent.width; - oldHeight = xEvent.height; - return 0; - case OS.UnmapNotify: - int [] argList = {OS.XmNmappedWhenManaged, 0}; - OS.XtGetValues (shellHandle, argList, argList.length / 2); - if (argList [1] != 0) { - minimized = true; - sendEvent (SWT.Iconify); - } - return 0; - case OS.MapNotify: - if (minimized) { - minimized = false; - sendEvent (SWT.Deiconify); - } - return 0; +int kEventWindowHidden (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowHidden (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + Shell [] shells = getShells (); + for (int i=0; i<shells.length; i++) { + Shell shell = shells [i]; + if (!shell.isDisposed ()) shell.setWindowVisible (false); } - */ - return 0; + return OS.eventNotHandledErr; } -int processSetFocus (Object callData) { - /* AW - XFocusChangeEvent xEvent = new XFocusChangeEvent (); - OS.memmove (xEvent, callData, XFocusChangeEvent.sizeof); - int handle = OS.XtWindowToWidget (xEvent.display, xEvent.window); - */ - int handle = shellHandle; // AW FIXME fake - if (handle != shellHandle) return super.processSetFocus (callData); - - /* AW - if (xEvent.mode != OS.NotifyNormal) return 0; - if (xEvent.detail != OS.NotifyNonlinear) return 0; - switch (xEvent.type) { - case OS.FocusIn: - postEvent (SWT.Activate); - break; - case OS.FocusOut: - postEvent (SWT.Deactivate); - break; - } - */ - - Menu menuBar= getMenuBar(); - Boolean b= (Boolean) callData; - - /* - if (OS.IsWindowActive(shellHandle) != b.booleanValue()) { - System.out.println("Shell.processSetFocus: " + b); - return 0; - } - */ - - if (b.booleanValue()) { - if (menuBar != null) { - OS.SetRootMenu(menuBar.handle); +int kEventWindowShown (int nextHandler, int theEvent, int userData) { + int result = super.kEventWindowShown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + Shell [] shells = getShells (); + for (int i=0; i<shells.length; i++) { + Shell shell = shells [i]; + if (!shell.isDisposed () && shell.getVisible ()) { + shell.setWindowVisible (true); } - postEvent (SWT.Activate); - /* - if (!isDisposed()) - restoreFocus (); - */ - } else { - //if (menuBar != null) - // OS.ReleaseMenu(menuBar.handle); - - /* - setActiveControl (null); - - if (isDisposed()) return 0; - */ - postEvent (SWT.Deactivate); - /* - if (!isDisposed()) - saveFocus (); - */ } - return 0; + return OS.eventNotHandledErr; } -void propagateWidget (boolean enabled) { - super.propagateWidget (enabled); - propagateHandle (enabled, shellHandle); + +void layoutControl () { + Rect rect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowContentRgn, rect); + int control = scrolledHandle != 0 ? scrolledHandle : handle; + setBounds (control, 0, 0, rect.right - rect.left, rect.bottom - rect.top, false, true, false); + super.layoutControl (); } -void realizeWidget () { - if (realized) return; - /* AW - OS.XtRealizeWidget (shellHandle); - */ - realizeChildren (); - realized = true; + +public void open () { + checkWidget(); + OS.SelectWindow (shellHandle); + setVisible (true); + if (!restoreFocus ()) traverseGroup (true); } + void register () { super.register (); - WidgetTable.put (shellHandle, this); + int [] theRoot = new int [1]; + OS.GetRootControl (shellHandle, theRoot); + WidgetTable.put (theRoot [0], this); } + void releaseHandle () { super.releaseHandle (); shellHandle = 0; } + void releaseShells () { Shell [] shells = getShells (); for (int i=0; i<shells.length; i++) { Shell shell = shells [i]; - if (!shell.isDisposed ()) { - shell.releaseWidget (); - shell.releaseHandle (); - } + if (!shell.isDisposed ()) shell.dispose (); } } + void releaseWidget () { releaseShells (); super.releaseWidget (); - display = null; + if (windowGroup != 0) OS.ReleaseWindowGroup (windowGroup); + windowGroup = 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); @@ -1244,27 +466,17 @@ public void removeShellListener(ShellListener listener) { eventTable.unhook(SWT.Iconify,listener); eventTable.unhook(SWT.Deiconify,listener); } -void saveBounds () { -/* - MacRect bounds= new MacRect(); - - // outside bounds and location - OS.GetWindowBounds(shellHandle, OS.kWindowStructureRgn, bounds.getData()); - oldX = bounds.getX(); - oldY = bounds.getY(); - - // inside bounds and location - OS.GetWindowBounds(shellHandle, OS.kWindowContentRgn, bounds.getData()); - oldWidth = bounds.getWidth(); - oldHeight = bounds.getHeight(); -*/ + +public void setActive () { + checkWidget (); + OS.SelectWindow (shellHandle); } 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 @@ -1278,7 +490,7 @@ void setActiveControl (Control control) { if (activate [index] != deactivate [index]) break; index++; } - + /* * It is possible (but unlikely), that application * code could have destroyed some of the widgets. If @@ -1298,229 +510,115 @@ void setActiveControl (Control control) { } public void setBounds (int x, int y, int width, int height) { - checkWidget(); - /* - * Feature in Motif. Motif will not allow a window - * to have a zero width or zero height. The fix is - * to ensure these values are never zero. - */ - saveBounds (); - int newWidth = Math.max (width - trimWidth (), 1); - int newHeight = Math.max (height - trimHeight (), 1); - - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - - OS.MoveWindow(shellHandle, (short)x, (short)y, false); - OS.SizeWindow(shellHandle, (short)newWidth, (short)newHeight, true); - //processResize (null); - - if (isFocus) caret.setFocus (); -} -// AW -public void setEnabled (boolean enabled) { - fIsEnabled= enabled; - super.setEnabled(enabled); + checkWidget (); + width = Math.max (0, width); + height = Math.max (0, height); + Rect rect = new Rect (); + OS.SetRect (rect, (short) x, (short) y, (short) (x + width), (short) (y + height)); + OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); } -// AW -/** - * 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 setLocation (int x, int y) { checkWidget(); - saveBounds (); - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - OS.MoveWindow(shellHandle, (short)x, (short)y, true); - //processResize(null); - if (isFocus) caret.setFocus (); + Rect rect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + OS.SetRect (rect, (short) x, (short) y, (short) (x + width), (short) (y + height)); + OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); } -public void setMinimized (boolean minimized) { + +public void setMaximized (boolean maximized) { checkWidget(); + super.setMaximized (maximized); + org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); + short inPartCode = (short) (maximized ? OS.inZoomOut : OS.inZoomIn); + //FIXME - returns -50 errParam + OS.ZoomWindowIdeal (shellHandle, inPartCode, pt); +} - /* - * Bug in MOTIF. For some reason, the receiver does not keep the - * value of the XmNiconic resource up to date when the user minimizes - * and restores the window. As a result, a window that is minimized - * by the user and then restored by the programmer is not restored. - * This happens because the XmNiconic resource is unchanged when the - * window is minimized by the user and subsequent attempts to set the - * resource fail because the new value of the resource is the same as - * the old value. The fix is to force XmNiconic to be up to date - * before setting the desired value. - */ - /* AW - int [] argList = {OS.XmNiconic, 0}; - OS.XtGetValues (shellHandle, argList, argList.length / 2); - if ((argList [1] != 0) != this.minimized) { - argList [1] = this.minimized ? 1 : 0; - OS.XtSetValues (shellHandle, argList, argList.length / 2); - } - */ - - /* Minimize or restore the shell */ - /* AW - argList [1] = (this.minimized = minimized) ? 1 : 0; - OS.XtSetValues (shellHandle, argList, argList.length / 2); - */ - - /* Force the XWindowAttributes to be up to date */ - /* - int xDisplay = OS.XtDisplay (handle); - if (xDisplay != 0) OS.XSync (xDisplay, false); - */ - - OS.CollapseWindow(shellHandle, true); +public void setMinimized (boolean minimized) { + checkWidget(); + super.setMinimized (minimized); + OS.CollapseWindow (shellHandle, true); } public void setSize (int width, int height) { checkWidget(); - saveBounds (); - int newWidth = Math.max (width - trimWidth (), 1); - int newHeight = Math.max (height - trimHeight (), 1); - boolean isFocus = caret != null && caret.isFocusCaret (); - if (isFocus) caret.killFocus (); - OS.SizeWindow(shellHandle, (short)newWidth, (short)newHeight, true); - //processResize (null); - if (isFocus) caret.setFocus (); + width = Math.max (0, width); + height = Math.max (0, height); + Rect rect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); + OS.SetRect (rect, rect.left, rect.top, (short)(rect.left + width), (short)(rect.top + height)); + OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); } + public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); super.setText (string); - int sHandle= 0; - try { - sHandle= OS.CFStringCreateWithCharacters(string); - OS.SetWindowTitleWithCFString(shellHandle, sHandle); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + OS.SetWindowTitleWithCFString (shellHandle, ptr); + OS.CFRelease (ptr); } + public void setVisible (boolean visible) { checkWidget(); - realizeWidget (); - - /* Show the shell */ if (visible) { - - sendEvent (SWT.Show); - if (isDisposed ()) return; + if ((state & HIDDEN) == 0) return; + state &= ~HIDDEN; + } else { + if ((state & HIDDEN) != 0) return; + state |= HIDDEN; + } + if (parent != null && !parent.isVisible ()) return; + setWindowVisible (visible); +} - /* Map the widget */ - /* AW - OS.XtSetMappedWhenManaged (shellHandle, true); - if (OS.XtIsTopLevelShell (shellHandle)) { - OS.XtMapWidget (shellHandle); - } else { - OS.XtPopup (shellHandle, OS.XtGrabNone); +void setWindowVisible (boolean visible) { + if (OS.IsWindowVisible (shellHandle) == visible) return; + if (visible) { + if (!resized) { + sendEvent (SWT.Resize); + if (layout != null) layout.layout (this, false); } - */ - OS.ShowWindow(shellHandle); - //OS.SelectWindow(shellHandle); - OS.BringToFront(shellHandle); - - processResize (null); - - // find focus - //if (savedFocus == null) - // setFocus(); - - /* - * Force the shell to be fully exposed before returning. - * This ensures that the shell coordinates are correct - * when queried directly after showing the shell. - */ - do { - display.update (); - } while (!isVisible ()); - - //adjustTrim (); - - /* Set the saved focus widget */ - /* - if (savedFocus != null && !savedFocus.isDisposed ()) { - savedFocus.setFocus (); + sendEvent (SWT.Show); + if (isDisposed ()) return; + int inModalKind = OS.kWindowModalityNone; + if ((style & SWT.PRIMARY_MODAL) != 0) inModalKind = OS.kWindowModalityWindowModal; + if ((style & SWT.APPLICATION_MODAL) != 0) inModalKind = OS.kWindowModalityAppModal; + if ((style & SWT.SYSTEM_MODAL) != 0) inModalKind = OS.kWindowModalitySystemModal; + if (inModalKind != OS.kWindowModalityNone) { + int inUnavailableWindow = 0; + if (parent != null) inUnavailableWindow = OS.GetControlOwner (parent.handle); + OS.SetWindowModality (shellHandle, inModalKind, inUnavailableWindow); } - savedFocus = null; - */ - - //sendEvent (SWT.Show); - - return; - } - - Shell[] shells= getShells(); - for (int i= 0; i < shells.length; i++) { - Shell shell= shells[i]; - if (shell.isVisible()) - shell.setVisible(false); - } - - /* Hide the shell */ - /* AW - OS.XtSetMappedWhenManaged (shellHandle, false); - if (OS.XtIsTopLevelShell (shellHandle)) { - OS.XtUnmapWidget (shellHandle); + OS.ShowWindow (shellHandle); } else { - OS.XtPopdown (shellHandle); + OS.HideWindow (shellHandle); + sendEvent (SWT.Hide); } - */ - OS.HideWindow(shellHandle); - - sendEvent (SWT.Hide); } -int topHandle () { - return shellHandle; -} -int trimHeight () { - if ((style & SWT.NO_TRIM) != 0) return 0; - /* AW - boolean hasTitle = false, hasResize = false, hasBorder = false; - hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0; - hasResize = (style & SWT.RESIZE) != 0; - hasBorder = (style & SWT.BORDER) != 0; - if (hasTitle) { - if (hasResize) return display.titleResizeTrimHeight; - if (hasBorder) return display.titleBorderTrimHeight; - return display.titleTrimHeight; - } - if (hasResize) return display.resizeTrimHeight; - if (hasBorder) return display.borderTrimHeight; - */ - return 0; + +void setZOrder () { + if (scrolledHandle != 0) OS.HIViewAddSubview (scrolledHandle, handle); } -int trimWidth () { - if ((style & SWT.NO_TRIM) != 0) return 0; - /* AW - boolean hasTitle = false, hasResize = false, hasBorder = false; - hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0; - hasResize = (style & SWT.RESIZE) != 0; - hasBorder = (style & SWT.BORDER) != 0; - if (hasTitle) { - if (hasResize) return display.titleResizeTrimWidth; - if (hasBorder) return display.titleBorderTrimWidth; - return display.titleTrimWidth; + +void setZOrder (Control control, boolean above) { + if (above) { + //NOT DONE - move one window above another + OS.BringToFront (shellHandle); + } else { + int window = control == null ? 0 : OS.GetControlOwner (control.handle); + OS.SendBehind (shellHandle, window); } - if (hasResize) return display.resizeTrimWidth; - if (hasBorder) return display.borderTrimWidth; - */ - return 0; } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java index 94280b6ce4..d67f0bdd61 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java @@ -6,127 +6,23 @@ package org.eclipse.swt.widgets; * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html */ + +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.carbon.*; -/** - * Instances of this class are selectable user interface - * objects that represent a range of positive, numeric values. - * <p> - * At any given moment, a given slider will have a - * single <em>selection</em> that is considered to be its - * value, which is constrained to be within the range of - * values the slider represents (that is, between its - * <em>minimum</em> and <em>maximum</em> values). - * </p><p> - * Typically, sliders will be made up of five areas: - * <ol> - * <li>an arrow button for decrementing the value</li> - * <li>a page decrement area for decrementing the value by a larger amount</li> - * <li>a <em>thumb</em> for modifying the value by mouse dragging</li> - * <li>a page increment area for incrementing the value by a larger amount</li> - * <li>an arrow button for incrementing the value</li> - * </ol> - * Based on their style, sliders are either <code>HORIZONTAL</code> - * (which have 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 - */ -public /*final*/ class Slider extends Control { - private int fIncrement= 1; // AW - private int fPageIncrement= 10; // AW -/** - * 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 class Slider extends Control { + boolean dragging; + int increment = 1; + int pageIncrement = 10; + public Slider (Composite parent, int style) { super (parent, checkStyle (style)); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver's value changes, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values: - * <code>0</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 - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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); @@ -134,210 +30,119 @@ public void addSelectionListener(SelectionListener 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); } + +int actionProc (int theControl, int partCode) { + Event event = new Event (); + int value = OS.GetControl32BitValue (handle); + switch (partCode) { + case OS.kControlUpButtonPart: + value -= increment; + event.detail = SWT.ARROW_UP; + break; + case OS.kControlPageUpPart: + value -= pageIncrement; + event.detail = SWT.PAGE_UP; + break; + case OS.kControlPageDownPart: + value += pageIncrement; + event.detail = SWT.PAGE_DOWN; + break; + case OS.kControlDownButtonPart: + value += increment; + event.detail = SWT.ARROW_DOWN; + break; + case OS.kControlIndicatorPart: + dragging = true; + event.detail = SWT.DRAG; + break; + default: + return 0; + } + OS.SetControl32BitValue (handle, value); + sendEvent (SWT.Selection, event); + if (dragging) { + Display display = getDisplay (); + display.update (); + } + return 0; +} + public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); - int border = getBorderWidth (); - int width = border * 2, height = border * 2; - Display display = getDisplay (); - int hScroll = display.scrolledMarginX; - int vScroll = display.scrolledMarginY; + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricScrollBarWidth, outMetric); + int width = 0, height = 0; if ((style & SWT.HORIZONTAL) != 0) { - width += hScroll * 10; - height += vScroll; + height = outMetric [0]; + width = height * 10; } else { - width += hScroll; - height += vScroll * 10; + width = outMetric [0]; + height = width * 10; } - if (wHint != SWT.DEFAULT) width = wHint + (border * 2); - if (hHint != SWT.DEFAULT) height = hHint + (border * 2); + if (wHint != SWT.DEFAULT) width = wHint; + if (hHint != SWT.DEFAULT) height = hHint; return new Point (width, height); } -void createHandle (int index) { - state |= HANDLE; - /* AW - int [] argList = { - OS.XmNancestorSensitive, 1, - OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0, - OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL, - }; - handle = OS.XmCreateScrollBar (parent.handle, null, argList, argList.length / 2); - */ - handle= MacUtil.newControl(parent.handle, (short)0, (short)0, (short)100, OS.kControlScrollBarLiveProc); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); + +void createHandle () { + Display display = getDisplay (); + int actionProc = display.actionProc; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateScrollBarControl (window, null, 0, 0, 100, 10, true, actionProc, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [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(); - return fIncrement; + return increment; } -/** - * 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(); - return OS.GetControl32BitMaximum(handle); + int maximum = OS.GetControl32BitMaximum (handle); + int viewSize = OS.GetControlViewSize (handle); + return maximum + viewSize; } -/** - * 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(); - return OS.GetControl32BitMinimum(handle); + return OS.GetControl32BitMinimum (handle); } -/** - * 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(); - return fPageIncrement; + return pageIncrement; } -/** - * Returns the single <em>selection</em> that is the receiver's value. - * - * @return the selection - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getSelection () { checkWidget(); - return OS.GetControl32BitValue(handle); + return OS.GetControl32BitValue (handle); } -/** - * 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(); - return OS.GetControlViewSize(handle); -} -void hookEvents () { - super.hookEvents (); - /* AW - int windowProc = getDisplay ().windowProc; - OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, SWT.Selection); - OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, SWT.Selection); - */ - OS.SetControlAction(handle, getDisplay().fControlActionProc); + return OS.GetControlViewSize (handle); } -int processSelection (Object callData) { - MacControlEvent macEvent= (MacControlEvent) callData; - if (! macEvent.isMouseDown()) - return 0; - - Event event = new Event (); - switch (macEvent.getPartCode()) { - case OS.kControlUpButtonPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - fIncrement); - event.detail = SWT.ARROW_UP; - break; - case OS.kControlPageUpPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - fPageIncrement); - event.detail = SWT.PAGE_UP; - break; - case OS.kControlPageDownPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) + fPageIncrement); - event.detail = SWT.PAGE_DOWN; - break; - case OS.kControlDownButtonPart: - OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) + fIncrement); - event.detail = SWT.ARROW_DOWN; - break; - case OS.kControlIndicatorPart: // end of drag or continuos drag - if (macEvent.isMouseDown()) - event.detail = SWT.DRAG; // continuos drag - else { - /* - * Do not set the detail field to SWT.DRAG - * to indicate that the dragging has ended. - */ - } - break; - } - - sendEvent (SWT.Selection, event); - - /* AW FIXME: may be we need the following here too... - if (macEvent.isMouseDown()) { - int wHandle= OS.GetControlOwner(handle); - if (wHandle != 0) { - getDisplay().updateWindow(wHandle); - } +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + int status = super.kEventMouseDown (nextHandler, theEvent, userData); + if (status == OS.noErr) return status; + dragging = false; + status = OS.CallNextEventHandler (nextHandler, theEvent); + if (dragging) { + Event event = new Event (); + sendEvent (SWT.Selection, event); } - */ - - return 0; + dragging = false; + return status; } -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver's value changes. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ + public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -345,133 +150,49 @@ public void removeSelectionListener(SelectionListener listener) { 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(); if (value < 1) return; - fIncrement= value; + increment = value; } -/** - * Sets the maximum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new maximum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setMaximum (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitMaximum(handle, value); + int minimum = OS.GetControl32BitMinimum (handle); + int viewSize = OS.GetControlViewSize (handle); + if (value - minimum - viewSize < 0) return; + OS.SetControl32BitMaximum (handle, value - viewSize); } -/** - * Sets the minimum value which the receiver will allow - * to be the argument which must be greater than or - * equal to zero. - * - * @param value the new minimum (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setMinimum (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitMinimum(handle, value); + int maximum = OS.GetControl32BitMinimum (handle); + int viewSize = OS.GetControlViewSize (handle); + if (maximum - value - viewSize < 0) return; + OS.SetControl32BitMinimum (handle, value); } -/** - * Sets the amount that the receiver's value will be - * modified by when the page increment/decrement areas - * are selected to the argument, which must be at least - * one. - * - * @return the page increment (must be greater than zero) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setPageIncrement (int value) { checkWidget(); if (value < 1) return; - fPageIncrement= value; + pageIncrement = value; } -/** - * Sets the single <em>selection</em> that is the receiver's - * value to the argument which must be greater than or equal - * to zero. - * - * @param value the new selection (must be zero or greater) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setSelection (int value) { checkWidget(); if (value < 0) return; - OS.SetControl32BitValue(handle, value); + OS.SetControl32BitValue (handle, value); } -/** - * Sets the size of the receiver's thumb relative to the - * difference between its maximum and minimum values to the - * argument which must be at least one. - * - * @param value the new thumb value (must be at least one) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ScrollBar - */ + public void setThumb (int value) { checkWidget(); if (value < 1) return; - OS.SetControlViewSize(handle, value); + OS.SetControlViewSize (handle, value); } -/** - * Sets the receiver's selection, minimum value, maximum - * value, thumb, increment and page increment all at once. - * <p> - * Note: This is equivalent to setting the values individually - * using the appropriate methods, but may be implemented in a - * more efficient fashion on some platforms. - * </p> - * - * @param selection the new selection value - * @param minimum the new minimum value - * @param maximum the new maximum value - * @param thumb the new thumb value - * @param increment the new increment value - * @param pageIncrement the new pageIncrement value - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) { checkWidget(); if (selection < 0) return; @@ -481,11 +202,12 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i if (maximum - minimum - thumb < 0) return; if (increment < 1) return; if (pageIncrement < 1) return; - OS.SetControl32BitMinimum(handle, minimum); - OS.SetControl32BitMaximum(handle, maximum); - OS.SetControlViewSize(handle, thumb); - OS.SetControl32BitValue(handle, selection); - fIncrement= increment; - fPageIncrement= pageIncrement; + OS.SetControl32BitMinimum (handle, minimum); + OS.SetControl32BitMaximum (handle, maximum - thumb); + OS.SetControlViewSize (handle, thumb); + OS.SetControl32BitValue (handle, selection); + this.increment = increment; + this.pageIncrement = pageIncrement; } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java index 351fa3cb93..689cfa4e2b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java @@ -7,10 +7,12 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; + import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.graphics.*; /** * Instances of this class implement the notebook user interface @@ -36,12 +38,7 @@ import org.eclipse.swt.internal.carbon.*; * </p> */ public class TabFolder extends Composite { - - private static final int TAB_HEIGHT= 32; - private static final int MARGIN= 6; - TabItem [] items; - private int oldValue; /** * Constructs a new instance of this class given its parent @@ -102,9 +99,9 @@ public TabFolder (Composite parent, int style) { 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); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Selection,typedListener); + addListener (SWT.DefaultSelection,typedListener); } static int checkStyle (int style) { @@ -124,19 +121,9 @@ protected void checkSubclass () { public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); - /* AW - RECT insetRect = new RECT (), itemRect = new RECT (); - OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, insetRect); - int width = insetRect.left - insetRect.right, height = 0; - int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0); - if (count != 0) { - OS.SendMessage (handle, OS.TCM_GETITEMRECT, count - 1, itemRect); - width = Math.max (width, itemRect.right - insetRect.right); - } - */ - int width= 100; // AW a bogus guess - int height= 0; - + // NEEDS WORK + int count = OS.GetControl32BitMaximum (handle); + int width = 100 * count, height = 0; Point size; if (layout != null) { size = layout.computeSize (this, wHint, hHint, changed); @@ -153,41 +140,42 @@ public Point computeSize (int wHint, int hHint, boolean changed) { width = trim.width; height = trim.height; return new Point (width, height); } + public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget (); - /* AW - RECT rect = new RECT (); - OS.SetRect (rect, x, y, x + width, y + height); - OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, rect); - */ - /* AW - int border = getBorderWidth (); - rect.left -= border; rect.right += border; - rect.top -= border; rect.bottom += border; - int newWidth = rect.right - rect.left; - int newHeight = rect.bottom - rect.top; - return new Rectangle (rect.left, rect.top, newWidth, newHeight); - */ - return new Rectangle (x-MARGIN, y-TAB_HEIGHT, width+(2*MARGIN), height+TAB_HEIGHT+MARGIN); + Rect bounds = new Rect (); + OS.GetControlBounds (handle, bounds); + Rect client = new Rect (); + OS.GetControlData (handle, (short)OS.kControlEntireControl, OS.kControlTabContentRectTag, Rect.sizeof, client, null); + x -= Math.max (3, client.left - bounds.left); + y -= Math.max (34, client.top - bounds.top); + width += Math.max (6, (bounds.right - bounds.left) - (client.right - client.left)); + height += Math.max (37, (bounds.bottom - bounds.top) - (client.bottom - client.top)); + Rect inset = getInset (); + x -= inset.left; + y -= inset.top; + width += inset.left + inset.right; + height += inset.top + inset.bottom; + return new Rectangle (x, y, width, height); +} + +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateTabsControl (window, new Rect (), (short)OS.kControlTabSizeLarge, (short)OS.kControlTabDirectionNorth, (short) 0, 0, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; } void createItem (TabItem item, int index) { - int count = OS.GetControl32BitMaximum(handle); - + int count = OS.GetControl32BitMaximum (handle); if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE); + OS.SetControl32BitMaximum (handle, count+1); if (count == items.length) { TabItem [] newItems = new TabItem [items.length + 4]; System.arraycopy (items, 0, newItems, 0, items.length); items = newItems; } - /* AW - TCITEM tcItem = new TCITEM (); - if (OS.SendMessage (handle, OS.TCM_INSERTITEM, index, tcItem) == -1) { - error (SWT.ERROR_ITEM_NOT_ADDED); - } - */ - OS.SetControl32BitMaximum(handle, count+1); - System.arraycopy (items, index, items, index + 1, count - index); items [index] = item; @@ -197,22 +185,16 @@ void createItem (TabItem item, int index) { * is added. */ if (count == 0) { + OS.SetControl32BitValue (handle, 1); Event event = new Event (); event.item = items [0]; sendEvent (SWT.Selection, event); // the widget could be destroyed at this point } } -void createHandle (int index) { - state |= HANDLE; - state &= ~CANVAS; - - handle= MacUtil.newControl(parent.handle, OS.kControlTabSmallProc); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); -} -void createWidget (int index) { - super.createWidget (index); +void createWidget () { + super.createWidget (); items = new TabItem [4]; } @@ -224,32 +206,16 @@ void destroyItem (TabItem item) { index++; } if (index == count) return; // not found - int selectionIndex = OS.GetControl32BitValue(handle)-1; - - /* AW - if (OS.SendMessage (handle, OS.TCM_DELETEITEM, index, 0) == 0) { - error (SWT.ERROR_ITEM_NOT_REMOVED); - } - */ - OS.SetControl32BitMaximum(handle, count-1); - - System.arraycopy (items, index + 1, items, index, --count - index); - items [count] = null; + int selectionIndex = OS.GetControl32BitValue (handle) - 1; + --count; + OS.SetControl32BitMaximum(handle, count); if (count == 0) { - /* AW - if (imageList != null) { - OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0); - Display display = getDisplay (); - display.releaseImageList (imageList); - } - imageList = null; - */ items = new TabItem [4]; + return; } - - updateCarbon(index); - - if (count > 0 && index == selectionIndex) { + System.arraycopy (items, index + 1, items, index, count - index); + items [count] = null; + if (index == selectionIndex) { setSelection (Math.max (0, selectionIndex - 1)); selectionIndex = getSelectionIndex (); if (selectionIndex != -1) { @@ -263,29 +229,15 @@ void destroyItem (TabItem item) { public Rectangle getClientArea () { checkWidget (); - /* AW - if (parent.hdwp != 0) { - int oldHdwp = parent.hdwp; - parent.hdwp = 0; - OS.EndDeferWindowPos (oldHdwp); - int count = parent.getChildrenCount (); - parent.hdwp = OS.BeginDeferWindowPos (count); - } - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, rect); - int width = rect.right - rect.left; - int height = rect.bottom - rect.top; - return new Rectangle (rect.left, rect.top, width, height); - */ - - short[] outer= new short[4]; - OS.GetControlBounds(handle, outer); - - short[] inner= new short[4]; - OS.GetControlData(handle, OS.kControlEntireControl, OS.kControlTabContentRectTag, inner); - - return new Rectangle(inner[1]-outer[1], inner[0]-outer[0], inner[3]-inner[1], inner[2]-inner[0]); + Rect bounds = new Rect (); + OS.GetControlBounds (handle, bounds); + Rect client = new Rect (); + OS.GetControlData (handle, (short)OS.kControlEntireControl, OS.kControlTabContentRectTag, Rect.sizeof, client, null); + int x = Math.max (0, client.left - bounds.left); + int y = Math.max (0, client.top - bounds.top); + int width = Math.max (0, client.right - client.left); + int height = Math.max (0, client.bottom - client.top); + return new Rectangle (x, y, width, height); } /** @@ -305,7 +257,7 @@ public Rectangle getClientArea () { */ public TabItem getItem (int index) { checkWidget (); - int count = OS.GetControl32BitMaximum(handle); + int count = OS.GetControl32BitMaximum (handle); if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE); return items [index]; } @@ -322,7 +274,7 @@ public TabItem getItem (int index) { */ public int getItemCount () { checkWidget (); - return OS.GetControl32BitMaximum(handle); + return OS.GetControl32BitMaximum (handle); } /** @@ -343,18 +295,9 @@ public int getItemCount () { */ public TabItem [] getItems () { checkWidget (); - int count = OS.GetControl32BitMaximum(handle); - int n= 0; - for (int i=0; i < count; i++) - if (items[i] != null) - n++; - if (n < count) - System.out.println("TabFolder.getItems: found null slots"); - TabItem [] result = new TabItem [n]; - for (int i=0; i < n; i++) - if (items[i] != null) - result[i]= items[i]; - //System.arraycopy (items, 0, result, 0, count); + int count = OS.GetControl32BitMaximum (handle); + TabItem [] result = new TabItem [count]; + System.arraycopy (items, 0, result, 0, count); return result; } @@ -376,7 +319,7 @@ public TabItem [] getItems () { */ public TabItem [] getSelection () { checkWidget (); - int index= OS.GetControl32BitValue(handle)-1; + int index = OS.GetControl32BitValue(handle) - 1; if (index == -1) return new TabItem [0]; return new TabItem [] {items [index]}; } @@ -394,14 +337,9 @@ public TabItem [] getSelection () { */ public int getSelectionIndex () { checkWidget (); - return OS.GetControl32BitValue(handle)-1; -} -void hookEvents () { - super.hookEvents (); - - Display display= getDisplay(); - OS.SetControlAction(handle, display.fControlActionProc); + return OS.GetControl32BitValue (handle) - 1; } + /** * Searches the receiver's list starting at the first item * (index 0) until an item is found that is equal to the @@ -422,56 +360,53 @@ void hookEvents () { public int indexOf (TabItem item) { checkWidget (); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); - int count = OS.GetControl32BitMaximum(handle); + int count = OS.GetControl32BitMaximum (handle); for (int i=0; i<count; i++) { if (items [i] == item) return i; } return -1; } -/* AW -boolean mnemonicHit (char key) { - for (int i=0; i<items.length; i++) { - TabItem item = items [i]; - if (item != null) { - char ch = findMnemonic (item.getText ()); - if (Character.toUpperCase (key) == Character.toUpperCase (ch)) { - if (setFocus ()) { - setSelection (i, true); - return true; - } - } + +Rect getInset () { + Display display = getDisplay (); + return display.tabFolderInset; +} + +int kEventControlHit (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlHit (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + int index = OS.GetControl32BitValue (handle) - 1; + int count = OS.GetControl32BitMaximum (handle); + for (int i = 0; i < count; i++) { + if (i != index) { + Control control = items [i].control; + if (control != null && !control.isDisposed ()) + control.setVisible (false); } } - return false; -} -boolean mnemonicMatch (char key) { - for (int i=0; i<items.length; i++) { - TabItem item = items [i]; - if (item != null) { - char ch = findMnemonic (item.getText ()); - if (Character.toUpperCase (key) == Character.toUpperCase (ch)) { - return true; - } + TabItem item = null; + if (index != -1) item = items [index]; + if (item != null) { + Control control = item.control; + if (control != null && !control.isDisposed ()) { + control.setBounds (getClientArea ()); + control.setVisible (true); } } - return false; + Event event = new Event (); + event.item = item; + postEvent (SWT.Selection, event); + redraw (); + return OS.eventNotHandledErr; } -*/ + void releaseWidget () { - int count = OS.GetControl32BitMaximum(handle); - for (int i=0; i<count; i++) { + int count = OS.GetControl32BitMaximum (handle); + for (int i = 0; i < count; i++) { TabItem item = items [i]; - if (item != null && !item.isDisposed ()) item.releaseWidget (); + if (item != null && !item.isDisposed ()) item.releaseResources (); } items = null; - /* AW - if (imageList != null) { - OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0); - Display display = getDisplay (); - display.releaseImageList (imageList); - } - imageList = null; - */ super.releaseWidget (); } @@ -500,6 +435,21 @@ public void removeSelectionListener (SelectionListener listener) { eventTable.unhook (SWT.DefaultSelection,listener); } +int setBounds (int c, int x, int y, int width, int height, boolean move, boolean resize, boolean events) { + int result = super.setBounds(c, x, y, width, height, move, resize, events); + if ((result & RESIZED) != 0) { + int index = OS.GetControl32BitValue (handle) - 1; + if (index != -1) { + TabItem item = items [index]; + Control control = item.control; + if (control != null && !control.isDisposed ()) { + control.setBounds (getClientArea ()); + } + } + } + return result; +} + /** * Sets the receiver's selection to be the given array of items. * The current selected is first cleared, then the new items are @@ -519,7 +469,7 @@ public void setSelection (TabItem [] items) { setSelection (-1); return; } - for (int i=items.length-1; i>=0; --i) { + for (int i=items.length - 1; i>=0; --i) { int index = indexOf (items [i]); if (index != -1) setSelection (index); } @@ -544,10 +494,9 @@ public void setSelection (int index) { } void setSelection (int index, boolean notify) { - - int oldIndex = OS.GetControl32BitValue(handle) - 1; - if (oldIndex != -1) { - TabItem item = items [oldIndex]; + int currentIndex = OS.GetControl32BitValue (handle) - 1; + if (currentIndex != -1) { + TabItem item = items [currentIndex]; if (item != null) { Control control = item.control; if (control != null && !control.isDisposed ()) { @@ -555,11 +504,10 @@ void setSelection (int index, boolean notify) { } } } - OS.SetControl32BitValue(handle, index+1); - - int newIndex = OS.GetControl32BitValue(handle) - 1; - if (newIndex != -1) { - TabItem item = items [newIndex]; + OS.SetControl32BitValue (handle, index+1); + index = OS.GetControl32BitValue (handle) - 1; + if (index != -1) { + TabItem item = items [index]; if (item != null) { Control control = item.control; if (control != null && !control.isDisposed ()) { @@ -571,8 +519,9 @@ void setSelection (int index, boolean notify) { event.item = item; sendEvent (SWT.Selection, event); } - } + } } + redraw (); } boolean traversePage (boolean next) { @@ -588,96 +537,4 @@ boolean traversePage (boolean next) { setSelection (index, true); return index == getSelectionIndex (); } - -////////////////////////////////////////////////// -// Mac stuff -////////////////////////////////////////////////// - -int processSelection (Object callData) { - MacControlEvent macEvent= (MacControlEvent) callData; - if (!macEvent.isMouseDown()) - handleSelectionChange(macEvent.getPartCode()-1); - else - oldValue= OS.GetControl32BitValue(handle)-1; - return 0; -} - -private void handleSelectionChange(int newValue) { - - TabItem item = null; - int index= oldValue; - - if (index != -1) item = items [index]; - if (item != null) { - Control control = item.control; - if (control != null && !control.isDisposed ()) { - control.setVisible (false); - } - } - - index= newValue; - if (index != -1) item = items [index]; - if (item != null) { - Control control = item.control; - if (control != null && !control.isDisposed ()) { - control.setBounds (getClientArea ()); - control.setVisible (true); - } - } - - Event event = new Event (); - event.item = item; - postEvent (SWT.Selection, event); -} - -private void updateCarbon(int startIndex) { - int n= OS.GetControl32BitMaximum(handle); - for (int i= startIndex; i < n; i++) { - TabItem item= items[i]; - if (item != null) - setTabText(i, item.getText()); - } -} - -void setTabText(int index, String string) { - int sHandle= 0; - try { - String t= MacUtil.removeMnemonics(string); - sHandle= OS.CFStringCreateWithCharacters(t); - OS.setTabText(handle, index+1, sHandle); - } finally { - if (sHandle != 0) - OS.CFRelease(sHandle); - } -} - -void setTabImage(int index, Image image) { - /* AW: does not work yet... - int icon= Image.carbon_createCIcon(image); - if (icon != 0) - if (OS.setTabIcon(handle, index+1, icon) != OS.kNoErr) - System.err.println("TabFolder.setTabImage: error"); - */ -} - -/** - * Overridden from Control. - * x and y are relative to window! - */ -void handleResize(int hndl, MacRect bounds) { - - bounds.inset(MARGIN, 0, MARGIN, MARGIN); - super.handleResize(hndl, bounds); - - if (handle != 0) { - int selectedIndex= OS.GetControl32BitValue(handle)-1; - if (selectedIndex != -1) { - Control control = items[selectedIndex].getControl(); - if (control != null && !control.isDisposed()) { - control.setBounds(getClientArea()); - } - } - } -} - } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java index b0e34f0ae5..ecc5656e44 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java @@ -9,6 +9,9 @@ package org.eclipse.swt.widgets; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.ControlTabInfoRecV1; +import org.eclipse.swt.internal.carbon.ControlButtonContentInfo; /** * Instances of this class represent a selectable user interface object @@ -27,6 +30,7 @@ public class TabItem extends Item { TabFolder parent; Control control; String toolTipText; + int cIcon; /** * Constructs a new instance of this class given its parent @@ -118,7 +122,7 @@ protected void checkSubclass () { * </ul> */ public Control getControl () { - checkWidget(); + checkWidget (); return control; } @@ -138,7 +142,7 @@ public Display getDisplay () { * </ul> */ public TabFolder getParent () { - checkWidget(); + checkWidget (); return parent; } @@ -154,7 +158,7 @@ public TabFolder getParent () { * </ul> */ public String getToolTipText () { - checkWidget(); + checkWidget (); return toolTipText; } @@ -169,6 +173,10 @@ void releaseChild () { void releaseWidget () { super.releaseWidget (); + if (cIcon != 0) { + destroyCIcon (cIcon); + cIcon = 0; + } control = null; parent = null; } @@ -189,7 +197,7 @@ void releaseWidget () { * </ul> */ public void setControl (Control control) { - checkWidget(); + checkWidget (); if (control != null) { if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT); @@ -212,21 +220,51 @@ public void setControl (Control control) { } public void setImage (Image image) { - checkWidget(); + checkWidget (); int index = parent.indexOf (this); if (index == -1) return; super.setImage (image); - getParent().setTabImage(index, image); + if (cIcon != 0) { + destroyCIcon(cIcon); + cIcon = 0; + } + ControlButtonContentInfo inContent = new ControlButtonContentInfo (); + if (image == null) { + inContent.contentType = (short)OS.kControlContentTextOnly; + } else { + cIcon = createCIcon (image); + inContent.contentType = (short)OS.kControlContentCIconHandle; + inContent.iconRef = cIcon; + } + OS.SetControlData (parent.handle, index+1, OS.kControlTabImageContentTag, ControlButtonContentInfo.sizeof, inContent); + parent.redraw (); } public void setText (String string) { - checkWidget(); + checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); + if ((style & SWT.ARROW) != 0) return; int index = parent.indexOf (this); if (index == -1) return; super.setText (string); - //getParent().updateCarbon(index); - getParent().setTabText(index, string); + char [] buffer = new char [text.length ()]; + text.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} + j--; + } + } + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + ControlTabInfoRecV1 tab = new ControlTabInfoRecV1 (); + tab.version= (short) OS.kControlTabInfoVersionOne; + tab.iconSuiteID = 0; + tab.name = ptr; + OS.SetControlData (parent.handle, index+1, OS.kControlTabInfoTag, ControlTabInfoRecV1.sizeof, tab); + OS.CFRelease (ptr); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java new file mode 100644 index 0000000000..f8fac108fa --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java @@ -0,0 +1,880 @@ +package org.eclipse.swt.widgets; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.DataBrowserCallbacks; +import org.eclipse.swt.internal.carbon.Rect; +import org.eclipse.swt.internal.carbon.DataBrowserListViewColumnDesc; + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.events.*; + +public class Table extends Composite { + TableItem [] items; + TableColumn [] columns; + int itemCount, columnCount, idCount, anchorFirst, anchorLast, headerHeight; + boolean ignoreSelect; + static final int CHECK_COLUMN_ID = 1024; + static final int COLUMN_ID = 1025; + +public Table (Composite parent, int style) { + super (parent, checkStyle (style)); +} + +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) { + /* + * Feature in Windows. It is not possible to create + * a table that does not have scroll bars. Therefore, + * no matter what style bits are specified, set the + * H_SCROLL and V_SCROLL bits so that the SWT style + * will match the widget that Windows creates. + */ + style |= SWT.H_SCROLL | SWT.V_SCROLL; + return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0); +} + +protected void checkSubclass () { + if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); +} + +public Point computeSize (int wHint, int hHint, boolean changed) { + checkWidget(); + int width = 0; + if (wHint == SWT.DEFAULT) { + GC gc = new GC (this); + for (int i=0; i<itemCount; i++) { + //NOT DONE - take into account the icon +// Rectangle rect = items [i].getBounds (); +// width = Math.max (width, rect.width); + Point extent = gc.stringExtent (items [i].text); + width = Math.max (width, extent.x); + } + gc.dispose (); + } else { + width = wHint; + } + if (width <= 0) width = DEFAULT_WIDTH; + int height = 0; + if (hHint == SWT.DEFAULT) { + height = itemCount * getItemHeight (); + } else { + height = hHint; + } + if (height <= 0) height = DEFAULT_HEIGHT; + Rectangle rect = computeTrim (0, 0, width, height); + return new Point (rect.width, rect.height); +} + +public Rectangle computeTrim (int x, int y, int width, int height) { + checkWidget(); + Rect rect = new Rect (); + OS.GetDataBrowserScrollBarInset (handle, rect); + x -= rect.left; + y -= rect.top; + width += (rect.left + rect.right) * 3; + height += rect.top + rect.bottom; + return new Rectangle (x, y, width, height); +} + +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateDataBrowserControl (window, null, OS.kDataBrowserListView, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + int selectionFlags = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserSelectOnlyOne : OS.kDataBrowserCmdTogglesSelection; + OS.SetDataBrowserSelectionFlags (handle, selectionFlags); + short [] height = new short [1]; + OS.GetDataBrowserListViewHeaderBtnHeight (handle, height); + headerHeight = height [0]; + OS.SetDataBrowserListViewHeaderBtnHeight (handle, (short) 0); + OS.SetDataBrowserHasScrollBars (handle, (style & SWT.H_SCROLL) != 0, (style & SWT.V_SCROLL) != 0); + if ((style & SWT.FULL_SELECTION) != 0) { + OS.SetDataBrowserTableViewHiliteStyle (handle, OS.kDataBrowserTableViewFillHilite); + } + //NOT DONE + if ((style & SWT.H_SCROLL) == 0) OS.AutoSizeDataBrowserListViewColumns (handle); + int position = 0; + if ((style & SWT.CHECK) != 0) { + DataBrowserListViewColumnDesc checkColumn = new DataBrowserListViewColumnDesc (); + checkColumn.headerBtnDesc_version = OS.kDataBrowserListViewLatestHeaderDesc; + checkColumn.propertyDesc_propertyID = CHECK_COLUMN_ID; + checkColumn.propertyDesc_propertyType = OS.kDataBrowserCheckboxType; + checkColumn.propertyDesc_propertyFlags = OS.kDataBrowserPropertyIsMutable; + //NOT DONE + checkColumn.headerBtnDesc_minimumWidth = 40; + checkColumn.headerBtnDesc_maximumWidth = 40; + checkColumn.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing; + OS.AddDataBrowserListViewColumn (handle, checkColumn, position++); + } + DataBrowserListViewColumnDesc column = new DataBrowserListViewColumnDesc (); + column.headerBtnDesc_version = OS.kDataBrowserListViewLatestHeaderDesc; + column.propertyDesc_propertyID = COLUMN_ID; + column.propertyDesc_propertyType = OS.kDataBrowserTextType; // OS.kDataBrowserIconAndTextType + column.propertyDesc_propertyFlags = OS.kDataBrowserListViewSelectionColumn | OS.kDataBrowserDefaultPropertyFlags; + //NOT DONE + column.headerBtnDesc_maximumWidth = 0x7FFF; + column.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing; + OS.AddDataBrowserListViewColumn (handle, column, position); + //NOT DONE + OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short)800); + + /* + * Feature in the Macintosh. Scroll bars are not created until + * the widget has a minimum size. The fix is to force the scroll + * bars to be created by temporarily giving the widget a size and + * then restoring it to zero. + * + * NOTE: The widget must be visible and SizeControl() must be used + * to resize the widget to a minimim size or the widget will not + * create the scroll bars. This work around currently flashes. + */ + OS.SizeControl (handle, (short) 0xFF, (short) 0xFF); + OS.SizeControl (handle, (short) 0, (short) 0); +} + +void createItem (TableColumn column, int index) { + if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_INVALID_RANGE); + column.id = COLUMN_ID + idCount++; + int position = index + ((style & SWT.CHECK) != 0 ? 1 : 0); + if (columnCount != 0) { + DataBrowserListViewColumnDesc desc = new DataBrowserListViewColumnDesc (); + desc.headerBtnDesc_version = OS.kDataBrowserListViewLatestHeaderDesc; + desc.propertyDesc_propertyID = column.id; + desc.propertyDesc_propertyType = OS.kDataBrowserTextType; // OS.kDataBrowserIconAndTextType + desc.propertyDesc_propertyFlags = OS.kDataBrowserDefaultPropertyFlags; + //NOT DONE +// desc.headerBtnDesc_minimumWidth = 80; + desc.headerBtnDesc_maximumWidth = 0x7FFF; + desc.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing; + OS.AddDataBrowserListViewColumn (handle, desc, position); + //NOT DONE + OS.SetDataBrowserTableViewNamedColumnWidth (handle, column.id, (short)0); + } + if (columnCount == columns.length) { + TableColumn [] newColumns = new TableColumn [columnCount + 4]; + System.arraycopy (columns, 0, newColumns, 0, columns.length); + columns = newColumns; + } + System.arraycopy (columns, index, columns, index + 1, columnCount++ - index); + columns [index] = column; + //NOT DONE - OPTIMIZE + for (int i=0; i<itemCount; i++) { + TableItem item = items [i]; + for (int j=columnCount-1; j>index; --j) { + item.setText (j, item.getText (j - 1)); + item.setImage (j, item.getImage (j - 1)); + } + item.setText (index, ""); + item.setImage (index, null); + } +} + +void createItem (TableItem item, int index) { + if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE); + int [] id = new int [] {itemCount + 1}; + if (OS.AddDataBrowserItems (handle, OS.kDataBrowserNoItem, 1, id, 0) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_ADDED); + } + if (itemCount == items.length) { + TableItem [] newItems = new TableItem [itemCount + 4]; + System.arraycopy (items, 0, newItems, 0, items.length); + items = newItems; + } + System.arraycopy (items, index, items, index + 1, itemCount++ - index); + items [index] = item; + OS.UpdateDataBrowserItems (handle, 0, 0, null, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); +} + +ScrollBar createScrollBar (int style) { + return createStandardBar (style); +} + +void createWidget () { + super.createWidget (); + items = new TableItem [4]; + columns = new TableColumn [4]; +} + +int defaultThemeFont () { + return OS.kThemeViewsFont; +} + +public void deselect (int index) { + checkWidget(); + if (0 <= index && index < itemCount) { + ignoreSelect = true; + int [] id = new int [] {index + 1}; + OS.SetDataBrowserSelectedItems (handle, id.length, id, OS.kDataBrowserItemsRemove); + ignoreSelect = false; + } +} + +public void deselect (int start, int end) { + checkWidget(); + //NOT DONE - check range + int length = end - start + 1; + if (length <= 0) return; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = end - i + 1; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, length, ids, OS.kDataBrowserItemsRemove); + ignoreSelect = false; +} + +public void deselect (int [] indices) { + checkWidget(); + if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); + //NOT DONE - check range + int length = indices.length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = indices [length - i - 1] + 1; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, length, ids, OS.kDataBrowserItemsRemove); + ignoreSelect = false; +} + +public void deselectAll () { + checkWidget (); + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsRemove); + ignoreSelect = false; +} + +void destroyItem (TableColumn column) { + int index = 0; + while (index < columnCount) { + if (columns [index] == column) break; + index++; + } + //NOT DONE - OPTIMIZE + for (int i=0; i<itemCount; i++) { + TableItem item = items [i]; + for (int j=index; j<columnCount-1; j++) { + item.setText (j, item.getText (j + 1)); + item.setImage (j, item.getImage (j + 1)); + } + if (columnCount > 1) { + item.setText (columnCount - 1, ""); + item.setImage (columnCount - 1, null); + } + } + if (columnCount == 1) { + //NOT DONE - reassign COLUMN_ID when last column deleted + } else { + if (OS.RemoveDataBrowserTableViewColumn (handle, column.id) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_REMOVED); + } + } + System.arraycopy (columns, index + 1, columns, index, --columnCount - index); + columns [columnCount] = null; +} + +void destroyItem (TableItem item) { + int index = 0; + while (index < itemCount) { + if (items [index] == item) break; + index++; + } + int [] id = new int [] {itemCount}; + if (OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, id.length, id, 0) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_REMOVED); + } + System.arraycopy (items, index + 1, items, index, --itemCount - index); + items [itemCount] = null; + OS.UpdateDataBrowserItems (handle, 0, 0, null, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); +} + +public Rectangle getClientArea () { + checkWidget(); + Rect rect = new Rect (), inset = new Rect (); + OS.GetControlBounds (handle, rect); + OS.GetDataBrowserScrollBarInset (handle, inset); + return new Rectangle (inset.left, inset.top, rect.right - rect.left + inset.right, rect.bottom - rect.top + inset.bottom); +} + +public TableColumn getColumn (int index) { + checkWidget (); + if (!(0 <=index && index < columnCount)) error (SWT.ERROR_INVALID_RANGE); + return columns [index]; +} + +public int getColumnCount () { + checkWidget (); + return columnCount; +} + +public TableColumn [] getColumns () { + checkWidget (); + TableColumn [] result = new TableColumn [columnCount]; + System.arraycopy (columns, 0, result, 0, columnCount); + return result; +} + +public int getGridLineWidth () { + checkWidget (); + return 0; +} + +public int getHeaderHeight () { + checkWidget (); + short [] height = new short [1]; + OS.GetDataBrowserListViewHeaderBtnHeight (handle, height); + return height [0]; +} + +public boolean getHeaderVisible () { + checkWidget (); + short [] height = new short [1]; + OS.GetDataBrowserListViewHeaderBtnHeight (handle, height); + return height [0] != 0; +} + +public TableItem getItem (int index) { + checkWidget (); + if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE); + return items [index]; +} + +public TableItem getItem (Point point) { + checkWidget (); + if (point == null) error (SWT.ERROR_NULL_ARGUMENT); + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); + OS.SetPt (pt, (short) (point.x + rect.left), (short) (point.y + rect.top)); + //NOT DONE - OPTIMIZE + for (int i=0; i<itemCount; i++) { + if (OS.GetDataBrowserItemPartBounds (handle, i + 1, COLUMN_ID, OS.kDataBrowserPropertyEnclosingPart, rect) == OS.noErr) { + if (OS.PtInRect (pt, rect)) return items [i]; + } + } + return null; +} + +public int getItemCount () { + checkWidget (); + return itemCount; +} + +public int getItemHeight () { + checkWidget (); + short [] height = new short [1]; + if (OS.GetDataBrowserTableViewRowHeight (handle, height) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT); + } + return height [0]; +} + +public TableItem [] getItems () { + checkWidget (); + TableItem [] result = new TableItem [itemCount]; + System.arraycopy (items, 0, result, 0, itemCount); + return result; +} + +public boolean getLinesVisible () { + checkWidget (); + return false; +} + +public TableItem [] getSelection () { + checkWidget (); + int ptr = OS.NewHandle (0); + if (OS.GetDataBrowserItems (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, ptr) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_SELECTION); + } + int count = OS.GetHandleSize (ptr) / 4; + TableItem [] result = new TableItem [count]; + OS.HLock (ptr); + int [] start = new int [1]; + OS.memcpy (start, ptr, 4); + int [] id = new int [1]; + for (int i=0; i<count; i++) { + OS.memcpy (id, start [0] + (i * 4), 4); + result [i] = items [id [0] - 1]; + } + OS.HUnlock (ptr); + OS.DisposeHandle (ptr); + return result; +} + +public int getSelectionCount () { + checkWidget (); + int [] count = new int [1]; + if (OS.GetDataBrowserItemCount (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, count) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_COUNT); + } + return count [0]; +} + +public int getSelectionIndex () { + checkWidget(); + int [] first = new int [1], last = new int [1]; + if (OS.GetDataBrowserSelectionAnchor (handle, first, last) != OS.noErr) return -1; + return first [0] - 1; +} + +public int [] getSelectionIndices () { + checkWidget (); + int ptr = OS.NewHandle (0); + if (OS.GetDataBrowserItems (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, ptr) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_SELECTION); + } + int count = OS.GetHandleSize (ptr) / 4; + int [] result = new int [count]; + OS.HLock (ptr); + int [] start = new int [1]; + OS.memcpy (start, ptr, 4); + int [] id = new int [1]; + for (int i=0; i<count; i++) { + OS.memcpy (id, start [0] + (i * 4), 4); + result [i] = id [0] - 1; + } + OS.HUnlock (ptr); + OS.DisposeHandle (ptr); + return result; +} + +public int getTopIndex () { + checkWidget(); + int[] top = new int [1], left = new int [1]; + OS.GetDataBrowserScrollPosition (handle, top, left); + return top [0] / getItemHeight (); +} + +void hookEvents () { + super.hookEvents (); + Display display= getDisplay(); + DataBrowserCallbacks callbacks = new DataBrowserCallbacks (); + callbacks.version = OS.kDataBrowserLatestCallbacks; + OS.InitDataBrowserCallbacks (callbacks); + callbacks.v1_itemDataCallback = display.itemDataProc; + callbacks.v1_itemNotificationCallback = display.itemNotificationProc; + OS.SetDataBrowserCallbacks (handle, callbacks); +} + +public int indexOf (TableColumn column) { + checkWidget (); + if (column == null) error (SWT.ERROR_NULL_ARGUMENT); + for (int i=0; i<columnCount; i++) { + if (columns [i] == column) return i; + } + return -1; +} + +public int indexOf (TableItem 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; +} + +public boolean isSelected (int index) { + checkWidget(); + return OS.IsDataBrowserItemSelected (handle, index + 1); +} + +int itemDataProc (int browser, int id, int property, int itemData, int setValue) { + int row = id - 1; + if (!(0 <= row && row < items.length)) return OS.noErr; + TableItem item = items [row]; + switch (property) { + case CHECK_COLUMN_ID: { + if (setValue != 0) { + short [] theData = new short [1]; + OS.GetDataBrowserItemDataButtonValue (itemData, theData); + item.checked = theData [0] == OS.kThemeButtonOn; + Event event = new Event (); + event.item = item; + event.detail = SWT.CHECK; + postEvent (SWT.Selection, event); + } else { + short theData = (short)(item.checked ? OS.kThemeButtonOn : OS.kThemeButtonOff); + OS.SetDataBrowserItemDataButtonValue (itemData, theData); + } + break; + } + } + if (property >= COLUMN_ID) { + int column = 0; + while (column < columnCount) { + if (columns [column].id == property) break; + column++; + } + String text = item.getText (column); + char [] buffer = new char [text.length ()]; + text.getChars (0, buffer.length, buffer, 0); + int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); + if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + OS.SetDataBrowserItemDataText (itemData, ptr); + OS.CFRelease (ptr); + } + return OS.noErr; +} + +int itemNotificationProc (int browser, int id, int message) { + int index = id - 1; + if (!(0 <= index && index < items.length)) return OS.noErr; + TableItem item = items [index]; + switch (message) { + case OS.kDataBrowserItemSelected: + case OS.kDataBrowserItemDeselected: { + if (ignoreSelect) break; + int [] first = new int [1], last = new int [1]; + OS.GetDataBrowserSelectionAnchor (handle, first, last); + boolean selected = false; + if ((style & SWT.MULTI) != 0) { + int modifiers = OS.GetCurrentEventKeyModifiers (); + if ((modifiers & OS.shiftKey) != 0) { + if (message == OS.kDataBrowserItemSelected) { + selected = first [0] == id || last [0] == id; + } else { + selected = id == anchorFirst || id == anchorLast; + } + } else { + if ((modifiers & OS.cmdKey) != 0) { + selected = true; + } else { + selected = first [0] == last [0]; + } + } + } else { + selected = message == OS.kDataBrowserItemSelected; + } + if (selected) { + anchorFirst = first [0]; + anchorLast = last [0]; + Event event = new Event (); + event.item = item; + postEvent (SWT.Selection, event); + } + break; + } + case OS.kDataBrowserItemDoubleClicked: { + Event event = new Event (); + event.item = item; + postEvent (SWT.DefaultSelection, event); + break; + } + } + return OS.noErr; +} + +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + int result = super.kEventMouseDown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * Feature in the Macintosh. For some reason, when the user + * clicks on the data browser, focus is assigned, then lost + * and then reassigned causing kEvenControlSetFocusPart events. + * The fix is to ignore kEvenControlSetFocusPart when the user + * clicks and send the focus events from kEventMouseDown. + */ + Display display = getDisplay (); + Control oldFocus = display.getFocusControl (); + display.ignoreFocus = true; + result = OS.CallNextEventHandler (nextHandler, theEvent); + display.ignoreFocus = false; + if (oldFocus != this) { + if (oldFocus != null) oldFocus.sendFocusEvent (false); + if (isEnabled ()) sendFocusEvent (true); + } + return result; +} + +int kEventRawKeyDown (int nextHandler, int theEvent, int userData) { + int result = super.kEventRawKeyDown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * Feature in the Macintosh. For some reason, when the user hits an + * up or down arrow to traverse the items in a Data Browser, the item + * scrolls to the left such that the white space that is normally + * visible to the right of the every item is scrolled out of view. + * The fix is to do the arrow traversal in Java and not call the + * default handler. + */ + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + switch (keyCode [0]) { + case 125: { /* Down */ + int index = getSelectionIndex (); + setSelection (Math.min (itemCount - 1, index + 1)); + return OS.noErr; + } + case 126: { /* Up*/ + int index = getSelectionIndex (); + setSelection (Math.max (0, index - 1)); + return OS.noErr; + } + } + return OS.eventNotHandledErr; +} + +int kEventRawKeyRepeat (int nextHandler, int theEvent, int userData) { + int result = super.kEventRawKeyRepeat (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * Feature in the Macintosh. For some reason, when the user hits an + * up or down arrow to traverse the items in a Data Browser, the item + * scrolls to the left such that the white space that is normally + * visible to the right of the every item is scrolled out of view. + * The fix is to do the arrow traversal in Java and not call the + * default handler. + */ + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + switch (keyCode [0]) { + case 125: { /* Down */ + int index = getSelectionIndex (); + setSelection (Math.min (itemCount - 1, index + 1)); + return OS.noErr; + } + case 126: { /* Up*/ + int index = getSelectionIndex (); + setSelection (Math.max (0, index - 1)); + return OS.noErr; + } + } + return OS.eventNotHandledErr; +} + +void releaseWidget () { + for (int i=0; i<columnCount; i++) { + TableColumn column = columns [i]; + if (!column.isDisposed ()) column.releaseResources (); + } + columns = null; + for (int i=0; i<itemCount; i++) { + TableItem item = items [i]; + if (!item.isDisposed ()) item.releaseResources (); + } + items = null; + super.releaseWidget (); +} + +public void remove (int index) { + checkWidget(); + if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE); + int [] id = new int [] {itemCount}; + if (OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, id.length, id, 0) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_REMOVED); + } + TableItem item = items [index]; + System.arraycopy (items, index + 1, items, index, --itemCount - index); + items [itemCount] = null; + item.releaseResources (); + OS.UpdateDataBrowserItems (handle, 0, 0, null, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); +} + +public void remove (int start, int end) { + checkWidget(); + if (!(0 <= start && start <= end && end < itemCount)) { + error (SWT.ERROR_INVALID_RANGE); + } + int length = end - start + 1; + for (int i=0; i<length; i++) remove (start); +} + +public void remove (int [] indices) { + if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); + int [] newIndices = new int [indices.length]; + System.arraycopy (indices, 0, newIndices, 0, indices.length); + sort (newIndices); + int last = -1; + for (int i=0; i<newIndices.length; i++) { + int index = newIndices [i]; + if (index != last || i == 0) remove (index); + last = index; + } +} + +public void removeAll () { + checkWidget(); + OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, 0, null, 0); + for (int i=0; i<itemCount; i++) { + TableItem item = items [i]; + if (!item.isDisposed ()) item.releaseResources (); + } + items = new TableItem [4]; + itemCount = columnCount = idCount = anchorFirst = anchorLast = 0; +} + +public void removeSelectionListener(SelectionListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + eventTable.unhook (SWT.Selection, listener); + eventTable.unhook (SWT.DefaultSelection,listener); +} + +public void select (int index) { + checkWidget(); + if (0 <- index && index < itemCount) { + int [] id = new int [] {index + 1}; + ignoreSelect = true; + int operation = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserItemsAssign: OS.kDataBrowserItemsAdd; + OS.SetDataBrowserSelectedItems (handle, id.length, id, operation); + ignoreSelect = false; + } +} + +public void select (int start, int end) { + checkWidget(); + //NOT DONE - check range + int length = end - start + 1; + if (length <= 0) return; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = end - i + 1; + ignoreSelect = true; + int operation = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserItemsAssign: OS.kDataBrowserItemsAdd; + OS.SetDataBrowserSelectedItems (handle, length, ids, operation); + ignoreSelect = false; +} + +public void select (int [] indices) { + checkWidget(); + if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); + //NOT DONE - check range + int length = indices.length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) ids [i] = indices [length - i - 1] + 1; + ignoreSelect = true; + int operation = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserItemsAssign: OS.kDataBrowserItemsAdd; + OS.SetDataBrowserSelectedItems (handle, ids.length, ids, operation); + ignoreSelect = false; +} + +public void selectAll () { + checkWidget (); + if ((style & SWT.SINGLE) != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsAssign); + ignoreSelect = false; +} + +public void setHeaderVisible (boolean show) { + checkWidget (); + int height = show ? headerHeight : 0; + OS.SetDataBrowserListViewHeaderBtnHeight (handle, (short)height); +} + +public void setLinesVisible (boolean show) { + checkWidget (); +} + +public void setSelection (int index) { + checkWidget(); + if (0 < index && index < itemCount) { + int [] id = new int [] {index + 1}; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, id.length, id, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + showIndex (id [0] - 1); + } +} + +public void setSelection (int start, int end) { + checkWidget (); + int length = end - start + 1; + if (length <= 0) return; + int count = length; + int [] ids = new int [length]; + for (int i=start; i<=end; i++) { + if (0 <= i && i < itemCount) ids [--count] = i + 1; + } + if (count != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + showIndex (ids [0] - 1); +} + +public void setSelection (int [] indices) { + if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); + int length = indices.length; + int count = length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) { + int index = indices [i]; + if (0 <= index && index < itemCount) ids [--count] = index + 1; + } + if (count != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + if (ids.length > 0) showIndex (ids [0] - 1); +} + +public void setSelection (TableItem [] items) { + checkWidget(); + if (items == null) error (SWT.ERROR_NULL_ARGUMENT); + int length = items.length; + int count = length; + int [] ids = new int [length]; + for (int i=0; i<length; i++) { + int index = indexOf (items [i]); + if (0 <= index && index < itemCount) ids [--count] = index + 1; + } + if (count != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + if (ids.length > 0) showIndex (ids [0] - 1); +} + +public void setTopIndex (int index) { + checkWidget(); + int [] top = new int [1], left = new int [1]; + OS.GetDataBrowserScrollPosition (handle, top, left); + top [0] = index * getItemHeight (); + OS.SetDataBrowserScrollPosition (handle, top [0], left [0]); +} + +void showIndex (int index) { + if (0 <= index && index < itemCount) { + //NOT DONE - doesn't work for SWT.CHECK + int id = columnCount == 0 ? COLUMN_ID : columns [0].id; + short [] width = new short [1]; + OS.GetDataBrowserTableViewNamedColumnWidth (handle, id, width); + Rect rect = new Rect (), inset = new Rect (); + OS.GetControlBounds (handle, rect); + OS.GetDataBrowserScrollBarInset (handle, inset); + OS.SetDataBrowserTableViewNamedColumnWidth (handle, id, (short)(rect.right - rect.left - inset.left - inset.right)); + OS.RevealDataBrowserItem (handle, index + 1, COLUMN_ID, (byte) OS.kDataBrowserRevealWithoutSelecting); + OS.SetDataBrowserTableViewNamedColumnWidth (handle, id, (short)width [0]); + } +} + +public void showItem (TableItem item) { + checkWidget (); + if (item == null) error (SWT.ERROR_NULL_ARGUMENT); + if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); + int index = indexOf (item); + if (index != -1) showIndex (index); +} + +public void showSelection () { + checkWidget(); + int index = getSelectionIndex (); + if (index >= 0) showIndex (index); +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableColumn.java new file mode 100644 index 0000000000..e7a7684fb7 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableColumn.java @@ -0,0 +1,183 @@ +package org.eclipse.swt.widgets; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +import org.eclipse.swt.internal.carbon.DataBrowserListViewColumnDesc; +import org.eclipse.swt.internal.carbon.DataBrowserListViewHeaderDesc; +import org.eclipse.swt.internal.carbon.OS; + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.events.*; + +public class TableColumn extends Item { + Table parent; + int id; + boolean resizable; + +public TableColumn (Table parent, int style) { + super (parent, checkStyle (style)); + resizable = true; + this.parent = parent; + parent.createItem (this, parent.getColumnCount ()); +} + +public TableColumn (Table parent, int style, int index) { + super (parent, checkStyle (style)); + resizable = true; + this.parent = parent; + parent.createItem (this, index); +} + +public void addControlListener(ControlListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Resize,typedListener); + addListener (SWT.Move,typedListener); +} + +public void 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.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0); +} + +protected void checkSubclass () { + if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); +} + +public int getAlignment () { + checkWidget (); + if ((style & SWT.LEFT) != 0) return SWT.LEFT; + if ((style & SWT.CENTER) != 0) return SWT.CENTER; + if ((style & SWT.RIGHT) != 0) return SWT.RIGHT; + return SWT.LEFT; +} + +public Display getDisplay () { + Table parent = this.parent; + if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); + return parent.getDisplay (); +} + +String getNameText () { + return getText (); +} + +public Table getParent () { + checkWidget (); + return parent; +} + +public boolean getResizable () { + checkWidget (); + return resizable; +} + +public int getWidth () { + checkWidget (); + short [] width = new short [1]; + OS.GetDataBrowserTableViewNamedColumnWidth (parent.handle, id, width); + return width [0]; +} + +public void pack () { + checkWidget (); + //NOT DONE + OS.SetDataBrowserTableViewNamedColumnWidth (parent.handle, id, (short)60); +} + +void releaseChild () { + super.releaseChild (); + parent.destroyItem (this); +} + +void releaseWidget () { + super.releaseWidget (); + parent = null; +} + +public void removeControlListener (ControlListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + eventTable.unhook (SWT.Move, listener); + eventTable.unhook (SWT.Resize, listener); +} + +public void removeSelectionListener(SelectionListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + eventTable.unhook (SWT.Selection, listener); + eventTable.unhook (SWT.DefaultSelection,listener); +} + +public void setAlignment (int alignment) { + checkWidget (); + if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return; + int index = parent.indexOf (this); + if (index == -1 || index == 0) return; + style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER); + style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER); +} + +public void setImage (Image image) { + checkWidget(); + if (image != null && image.isDisposed ()) { + error (SWT.ERROR_INVALID_ARGUMENT); + } + int index = parent.indexOf (this); + if (index == -1) return; + super.setImage (image); +} + +public void setResizable (boolean resizable) { + checkWidget (); + this.resizable = resizable; +} + +public void setText (String string) { + checkWidget (); + if (string == null) error (SWT.ERROR_NULL_ARGUMENT); + super.setText (string); + char [] buffer = new char [text.length ()]; + text.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} + j--; + } + } + int str = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); + if (str == 0) error (SWT.ERROR_CANNOT_SET_TEXT); + DataBrowserListViewHeaderDesc desc = new DataBrowserListViewHeaderDesc (); + desc.version = OS.kDataBrowserListViewLatestHeaderDesc; + //NOT DONE - for some reason this call GP's +// OS.GetDataBrowserListViewHeaderDesc (parent.handle, id, desc); + desc.maximumWidth = 0x7FFF; + desc.titleString = str; + OS.SetDataBrowserListViewHeaderDesc (parent.handle, id, desc); + OS.CFRelease (str); +} + +public void setWidth (int width) { + checkWidget (); + OS.SetDataBrowserTableViewNamedColumnWidth (parent.handle, id, (short)width); +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableItem.java new file mode 100644 index 0000000000..e8f15fbb37 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableItem.java @@ -0,0 +1,223 @@ +package org.eclipse.swt.widgets; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.widgets.Item; + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; + +public class TableItem extends Item { + Table parent; + String [] strings; + Image [] images; + boolean checked; + +public TableItem (Table parent, int style) { + super (parent, style); + this.parent = parent; + parent.createItem (this, parent.getItemCount ()); +} + +public TableItem (Table parent, int style, int index) { + super (parent, style); + this.parent = parent; + parent.createItem (this, index); +} + +protected void checkSubclass () { + if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); +} + +public Color getBackground () { + checkWidget (); + //NOT DONE + return getDisplay ().getSystemColor (SWT.COLOR_WHITE); +} + +public Rectangle getBounds (int index) { + checkWidget(); + //NOT DONE + return new Rectangle (0, 0, 0, 0); +} + +public boolean getChecked () { + checkWidget(); + if ((parent.style & SWT.CHECK) == 0) return false; + return checked; +} + +public Display getDisplay () { + Table parent = this.parent; + if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); + return parent.getDisplay (); +} + +public Color getForeground () { + checkWidget (); + //NOT DONE + return getDisplay ().getSystemColor (SWT.COLOR_BLACK); +} + +public boolean getGrayed () { + checkWidget (); + if ((parent.style & SWT.CHECK) == 0) return false; + //NOT DONE + return false; +} + +public Image getImage (int index) { + checkWidget(); + if (index == 0) return super.getImage (); + if (images != null) { + if (0 <= index && index < images.length) return images [index]; + } + return null; +} + +public Rectangle getImageBounds (int index) { + checkWidget(); + //NOT DONE + return new Rectangle (0, 0, 0, 0); +} + +public int getImageIndent () { + checkWidget(); + return 0; +} + +public Table getParent () { + checkWidget(); + return parent; +} + +public String getText (int index) { + checkWidget(); + if (index == 0) return super.getText (); + int itemIndex = parent.indexOf (this); + if (itemIndex == -1) error (SWT.ERROR_CANNOT_GET_TEXT); + if (strings != null) { + if (0 <= index && index < strings.length) { + String string = strings [index]; + return string != null ? string : ""; + } + } + return ""; +} + +void releaseChild () { + super.releaseChild (); + parent.destroyItem (this); +} + +void releaseWidget () { + super.releaseWidget (); + parent = null; +} + +public void setBackground (Color color) { + checkWidget (); + if (color != null && color.isDisposed ()) { + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } + //NOT DONE +} + +public void setChecked (boolean checked) { + checkWidget (); + if ((parent.style & SWT.CHECK) == 0) return; + int itemIndex = parent.indexOf (this); + if (itemIndex == -1) return; + this.checked = checked; + int [] id = new int [] {itemIndex + 1}; + OS.UpdateDataBrowserItems (parent.handle, 0, id.length, id, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); +} + +public void setForeground (Color color) { + checkWidget (); + if (color != null && color.isDisposed ()) { + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } + //NOT DONE +} + +public void setGrayed (boolean grayed) { + checkWidget (); + if ((parent.style & SWT.CHECK) == 0) return; + //NOT DONE +} + +public void setImage (Image [] images) { + checkWidget(); + if (images == null) error (SWT.ERROR_NULL_ARGUMENT); + for (int i=0; i<images.length; i++) { + setImage (i, images [i]); + } +} + +public void setImage (int index, Image image) { + checkWidget(); + if (image != null && image.isDisposed ()) { + error(SWT.ERROR_INVALID_ARGUMENT); + } + int itemIndex = parent.indexOf (this); + if (itemIndex == -1) return; + if (index == 0) { + super.setImage (image); + } + //NOT DONE +} + +public void setImage (Image image) { + checkWidget (); + setImage (0, image); +} + +public void setImageIndent (int indent) { + checkWidget(); + if (indent < 0) return; +} + +public void setText (String [] strings) { + checkWidget(); + if (strings == null) error (SWT.ERROR_NULL_ARGUMENT); + for (int i=0; i<strings.length; i++) { + String string = strings [i]; + if (string != null) setText (i, string); + } +} + +public void setText (int index, String string) { + checkWidget(); + if (string == null) error (SWT.ERROR_NULL_ARGUMENT); + int itemIndex = parent.indexOf (this); + if (itemIndex == -1) return; + if (index == 0) { + super.setText (string); + } + int columnCount = parent.columnCount; + if (0 <= index && index < columnCount) { + if (strings == null) strings = new String [columnCount]; + if (strings.length < columnCount) { + String [] newStrings = new String [columnCount]; + System.arraycopy (strings, 0, newStrings, 0, strings.length); + strings = newStrings; + } + if (0 <= index && index < strings.length) strings [index] = string; + } + int [] id = new int [] {itemIndex + 1}; + OS.UpdateDataBrowserItems (parent.handle, 0, id.length, id, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); +} + +public void setText (String string) { + checkWidget(); + setText (0, string); +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java index 13ca20a937..2490b52a93 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java @@ -7,41 +7,19 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; +import org.eclipse.swt.internal.carbon.EventRecord; +import org.eclipse.swt.internal.carbon.TXNLongRect; + import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.internal.carbon.*; - -/** - * Instances of this class are selectable user interface - * objects that allow the user to enter and modify text. - * <p> - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>MULTI, SINGLE, READ_ONLY, WRAP</dd> - * <dt><b>Events:</b></dt> - * <dd>DefaultSelection, Modify, Verify</dd> - * </dl> - * <p> - * Note: Only one of the styles MULTI and SINGLE may be specified. - * </p><p> - * IMPORTANT: This class is <em>not</em> intended to be subclassed. - * </p> - */ +import org.eclipse.swt.graphics.*; + public class Text extends Scrollable { - // AW - private static final int FOCUS_BORDER= 3; - private static final int MARGIN= 0; // 2; - - private int fTextLimit= LIMIT; - private int fTX; - private int fFrameID; - private Rectangle fFrameBounds; - // AW - + int txnObject, txnFrameID; + int textLimit = LIMIT; char echoCharacter; - // AW int drawCount; - public static final int LIMIT; public static final String DELIMITER; @@ -55,89 +33,17 @@ public class Text extends Scrollable { 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 Widget#checkSubclass - * @see Widget#getStyle - */ public Text (Composite parent, int style) { super (parent, checkStyle (style)); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the receiver's text is modified, by sending - * it one of the messages defined in the <code>ModifyListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ModifyListener - * @see #removeModifyListener - */ + public void addModifyListener (ModifyListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Modify, typedListener); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the control is selected, by sending - * 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 - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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); @@ -145,59 +51,28 @@ public void addSelectionListener(SelectionListener 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 listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the 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); - string = Display.convertToLf (string); - int length = OS.TXNDataSize(fTX) / 2; - if (hooks (SWT.Verify)) { - string = verifyText (string, length, length); + if (hooks (SWT.Verify) || filters (SWT.Verify)) { + int charCount = getCharCount (); + string = verifyText (string, charCount, charCount); if (string == null) return; } - replaceTXNText(OS.kTXNEndOffset, OS.kTXNEndOffset, string); + setTXNText (OS.kTXNEndOffset, OS.kTXNEndOffset, string); + OS.TXNSetSelection (txnObject, OS.kTXNEndOffset, OS.kTXNEndOffset); + OS.TXNShowSelection (txnObject, false); + if (string.length () != 0) sendEvent (SWT.Modify); } + static int checkStyle (int style) { style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0); if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL); @@ -207,808 +82,422 @@ static int checkStyle (int style) { } return style | SWT.SINGLE; } -/** - * Clears the selection. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void clearSelection () { checkWidget(); - OS.TXNSetSelection(fTX, OS.kTXNStartOffset, OS.kTXNStartOffset); // AW: wrong + int [] oStartOffset = new int [1], oEndOffset = new int [1]; + OS.TXNGetSelection (txnObject, oStartOffset, oEndOffset); + OS.TXNSetSelection (txnObject, oStartOffset [0], oStartOffset [0]); } + public Point computeSize (int wHint, int hHint, boolean changed) { - checkWidget(); - int width = wHint; - int height = hHint; - if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) { - int size= OS.TXNDataSize(fTX); - if (size == 0) { - if (hHint == SWT.DEFAULT) { - if ((style & SWT.SINGLE) != 0) { - int[] textBounds= new int[4]; - OS.TXNGetRectBounds(fTX, null, null, textBounds); - height= textBounds[2]-textBounds[0]; - } else - height= DEFAULT_HEIGHT; - } - if (wHint == SWT.DEFAULT) - width= DEFAULT_WIDTH; - } else { - int[] textBounds= new int[4]; - OS.TXNGetRectBounds(fTX, null, null, textBounds); - if (hHint == SWT.DEFAULT) - height= textBounds[2]-textBounds[0]; - if (wHint == SWT.DEFAULT) - width= textBounds[3]-textBounds[1]; - } - } - if (horizontalBar != null) { - height += 15; - } - if (verticalBar != null) { - width += 15; - } - /* AW - XRectangle rect = new XRectangle (); - OS.XmWidgetGetDisplayRect (handle, rect); - width += rect.x * 2; height += rect.y * 2; - if ((style & (SWT.MULTI | SWT.BORDER)) != 0) height++; - */ - // AW - width += 2*MARGIN; - height += 2*MARGIN; - if ((style & SWT.BORDER) != 0) { - width += 2*FOCUS_BORDER; - height += 2*FOCUS_BORDER; - } - // AW + TXNLongRect oTextRect = new TXNLongRect (); + OS.TXNGetRectBounds (txnObject, null, null, oTextRect); + int width = oTextRect.right - oTextRect.left; + int height = oTextRect.bottom - oTextRect.top; + 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 = trim.width; height = trim.height; return new Point (width, height); } + public Rectangle computeTrim (int x, int y, int width, int height) { - checkWidget(); - Rectangle trim = super.computeTrim(x, y, width, height); - /* AW - XRectangle rect = new XRectangle (); - OS.XmWidgetGetDisplayRect (handle, rect); - trim.x -= rect.x; - trim.y -= rect.y; - trim.width += rect.x; - trim.height += rect.y; - */ - /* AW - if ((style & (SWT.MULTI | SWT.BORDER)) != 0) trim.height += 3; - */ - // AW - if ((style & SWT.BORDER) != 0) { - trim.x -= FOCUS_BORDER; - trim.y -= FOCUS_BORDER; - trim.width += FOCUS_BORDER; - trim.height += FOCUS_BORDER; - } - // AW - return trim; -} -/** - * Copies the selected text. - * <p> - * The current selection is copied to the clipboard. - * </p> - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + checkWidget (); + int ptr = OS.NewPtr (Rect.sizeof); + OS.TXNGetTXNObjectControls (txnObject, 1, new int [] {OS.kTXNMarginsTag}, new int [] {ptr}); + Rect rect = new Rect (); + OS.memcpy (rect, ptr, Rect.sizeof); + OS.DisposePtr (ptr); + width += rect.left + rect.right; + height += rect.top + rect.bottom; + int [] size = new int [1]; + OS.GetThemeMetric(OS.kThemeMetricScrollBarWidth, size); + if (horizontalBar != null) height += size [0]; + if (verticalBar != null) width += size [0]; + Rect inset = inset (); + x -= inset.left; + y -= inset.top; + width += inset.left + inset.right; + height += inset.top + inset.bottom; + return new Rectangle (x, y, width, height); +} + public void copy () { - checkWidget(); - OS.TXNCopy(fTX); -} -void createHandle (int index) { - state |= HANDLE; - /* AW - int [] argList1 = { - OS.XmNverifyBell, 0, - OS.XmNeditMode, (style & SWT.SINGLE) != 0 ? OS.XmSINGLE_LINE_EDIT : OS.XmMULTI_LINE_EDIT, - OS.XmNscrollHorizontal, (style & SWT.H_SCROLL) != 0 ? 1 : 0, - OS.XmNscrollVertical, (style & SWT.V_SCROLL) != 0 ? 1 : 0, - OS.XmNwordWrap, (style & SWT.WRAP) != 0 ? 1: 0, - OS.XmNeditable, (style & SWT.READ_ONLY) != 0 ? 0 : 1, - OS.XmNcursorPositionVisible, (style & SWT.READ_ONLY) != 0 && (style & SWT.SINGLE) != 0 ? 0 : 1, - OS.XmNancestorSensitive, 1, - }; - */ - int frameOptions= OS.kTXNDontDrawCaretWhenInactiveMask | OS.kTXNMonostyledTextMask; - if ((style & SWT.H_SCROLL) != 0) - frameOptions |= OS.kTXNWantHScrollBarMask; - if ((style & SWT.V_SCROLL) != 0) - frameOptions |= OS.kTXNWantVScrollBarMask; - if ((style & SWT.SINGLE) != 0) - frameOptions |= OS.kTXNSingleLineOnlyMask; - if ((style & SWT.READ_ONLY) != 0) - frameOptions |= OS.kTXNReadOnlyMask; - if ((style & SWT.WRAP) != 0) - frameOptions |= OS.kTXNAlwaysWrapAtViewEdgeMask; - - int parentHandle= parent.handle; - handle= MacUtil.createDrawingArea(parentHandle, -1, true, 0, 0, 0); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); - - int wHandle= OS.GetControlOwner(parentHandle); - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - int frameType= OS.kTXNTextEditStyleFrameType; - int iFileType= OS.kTXNUnicodeTextFile; - int iPermanentEncoding= OS.kTXNSystemDefaultEncoding; - int[] tnxObject= new int[1]; - int[] frameID= new int[1]; - - /* - * Since MLTE is no real control it must embed its scrollbars in the root control. - * However, this breaks SWT assumption that everything is a nice and clean hierarchy. - * To work around this problem we try to move the scrollbars from the root control - * to the real parent of the Text widget. - * This is done in two steps: before creating the MLTE object with TXNNewObject - * we count the number of controls under the root control. Second step: see below. - */ - int root; - if (true) { - int[] rootHandle= new int[1]; - OS.GetRootControl(wHandle, rootHandle); - root= rootHandle[0]; - } else { - root= OS.HIViewGetRoot(wHandle); - } - short[] cnt= new short[1]; - OS.CountSubControls(root, cnt); - short oldCount= cnt[0]; + checkWidget (); + OS.TXNCopy (txnObject); +} + +void createHandle () { + int features = OS.kControlSupportsEmbedding | OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick; + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateUserPaneControl (window, null, features, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; /* - * Create the MLTE object (and possibly 0-2 scrollbars) - */ - int status= OS.TXNNewObject(0, wHandle, bounds.getData(), frameOptions, frameType, iFileType, iPermanentEncoding, - tnxObject, frameID, handle); - if (status != OS.kNoErr) - error(SWT.ERROR_NO_HANDLES); - - /* - * Second step: count the controls under root again to find out how many - * scrollbars had been added. Then move these new controls under the user pane - */ - short[] newCnt= new short[1]; - OS.CountSubControls(root, newCnt); - short newCount= newCnt[0]; - int[] child= new int[1]; - for (short i= newCount; i > oldCount; i--) { - OS.GetIndexedSubControl(root, i, child); - OS.HIViewRemoveFromSuperview(child[0]); - OS.HIViewAddSubview(handle, child[0]); - } + * Feature in the Macintosh. The TXNObject is not a control but creates scroll + * bar controls to scroll the text. These are created in the root and are not + * children of the user pane that is used to represent the TNXObject. The fix + * is to embed the scroll bars in the user pane.
*/ + int [] theRoot = new int [1]; + OS.GetRootControl (window, theRoot); + short [] oldCount = new short [1]; + OS.CountSubControls (theRoot [0], oldCount); - fTX= tnxObject[0]; - fFrameID= frameID[0]; - OS.TXNActivate(fTX, fFrameID, OS.kScrollBarsSyncWithFocus); + /* Create the TXNObject */ + int iFrameOptions = OS.kTXNDontDrawCaretWhenInactiveMask | OS.kTXNMonostyledTextMask; + if ((style & SWT.H_SCROLL) != 0) iFrameOptions |= OS.kTXNWantHScrollBarMask; + if ((style & SWT.V_SCROLL) != 0) iFrameOptions |= OS.kTXNWantVScrollBarMask; + if ((style & SWT.SINGLE) != 0) iFrameOptions |= OS.kTXNSingleLineOnlyMask; + if ((style & SWT.READ_ONLY) != 0) iFrameOptions |= OS.kTXNReadOnlyMask; + if ((style & SWT.WRAP) != 0) iFrameOptions |= OS.kTXNAlwaysWrapAtViewEdgeMask; + int [] oTXNObject = new int [1], oTXNFrameID = new int[1]; + OS.TXNNewObject (0, window, null, iFrameOptions, OS.kTXNTextEditStyleFrameType, OS.kTXNUnicodeTextFile, OS.kTXNSystemDefaultEncoding, oTXNObject, oTXNFrameID, 0); + if (oTXNObject [0] == 0) error (SWT.ERROR_NO_HANDLES); + txnObject = oTXNObject [0]; + txnFrameID = oTXNFrameID [0]; - OS.TXNFocus(fTX, false); - /* - * If the widget remains empty the caret will be too short. - * As a workaround initialize the widget with a single character - * and immediately remove it afterwards. - */ - OS.TXNSetData(fTX, new char[] { ' ' }, 0, 0); - OS.TXNSetData(fTX, new char[0], 0, 1); + /* Embed the scroll bars in the user pane */ + short [] newCount = new short [1]; + OS.CountSubControls (theRoot [0], newCount); + int [] scrollBar = new int [1]; + for (int i=newCount [0]; i>oldCount [0]; --i) { + OS.GetIndexedSubControl (theRoot [0], (short) i, scrollBar); + OS.HIViewRemoveFromSuperview (scrollBar [0]); + OS.HIViewAddSubview (handle, scrollBar [0]); + } - OS.setTXNMargins(fTX, (short)MARGIN); + /* Configure the TXNOBject */ + OS.TXNSetTXNObjectControls (txnObject, false, 1, new int [] {OS.kTXNDisableDragAndDropTag}, new int [] {1}); + OS.TXNSetFrameBounds (txnObject, 0, 0, 0, 0, txnFrameID); + int ptr = OS.NewPtr (Rect.sizeof); + Rect rect = new Rect (); + OS.SetRect (rect, (short) 1, (short) 1, (short) 1, (short) 1); + OS.memcpy (ptr, rect, Rect.sizeof); + OS.TXNSetTXNObjectControls (txnObject, false, 1, new int [] {OS.kTXNMarginsTag}, new int [] {ptr}); + OS.DisposePtr (ptr); +} - OS.TXNSetTXNObjectControls(fTX, false, 1, new int[] { OS.kTXNDoFontSubstitution }, new int[] { 1 }); -} ScrollBar createScrollBar (int type) { - return createStandardBar (type); -} -/** - * Cuts the selected text. - * <p> - * The current selection is first copied to the - * clipboard and then deleted from the widget. - * </p> - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + return createStandardBar (style); +} + public void cut () { checkWidget(); - OS.TXNCut(fTX); -} -void destroyWidget () { - super.destroyWidget(); - if (fTX != 0) { - //System.out.println("Text.destroyWidget"); - OS.TXNDeleteObject(fTX); - fTX= 0; + Point oldSelection = getSelection (); + if (hooks (SWT.Verify) || filters (SWT.Verify)) { + if (oldSelection.x != oldSelection.y) { + String newText = verifyText ("", oldSelection.x, oldSelection.y); + if (newText == null) return; + if (newText.length () != 0) { + setTXNText (OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection, newText); + } + } } + OS.TXNCut (txnObject); + Point newSelection = getSelection (); + if (!oldSelection.equals (newSelection)) sendEvent (SWT.Modify); } -int defaultBackground () { - return getDisplay ().textBackground; -} -Font defaultFont () { - return getDisplay ().textFont; -} -int defaultForeground () { - return getDisplay ().textForeground; -} -/** - * Gets the line number of the caret. - * <p> - * The line number of the caret is returned. - * </p> - * - * @return the line number - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +void drawWidget (int control) { + OS.TXNDraw (txnObject, 0); + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + Rect inset = inset (); + rect.left += inset.left; + rect.top += inset.top; + rect.right -= inset.right; + rect.bottom -= inset.bottom; + if (hasBorder ()) { + int state = OS.IsControlActive (handle) ? OS.kThemeStateActive : OS.kThemeStateInactive; + if (hasFocus ()) { + OS.DrawThemeEditTextFrame (rect, state); + OS.DrawThemeFocusRect (rect, true); + } else { + OS.DrawThemeFocusRect (rect, false); + OS.DrawThemeEditTextFrame (rect, state); + } + } else { + OS.DrawThemeFocusRect (rect, hasFocus ()); + } +} + public int getCaretLineNumber () { checkWidget(); - /* AW - return getLineNumber (OS.XmTextGetInsertionPosition (handle)); - */ - System.out.println("Text.getCaretLineNumber: nyi"); - return 1; -} -/** - * Gets the location the caret. - * <p> - * The location of the caret is returned. - * </p> - * - * @return a point, the location of the caret - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + if ((style & SWT.SINGLE) != 0) return 0; + return (getTopPixel () + getCaretLocation ().y) / getLineHeight (); +} + public Point getCaretLocation () { checkWidget(); - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - int [] start= new int [1], end= new int [1]; - OS.TXNGetSelection(fTX, start, end); - MacPoint loc= new MacPoint(); - OS.TXNOffsetToPoint(fTX, end[0], loc.getData()); - Point p= loc.toPoint(); - p.x-= bounds.getX(); - p.y-= bounds.getY(); - return p; -} -/** - * Gets the position of the caret. - * <p> - * The character position of the caret is returned. - * </p> - * - * @return the position of the caret - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + org.eclipse.swt.internal.carbon.Point oPoint = new org.eclipse.swt.internal.carbon.Point (); + int [] oStartOffset = new int [1], oEndOffset = new int [1]; + OS.TXNGetSelection (txnObject, oStartOffset, oEndOffset); + OS.TXNOffsetToPoint (txnObject, oStartOffset [0], oPoint); + Rect oViewRect = new Rect (); + OS.TXNGetViewRect (txnObject, oViewRect); + return new Point (oPoint.h - oViewRect.left, oPoint.v - oViewRect.top); +} + public int getCaretPosition () { - checkWidget(); - /* AW - return OS.XmTextGetInsertionPosition (handle); - */ - int [] start= new int [1], end= new int [1]; - OS.TXNGetSelection(fTX, start, end); - return end[0]; -} -/** - * Gets the number of characters. - * - * @return number of characters in the widget - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + checkWidget(); + int [] oStartOffset = new int [1], oEndOffset = new int [1]; + OS.TXNGetSelection (txnObject, oStartOffset, oEndOffset); + return oStartOffset [0]; +} + public int getCharCount () { checkWidget(); - return OS.TXNDataSize(fTX) / 2; -} -/** - * Gets the double click enabled flag. - * <p> - * The double click flag enables or disables the - * default action of the text widget when the user - * double clicks. - * </p> - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + return OS.TXNDataSize (txnObject) / 2; +} + public boolean getDoubleClickEnabled () { checkWidget(); - System.out.println("Text.getDoubleClickEnabled: nyi"); + //NOT DONE return true; } -/** - * Gets the echo character. - * <p> - * The echo character is the character that is - * displayed when the user enters text or the - * text is changed by the programmer. - * </p> - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public char getEchoChar () { checkWidget(); return echoCharacter; } -/** - * Gets the editable state. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public boolean getEditable () { checkWidget(); - /* - * Bug in MOTIF. For some reason, when XmTextGetEditable () is called - * from inside an XmNvalueChangedCallback or XmNModifyVerifyCallback, - * it always returns TRUE. Calls to XmTextGetEditable () outside of - * these callbacks return the correct value. The fix is to query the - * resource directly instead of using the convenience function. - */ - /* AW - int [] argList = {OS.XmNeditable, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - return argList [1] != 0; - */ - System.out.println("Text.getEditable: nyi"); - return true; -} -/** - * Gets the number of lines. - * - * @return the number of lines in the widget - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + return (style & SWT.READ_ONLY) == 0; +} + public int getLineCount () { checkWidget(); - int[] lineTotal= new int[1]; - OS.TXNGetLineCount(fTX, lineTotal); - return lineTotal[0]; -} -/** - * Gets the line delimiter. - * - * @return a string that is the line delimiter - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + int [] oLineTotal = new int [1]; + OS.TXNGetLineCount (txnObject, oLineTotal); + return oLineTotal [0]; +} + public String getLineDelimiter () { checkWidget(); return DELIMITER; } -/** - * Gets the height of a line. - * - * @return the height of a row of text - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int getLineHeight () { checkWidget(); - return getFontHeight (); -} -int getLineNumber (int position) { - if (position == 0) return 0; - int count = 0; - /* AW - int count = 0, start = 0, page = 1024; - char [] buffer = new char [page + 1]; - */ - /* - * Bug in Linux. For some reason, XmTextGetSubstringWcs () does - * not copy wchar_t characters into the buffer. Instead, it - * copies 4 bytes per character. This does not happen on other - * platforms such as AIX. The fix is to call XmTextGetSubstring () - * instead on Linux and rely on the fact that Metrolink Motif 1.2 - * does not support multibyte locales. - */ - /* AW - byte [] buffer1 = null; - if (OS.IsLinux) buffer1 = new byte [page + 1]; - int end = ((position + page - 1) / page) * page; - while (start < end) { - int length = page; - if (start + page > position) length = position - start; - if (echoCharacter != '\0') { - hiddenText.getChars (start, start + length, buffer, 0); - } else { - if (OS.IsLinux) { - OS.XmTextGetSubstring (handle, start, length, buffer1.length, buffer1); - for (int i=0; i<length; i++) buffer [i] = (char) buffer1 [i]; - } else { - OS.XmTextGetSubstringWcs (handle, start, length, buffer.length, buffer); - } - } - for (int i=0; i<length; i++) { - if (buffer [i] == '\n') count++; - } - start += page; - } - */ - System.out.println("Text.getLineNumber: nyi"); - return count; -} -/** - * Gets the position of the selected text. - * <p> - * Indexing is zero based. The range of - * a selection is from 0..N where N is - * the number of characters in the widget. - * </p> - * - * @return the start and end of the selection - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + int [] oLineWidth = new int [1], oLineHeight = new int [1]; + OS.TXNGetLineMetrics (txnObject, 0, oLineWidth, oLineHeight); + return OS.Fix2Long (oLineHeight [0]); +} + public Point getSelection () { checkWidget(); - int [] start = new int [1], end = new int [1]; - OS.TXNGetSelection(fTX, start, end); - return new Point (start [0], end [0]); -} -/** - * Gets the number of selected characters. - * - * @return the number of selected characters. - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + int [] oStartOffset = new int [1], oEndOffset = new int [1]; + OS.TXNGetSelection (txnObject, oStartOffset, oEndOffset); + return new Point (oStartOffset [0], oEndOffset [0]); +} + public int getSelectionCount () { checkWidget(); - int [] start = new int [1], end = new int [1]; - OS.TXNGetSelection(fTX, start, end); - return end [0] - start [0]; -} -/** - * Gets the selected text. - * - * @return the selected text - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + int [] oStartOffset = new int [1], oEndOffset = new int [1]; + OS.TXNGetSelection (txnObject, oStartOffset, oEndOffset); + return oEndOffset [0] - oStartOffset [0]; +} + public String getSelectionText () { checkWidget(); - return getTXNText(OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection); -} -/** - * Gets the number of tabs. - * <p> - * Tab stop spacing is specified in terms of the - * space (' ') character. The width of a single - * tab stop is the pixel width of the spaces. - * </p> - * - * @return the number of tab characters - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + return getTXNText (OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection); +} + public int getTabs () { checkWidget(); - System.out.println("Text.getTabs: nyi"); + //NOT DONE return 8; } -/** - * Gets the widget text. - * <p> - * The text for a text widget is the characters in the widget. - * </p> - * - * @return the widget text - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public String getText () { checkWidget(); - return getTXNText(OS.kTXNStartOffset, OS.kTXNEndOffset); -} -/** - * Gets a range of text. - * <p> - * Indexing is zero based. The range of - * a selection is from 0..N-1 where N is - * the number of characters in the widget. - * </p> - * - * @param start the start of the range - * @param end the end of the range - * @return the range of text - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + return getTXNText (OS.kTXNStartOffset, OS.kTXNEndOffset); +} + public String getText (int start, int end) { - checkWidget(); - int numChars = end - start + 1; - if (numChars < 0 || start < 0) return ""; - return getTXNText(start, end); -} -/** - * 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> - */ + checkWidget (); + if (start < 0 || start > end) return ""; + return getTXNText (start, end); +} + public int getTextLimit () { checkWidget(); - return fTextLimit; -} -/** - * 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> - */ + return textLimit; +} + public int getTopIndex () { checkWidget(); if ((style & SWT.SINGLE) != 0) return 0; - if (scrolledHandle == 0) return 0; - /* AW - int [] argList1 = {OS.XmNverticalScrollBar, 0}; - OS.XtGetValues (scrolledHandle, argList1, argList1.length / 2); - if (argList1 [1] == 0) return 0; - int [] argList2 = {OS.XmNvalue, 0}; - OS.XtGetValues (argList1 [1], argList2, argList2.length / 2); - return argList2 [1]; - */ - System.out.println("Text.getTopIndex: nyi"); - return 0; -} -/** - * Gets the top pixel. - * <p> - * The top pixel is the pixel position of the line - * that is currently at the top of the widget. On - * some platforms, a text widget can be scrolled by - * pixels instead of lines so that a partial line - * is displayed at the top of the widget. - * </p><p> - * The top pixel changes when the widget is scrolled. - * The top pixel does not include the widget trimming. - * </p> - * - * @return the pixel position of the top line - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + return getTopPixel () / getLineHeight (); +} + public int getTopPixel () { checkWidget(); - return getTopIndex () * getLineHeight (); + if ((style & SWT.SINGLE) != 0) return 0; + Rect oViewRect = new Rect (); + TXNLongRect oDestinationRect = new TXNLongRect (); + TXNLongRect oTextRect = new TXNLongRect (); + OS.TXNGetRectBounds (txnObject, oViewRect, oDestinationRect, oTextRect); + return oDestinationRect.top - oTextRect.top; } -boolean getWrap () { - checkWidget(); - /* AW - int [] argList = {OS.XmNwordWrap, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - return argList [1] != 0; - */ - System.out.println("Text.getWrap: nyi"); - return false; -} -void hookEvents () { - super.hookEvents (); - /* AW - int windowProc = getDisplay ().windowProc; - OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, SWT.DefaultSelection); - OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Modify); - OS.XtAddCallback (handle, OS.XmNmodifyVerifyCallback, windowProc, SWT.Verify); - */ - Display display= getDisplay(); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneDrawProcTag, display.fUserPaneDrawProc); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneHitTestProcTag, display.fUserPaneHitTestProc); -} -/** - * Inserts a string. - * <p> - * The old selection is replaced with the new text. - * </p> - * - * @param string the string - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +String getTXNText (int iStartOffset, int iEndOffset) { + int [] oDataHandle = new int [1]; + OS.TXNGetData (txnObject, iStartOffset, iEndOffset, oDataHandle); + if (oDataHandle [0] == 0) return ""; + int length = OS.GetHandleSize (oDataHandle [0]); + if (length == 0) return ""; + int [] ptr = new int [1]; + OS.HLock (oDataHandle [0]); + OS.memcpy (ptr, oDataHandle [0], 4); + char [] buffer = new char [length / 2]; + OS.memcpy (buffer, ptr [0], length); + OS.HUnlock (oDataHandle[0]); + OS.DisposeHandle (oDataHandle[0]); + return new String (buffer); +} + +Rect inset () { + Rect rect = new Rect (); + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric); + rect.left += outMetric [0]; + rect.top += outMetric [0]; + rect.right += outMetric [0]; + rect.bottom += outMetric [0]; + if (hasBorder ()) { + OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric); + rect.left += outMetric [0]; + rect.top += outMetric [0]; + rect.right += outMetric [0]; + rect.bottom += outMetric [0]; + } + return rect; +} + public void insert (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - string = Display.convertToLf (string); - if (hooks (SWT.Verify)) { - int [] start = new int [1], end = new int [1]; - OS.TXNGetSelection(fTX, start, end); - string = verifyText (string, start [0], end [0]); + if (hooks (SWT.Verify) || filters (SWT.Verify)) { + Point selection = getSelection (); + string = verifyText (string, selection.x, selection.y); if (string == null) return; } - /* AW - TCHAR buffer = new TCHAR (getCodePage (), string, true); - OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); + setTXNText (OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection, string); + OS.TXNShowSelection (txnObject, false); + if (string.length () != 0) sendEvent (SWT.Modify); +} + +int kEventControlActivate (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlActivate (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + OS.TXNFocus (txnObject, hasFocus ()); + OS.TXNActivate (txnObject, txnFrameID, OS.kScrollBarsSyncAlwaysActive); + return result; +} + +int kEventControlBoundsChanged (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlBoundsChanged (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + int [] attributes = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamAttributes, OS.typeUInt32, null, attributes.length * 4, null, attributes); + if ((attributes [0] & (OS.kControlBoundsChangePositionChanged | OS.kControlBoundsChangeSizeChanged)) != 0) { + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + Rect inset = inset (); + rect.left += inset.left; + rect.top += inset.top; + rect.right -= inset.right; + rect.bottom -= inset.bottom; + OS.TXNSetFrameBounds (txnObject, rect.top, rect.left, rect.bottom, rect.right, txnFrameID); + } + return result; +} + +int kEventControlClick (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlClick (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + int window = OS.GetControlOwner (handle); + OS.SetKeyboardFocus (window, handle, (short)OS.kControlFocusNextPart); + EventRecord iEvent = new EventRecord (); + OS.ConvertEventRefToEventRecord (theEvent, iEvent); + OS.TXNClick (txnObject, iEvent); + return OS.noErr; +} + +int kEventControlDeactivate (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlDeactivate (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + OS.TXNFocus (txnObject, hasFocus()); + OS.TXNActivate (txnObject, txnFrameID, OS.kScrollBarsSyncWithFocus); + return result; +} + +int kEventControlSetCursor (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlSetCursor (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + OS.TXNAdjustCursor (txnObject, 0); + return OS.noErr; +} + +int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlSetFocusPart (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + short [] part = new short [1]; + OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part); + OS.TXNFocus (txnObject, part [0] != 0); + redraw (); + return OS.noErr; +} + +int kEventRawKeyDown (int nextHandler, int theEvent, int userData) { + /* + * Bug in the Macintosh. When the default handler calls TXNKeyDown() + * for a single line TXN Object, it does not check for the return key + * or the default button. The result is that a garbage character (the + * CR) is entered into the TXN Object. The fix is to temporarily take + * focus away from the TXN Object, call the default handler to process + * the return key and reset the focus. */ - replaceTXNText(OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection, string); -} -/** - * 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> - */ + if ((style & SWT.SINGLE) != 0) { + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + switch (keyCode [0]) { + case 36: //CR KEY + OS.TXNFocus (txnObject, false); + int result = OS.CallNextEventHandler (nextHandler, theEvent); + OS.TXNFocus (txnObject, true); + return result; + } + } + return super.kEventRawKeyDown (nextHandler, theEvent, userData); +} + public void paste () { checkWidget(); - OS.TXNPaste(fTX); + //NOT DONE - get clipboard text and verify or use undo? + OS.TXNPaste (txnObject); } -int processFocusIn () { - super.processFocusIn (); - // widget could be disposed at this point - if (handle == 0) return 0; - if ((style & SWT.READ_ONLY) != 0) return 0; - - drawFrame(null); - OS.TXNFocus(fTX, true); - - if ((style & SWT.MULTI) != 0) return 0; - /* AW - int [] argList = {OS.XmNcursorPositionVisible, 1}; - OS.XtSetValues (handle, argList, argList.length / 2); - */ - return 0; -} -int processFocusOut () { - super.processFocusOut (); - // widget could be disposed at this point - if (handle == 0) return 0; - if ((style & SWT.READ_ONLY) != 0) return 0; - - //fgTextInFocus= null; - OS.TXNFocus(fTX, false); - drawFrame(null); - - if ((style & SWT.MULTI) != 0) return 0; - /* AW - int [] argList = {OS.XmNcursorPositionVisible, 0}; - OS.XtSetValues (handle, argList, argList.length / 2); - */ - return 0; -} -int processMouseDown (MacMouseEvent mmEvent) { - if (isEnabled()) { - int macEvent[]= mmEvent.toOldMacEvent(); - if (macEvent != null) - OS.TXNClick(fTX, macEvent); - } - return 0; -} -int processPaint (Object callData) { - syncBounds(null); - drawFrame(callData); - return 0; -} -/** - * Removes the listener from the collection of listeners who will - * be notified when the receiver's text is modified. - * - * @param listener the listener which should no longer be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ModifyListener - * @see #addModifyListener - */ + +void releaseWidget () { + super.releaseWidget (); + OS.TXNDeleteObject (txnObject); + txnObject = txnFrameID = 0; +} + 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. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ + public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -1016,372 +505,173 @@ public void removeSelectionListener(SelectionListener listener) { 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 - */ + 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.TXNSelectAll(fTX); -} -/** - * Sets the double click enabled flag. - * <p> - * The double click flag enables or disables the - * default action of the text widget when the user - * double clicks. - * </p> - * - * @param doubleClick the new double click flag - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + OS.TXNSelectAll (txnObject); +} + +boolean sendKeyEvent (int type, Event event) { + if (!super.sendKeyEvent (type, event)) { + return false; + } + if (type != SWT.KeyDown) return true; + if (event.character == 0) return true; + if ((style & SWT.READ_ONLY) != 0) return false; + String oldText = ""; + int charCount = getCharCount (); + Point selection = getSelection (); + int start = selection.x, end = selection.y; + switch (event.character) { + case SWT.BS: + if (start == end) { + if (start == 0) return true; + start = Math.max (0, start - 1); + } + break; + case SWT.DEL: + if (start == end) { + if (start == charCount) return true; + end = Math.min (end + 1, charCount); + } + break; + case SWT.CR: + if ((style & SWT.SINGLE) != 0) { + postEvent (SWT.DefaultSelection); + return true; + } + oldText = DELIMITER; + break; + default: + if (event.character != '\t' && event.character < 0x20) return true; + oldText = new String (new char [] {event.character}); + } + String newText = verifyText (oldText, start, end); + if (newText == null) return false; + if (charCount - (end - start) + newText.length () > textLimit) { + return false; + } + if (newText != oldText) setTXNText (start, end, newText); + /* + * Post the modify event so that the character will be inserted + * into the widget when the modify event is delivered. Normally, + * modify events are sent but it is safe to post the event here + * because this method is called from the event loop. + */ + postEvent (SWT.Modify); + return newText == oldText; +} + public void setDoubleClickEnabled (boolean doubleClick) { checkWidget(); - System.out.println("Text.setDoubleClickEnabled: nyi"); -} -/** - * 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, - * 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> - */ + //NOT DONE +} + public void setEchoChar (char echo) { checkWidget(); - if (echoCharacter == echo) return; echoCharacter = echo; - OS.TXNEchoMode(fTX, echo, 0, echo != '\0'); -} -/** - * 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> - */ + OS.TXNEchoMode (txnObject, echo, 0, echo != '\0'); +} + public void setEditable (boolean editable) { checkWidget(); - /* AW - OS.XmTextSetEditable (handle, editable); - int isEditable= editable ? 1 : 0; - */ - style &= ~SWT.READ_ONLY; - if (!editable) style |= SWT.READ_ONLY; - if ((style & SWT.MULTI) != 0) return; - /* - int [] argList = {OS.XmNcursorPositionVisible, editable && hasFocus () ? 1 : 0}; - OS.XtSetValues (handle, argList, argList.length / 2); - */ + if (editable) { + style &= ~SWT.READ_ONLY; + } else { + style |= SWT.READ_ONLY; + } } -/** - * Sets the redraw flag. - */ -public void setRedraw (boolean redraw) { - checkWidget(); - if ((style & SWT.SINGLE) != 0) return; - super.setRedraw(redraw); -// AW -// if (redraw) { -// if (--drawCount == 0) ; /* AW OS.XmTextEnableRedisplay(handle); */ -// } else { -// if (drawCount++ == 0) ; /* AW OS.XmTextDisableRedisplay(handle); */ -// } -// AW -} -/** - * 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 start) { checkWidget(); - OS.TXNSetSelection(fTX, start, start); -} -/** - * Sets the selection. - * <p> - * Indexing is zero based. The range of - * a selection is from 0..N where N is - * the number of characters in the widget. - * </p><p> - * Text selections are specified in terms of - * caret positions. In a text widget that - * contains N characters, there are N+1 caret - * positions, ranging from 0..N. This differs - * from other functions that address character - * position such as getText () that use the - * usual array indexing rules. - * </p> - * - * @param start the start of the range - * @param end the end of the range - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + setSelection (start, start); +} + public void setSelection (int start, int end) { checkWidget(); - OS.TXNSetSelection(fTX, start, end); -} -/** - * Sets the selection. - * <p> - * Indexing is zero based. The range of - * a selection is from 0..N where N is - * the number of characters in the widget. - * </p><p> - * Text selections are specified in terms of - * caret positions. In a text widget that - * contains N characters, there are N+1 caret - * positions, ranging from 0..N. This differs - * from other functions that address character - * position such as getText () that use the - * usual array indexing rules. - * </p> - * - * @param selection the point - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the 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> - */ + if (start < 0 || start > end) return; + OS.TXNSetSelection (txnObject, start, end); + OS.TXNShowSelection (txnObject, false); +} + public void setSelection (Point selection) { checkWidget(); if (selection == null) error (SWT.ERROR_NULL_ARGUMENT); setSelection (selection.x, selection.y); } - /** - * 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(); - System.out.println("Text.setTabs: nyi"); -} -/** - * 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 text the new text - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + //NOT DONE +} + public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); - string = Display.convertToLf (string); - if (hooks (SWT.Verify)) { - int length = OS.TXNDataSize(fTX) / 2; - string = verifyText (string, 0, length); + if (hooks (SWT.Verify) || filters (SWT.Verify)) { + string = verifyText (string, 0, getCharCount ()); if (string == null) return; } - replaceTXNText(OS.kTXNStartOffset, OS.kTXNEndOffset, string); - - showBeginning(); -} -/** - * 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>. - * </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> - */ + setTXNText (OS.kTXNStartOffset, OS.kTXNEndOffset, string); + OS.TXNSetSelection (txnObject, OS.kTXNStartOffset, OS.kTXNStartOffset); + OS.TXNShowSelection (txnObject, false); +} + +void setTXNText (int iStartOffset, int iEndOffset, String string) { + char [] buffer = new char [string.length ()]; + string.getChars (0, buffer.length, buffer, 0); + OS.TXNSetData (txnObject, OS.kTXNUnicodeTextData, buffer, buffer.length * 2, iStartOffset, iEndOffset); +} + public void setTextLimit (int limit) { checkWidget(); if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO); - fTextLimit= limit; -} -/** - * Sets the zero-relative index of the line which is currently - * at the top of the receiver. This index can change when lines - * are scrolled or new lines are added and removed. - * - * @param index the index of the top item - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + textLimit = limit; +} + public void setTopIndex (int index) { checkWidget(); if ((style & SWT.SINGLE) != 0) return; - if (scrolledHandle == 0) return; - /* AW - int [] argList1 = {OS.XmNverticalScrollBar, 0}; - OS.XtGetValues (scrolledHandle, argList1, argList1.length / 2); - if (argList1 [1] == 0) return; - int [] argList2 = {OS.XmNvalue, 0}; - OS.XtGetValues (argList1 [1], argList2, argList2.length / 2); - OS.XmTextScroll (handle, index - argList2 [1]); - */ - System.out.println("Text.setTopIndex: nyi"); -} -void setWrap (boolean wrap) { - checkWidget(); - /* AW - int [] argList = {OS.XmNwordWrap, wrap ? 1 : 0}; - OS.XtSetValues (handle, argList, argList.length / 2); - */ - System.out.println("Text.setWrap: nyi"); -} -/** - * Shows the selection. - * <p> - * If the selection is already showing - * in the receiver, this method simply returns. Otherwise, - * lines are scrolled until the selection is visible. - * </p> - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void showSelection () { - checkWidget(); - OS.TXNShowSelection(fTX, false); -} -int traversalCode () { - int bits = super.traversalCode (); - if ((style & SWT.READ_ONLY) != 0) return bits; - if ((style & SWT.MULTI) != 0) { - bits &= ~SWT.TRAVERSE_RETURN; - /* AW - if (key == OS.XK_Tab && xEvent != null) { - boolean next = (xEvent.state & OS.ShiftMask) == 0; - if (next && (xEvent.state & OS.ControlMask) == 0) { - bits &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS); - } - } - */ - } - return bits; + //NOT DONE +// Rect oViewRect = new Rect (); +// TXNLongRect oDestinationRect = new TXNLongRect (); +// TXNLongRect oTextRect = new TXNLongRect (); +// OS.TXNGetRectBounds (txnObject, oViewRect, oDestinationRect, oTextRect); +// int topPixel = oDestinationRect.top - oTextRect.top; +// int [] oOffset = new int [1]; +// org.eclipse.swt.internal.carbon.Point iPoint = new org.eclipse.swt.internal.carbon.Point (); +// OS.SetPt (iPoint, (short)0, (short)(-topPixel + (index * getLineHeight ()))); +// OS.TXNPointToOffset (txnObject, iPoint, oOffset); +// System.out.println (oOffset [0]); +// int [] oStartOffset = new int [1], oEndOffset = new int [1]; +// OS.TXNGetSelection (txnObject, oStartOffset, oEndOffset); +// OS.TXNSetSelection (txnObject, oOffset [0], oOffset [0]); +// OS.TXNShowSelection (txnObject, false); +// OS.TXNSetSelection (txnObject, oStartOffset [0], oEndOffset [0]); } -String verifyText (String string, int start, int end) { - return verifyText (string, start, end, null); + +public void setVisible (boolean visible) { + super.setVisible (visible); + OS.TXNSetTXNObjectControls (txnObject, false, 1, new int[] {OS.kTXNVisibilityTag}, new int[] {visible ? -1 : 0}); } -String verifyText (String string, int start, int end, Event keyEvent) { - int size= (OS.TXNDataSize(fTX) / 2) - (end-start); - if (size + string.length() > fTextLimit) - return null; +public void showSelection () { + checkWidget(); + OS.TXNShowSelection (txnObject, false); +} +String verifyText (String string, int start, int end) { Event event = new Event (); event.text = string; event.start = start; event.end = end; - if (keyEvent != null) { - event.character = keyEvent.character; - event.keyCode = keyEvent.keyCode; - event.stateMask = keyEvent.stateMask; - } /* * It is possible (but unlikely), that application * code could have disposed the widget in the verify @@ -1392,202 +682,5 @@ String verifyText (String string, int start, int end, Event keyEvent) { if (!event.doit || isDisposed ()) return null; return event.text; } -/////////////////////////////////////////// -// Mac Stuff -/////////////////////////////////////////// - - private void replaceTXNText(int start, int end, String s) { - int l= s.length(); - char[] chars= new char[l]; - s.getChars(0, l, chars, 0); - OS.TXNSetData(fTX, chars, start, end); - - //syncBounds(null); - - sendEvent (SWT.Modify); - } - - private String getTXNText(int start, int end) { - int[] dataHandle= new int[1]; - OS.TXNGetData(fTX, start, end, dataHandle); - int length= OS.GetHandleSize(dataHandle[0]); - if (length <= 0) - return ""; - char[] chars= new char[length/2]; - OS.getHandleData(dataHandle[0], chars); - OS.DisposeHandle(dataHandle[0]); - return new String(chars); - } - - int sendKeyEvent(int type, MacEvent mEvent, Event event) { - - int status= OS.kNoErr; // we handled the event - - if ((mEvent.getModifiers() & OS.cmdKey) != 0) { - int kind= mEvent.getKind(); - int code= mEvent.getKeyCode(); - switch (code) { - case 0: - if (kind == OS.kEventRawKeyDown) - selectAll(); - return status; - case 7: - if (kind == OS.kEventRawKeyDown) - cut(); - return status; - case 8: - if (kind == OS.kEventRawKeyDown) - copy(); - return status; - case 9: - if (kind == OS.kEventRawKeyDown || kind == OS.kEventRawKeyRepeat) - paste(); - return status; - default: - break; - } - } - - int eRefHandle= mEvent.getEventRef(); - int nextHandler= mEvent.getNextHandler(); - - if (hooks (SWT.Verify)) { - - // extract characters from event - String unicode= mEvent.getText(); - String text= unicode != null ? unicode : ""; - String original= new String(text); - - // send verify event - int[] start= new int[1], end= new int[1]; - OS.TXNGetSelection(fTX, start, end); - - if (text.length() == 1) { - switch (text.charAt(0)) { - case 0x08: - if (start[0] == end[0]) { - if (start[0] == 0) - return status; - if (start[0] > 0) - start[0]--; - } - break; - } - } - - String string= verifyText(original, start[0], end[0], event); - if (string == null) - return status; // ignore event - - int l= string.length(); - char[] newChars= new char[l]; - string.getChars(0, l, newChars, 0); - if (true) { - OS.SetEventParameter(eRefHandle, OS.kEventParamTextInputSendText, OS.typeUnicodeText, newChars); - status= OS.CallNextEventHandler(nextHandler, eRefHandle); - } else { - OS.TXNSetSelection(fTX, start[0], end[0]); - OS.TXNSetData(fTX, newChars, OS.kTXNUseCurrentSelection, OS.kTXNUseCurrentSelection); - OS.TXNSetSelection(fTX, start[0], start[0]+newChars.length); - } - } else { - status= OS.CallNextEventHandler(nextHandler, eRefHandle); - } - - sendEvent (SWT.Modify); - - return status; - } - void handleResize(int hndl, MacRect bounds) { - super.handleResize(hndl, bounds); - syncBounds(bounds); - } - - private void syncBounds(MacRect b) { - - if (fTX == 0) - return; - - if (b == null) { - b= new MacRect(); - OS.GetControlBounds(handle, b.getData()); - } - - int x= b.getX(); - int y= b.getY(); - int w= b.getWidth(); - int h= b.getHeight(); - - if ((style & SWT.BORDER) != 0) { - x+= FOCUS_BORDER; - y+= FOCUS_BORDER; - w-= 2*FOCUS_BORDER; - h-= 2*FOCUS_BORDER; - } - - Rectangle oldRect= fFrameBounds; - fFrameBounds= new Rectangle(x, y, w, h); - if (oldRect == null || !oldRect.equals(fFrameBounds)) { - OS.TXNSetFrameBounds(fTX, y, x, y+h, x+w, fFrameID); - } - - OS.TXNDraw(fTX, 0); - } - - private void drawFrame(Object callData) { - - if ((style & SWT.BORDER) == 0) - return; - - GC gc= new GC(this); - int damageRegion= 0; - if (callData instanceof MacControlEvent) - damageRegion= ((MacControlEvent)callData).getDamageRegionHandle(); - try { - Rectangle r= gc.carbon_focus(damageRegion); - if (!r.isEmpty()) { - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - bounds.setLocation(0, 0); - int m= FOCUS_BORDER; - bounds.inset(m, m, m, m+1); - - MacRect fbounds= new MacRect(); - OS.GetControlBounds(handle, fbounds.getData()); - fbounds.setLocation(0, 0); - int fm= FOCUS_BORDER; - fbounds.inset(fm, fm+1, fm, fm+1); - - - if ((style & SWT.READ_ONLY) == 0) { - if (getDisplay().getFocusControl() == this) { - OS.DrawThemeEditTextFrame(bounds.getData(), OS.kThemeStateActive); - OS.DrawThemeFocusRect(fbounds.getData(), true); - } else { - OS.DrawThemeFocusRect(fbounds.getData(), false); - OS.DrawThemeEditTextFrame(bounds.getData(), OS.kThemeStateActive); - } - } else { - OS.DrawThemeEditTextFrame(bounds.getData(), OS.kThemeStateActive); - } - - } - } finally { - gc.carbon_unfocus(); - } - showBeginning(); - } - - private void showBeginning() { - int[] start= new int[1], end= new int [1]; - OS.TXNGetSelection(fTX, start, end); - if (start[0] != 0 || end[0] != 0) { - OS.TXNSetSelection(fTX, 0, 0); - OS.TXNShowSelection(fTX, false); - OS.TXNSetSelection(fTX, start[0], end[0]); - } else { - OS.TXNShowSelection(fTX, false); - } - } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java index 2d83219fea..d31fa10c83 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolBar.java @@ -7,70 +7,16 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; + 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</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> - */ public class ToolBar extends Composite { int itemCount; ToolItem [] items; - // AW - boolean fGotSize= false; - // AW -/** - * 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#VERTICAL - * @see Widget#checkSubclass - * @see Widget#getStyle - */ + + public ToolBar (Composite parent, int style) { super (parent, checkStyle (style)); @@ -82,8 +28,13 @@ public ToolBar (Composite parent, int style) { * the bits using the original style supplied by the * programmer. */ - this.style = checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0); + if ((style & SWT.VERTICAL) != 0) { + this.style |= SWT.VERTICAL; + } else { + this.style |= SWT.HORIZONTAL; + } } + static int checkStyle (int style) { /* * Even though it is legal to create this widget @@ -94,27 +45,28 @@ static int checkStyle (int style) { */ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL); } + protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } + public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); int width = wHint, height = hHint; if (wHint == SWT.DEFAULT) width = 0x7FFFFFFF; if (hHint == SWT.DEFAULT) height = 0x7FFFFFFF; int [] result = layout (width, height, false); - int border = getBorderWidth () * 2; Point extent = new Point (result [1], result [2]); if (wHint != SWT.DEFAULT) extent.x = wHint; if (hHint != SWT.DEFAULT) extent.y = hHint; - extent.x += border; - extent.y += border; return extent; } -void createHandle (int index) { - super.createHandle (index); - state &= ~CANVAS; + +void createHandle () { + state |= GRAB; + super.createHandle (parent.handle); } + void createItem (ToolItem item, int index) { if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE); if (itemCount == items.length) { @@ -122,15 +74,22 @@ void createItem (ToolItem item, int index) { System.arraycopy (items, 0, newItems, 0, items.length); items = newItems; } - item.createWidget (index); + item.createWidget (); System.arraycopy (items, index, items, index + 1, itemCount++ - index); items [index] = item; + if (parent.font != null) item.setFontStyle (parent.font); } -void createWidget (int index) { - super.createWidget (index); + +void createWidget () { + super.createWidget (); items = new ToolItem [4]; itemCount = 0; } + +int defaultThemeFont () { + return OS.kThemeToolbarFont; +} + void destroyItem (ToolItem item) { int index = 0; while (index < itemCount) { @@ -141,187 +100,116 @@ void destroyItem (ToolItem item) { System.arraycopy (items, index + 1, items, index, --itemCount - index); items [itemCount] = null; } -/** - * Returns the item at the given, zero-relative index in the - * receiver. Throws an exception if the index is out of range. - * - * @param index the index of the item to return - * @return the item at the given index - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +void drawWidget (int control) { + drawBackground (handle, background); +} + public ToolItem getItem (int index) { checkWidget(); - ToolItem [] items = getItems (); - if (0 <= index && index < items.length) return items [index]; + if (0 <= index && index < itemCount) return items [index]; error (SWT.ERROR_INVALID_RANGE); return null; } -/** - * Returns the item at the given point in the receiver - * or null if no such item exists. The point is in the - * coordinate system of the receiver. - * - * @param point the point used to locate the item - * @return the item at the given point - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public ToolItem getItem (Point pt) { checkWidget(); - ToolItem [] items = getItems (); - for (int i=0; i<items.length; i++) { + 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 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 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 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(); Rectangle rect = getClientArea (); return layout (rect.width, rect.height, false) [0]; } -/** - * Searches the receiver's list starting at the first item - * (index 0) until an item is found that is equal to the - * argument, and returns the index of that item. If no item - * is found, returns -1. - * - * @param item the search item - * @return the index of the item - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the tool item is null</li> - * <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public int indexOf (ToolItem item) { checkWidget(); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); - ToolItem [] items = getItems (); - for (int i=0; i<items.length; i++) { + for (int i=0; i<itemCount; i++) { if (items [i] == item) return i; } return -1; } -int [] layoutHorizontal (int nWidth, int nHeight, boolean resize) { - int xSpacing = 0, ySpacing = (style & SWT.NO_FOCUS) != 0 ? 4 : 2; + +int [] layoutHorizontal (int width, int height, boolean resize) { + int xSpacing = 0, ySpacing = 2; int marginWidth = 0, marginHeight = 0; - ToolItem [] children = getItems (); - int length = children.length; int x = marginWidth, y = marginHeight; int maxHeight = 0, maxX = 0, rows = 1; boolean wrap = (style & SWT.WRAP) != 0; - for (int i=0; i<length; i++) { - ToolItem child = children [i]; - Rectangle rect = child.getBounds (); - if (wrap && i != 0 && x + rect.width > nWidth) { + int itemHeight = 0; + for (int i=0; i<itemCount; i++) { + Rectangle rect = items [i].getBounds (); + itemHeight = Math.max (itemHeight, rect.height); + } + for (int i=0; i<itemCount; i++) { + ToolItem item = items [i]; + Rectangle rect = item.getBounds (); + if (wrap && i != 0 && x + rect.width > width) { rows++; - x = marginWidth; y += ySpacing + maxHeight; + x = marginWidth; + y += ySpacing + maxHeight; maxHeight = 0; } maxHeight = Math.max (maxHeight, rect.height); if (resize) { - child.setBounds (x, y, rect.width, rect.height); + item.setBounds (x, y, rect.width, itemHeight); } x += xSpacing + rect.width; maxX = Math.max (maxX, x); } return new int [] {rows, maxX, y + maxHeight}; } -int [] layoutVertical (int nWidth, int nHeight, boolean resize) { - int xSpacing = (style & SWT.NO_FOCUS) != 0 ? 4 : 2, ySpacing = 0; + +int [] layoutVertical (int width, int height, boolean resize) { + int xSpacing = 2, ySpacing = 0; int marginWidth = 0, marginHeight = 0; - ToolItem [] children = getItems (); - int length = children.length; int x = marginWidth, y = marginHeight; int maxWidth = 0, maxY = 0, cols = 1; boolean wrap = (style & SWT.WRAP) != 0; - for (int i=0; i<length; i++) { - ToolItem child = children [i]; - Rectangle rect = child.getBounds (); - if (wrap && i != 0 && y + rect.height > nHeight) { + int itemWidth = 0; + for (int i=0; i<itemCount; i++) { + Rectangle rect = items [i].getBounds (); + itemWidth = Math.max (itemWidth, rect.width); + } + for (int i=0; i<itemCount; i++) { + ToolItem item = items [i]; + Rectangle rect = item.getBounds (); + if (wrap && i != 0 && y + rect.height > height) { cols++; - x += xSpacing + maxWidth; y = marginHeight; + x += xSpacing + maxWidth; + y = marginHeight; maxWidth = 0; } maxWidth = Math.max (maxWidth, rect.width); if (resize) { - child.setBounds (x, y, rect.width, rect.height); + item.setBounds (x, y, itemWidth, rect.height); } y += ySpacing + rect.height; maxY = Math.max (maxY, y); } return new int [] {cols, x + maxWidth, maxY}; } + int [] layout (int nWidth, int nHeight, boolean resize) { if ((style & SWT.VERTICAL) != 0) { return layoutVertical (nWidth, nHeight, resize); @@ -329,87 +217,51 @@ int [] layout (int nWidth, int nHeight, boolean resize) { return layoutHorizontal (nWidth, nHeight, resize); } } -/* AW -boolean mnemonicHit (char key) { - for (int i = 0; i < items.length; i++) { - ToolItem item = items [i]; - if (item != null) { - char mnemonic = findMnemonic (item.getText ()); - if (mnemonic != '\0') { - if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) { - OS.XmProcessTraversal (item.handle, OS.XmTRAVERSE_CURRENT); - item.click (false, null); - return true; - } - } - } - } - return false; -} -boolean mnemonicMatch (char key) { - for (int i = 0; i < items.length; i++) { - ToolItem item = items [i]; - if (item != null) { - char mnemonic = findMnemonic (item.getText ()); - if (mnemonic != '\0') { - if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) { - return true; - } - } - } - } - return false; -} -*/ -void propagateWidget (boolean enabled) { - super.propagateWidget (enabled); - for (int i=0; i<itemCount; i++) { - items [i].propagateWidget (enabled); - } -} + void relayout () { if (drawCount > 0) return; Rectangle rect = getClientArea (); layout (rect.width, rect.height, true); } + void relayout (int width, int height) { if (drawCount > 0) return; layout (width, height, true); } + void releaseWidget () { for (int i=0; i<itemCount; i++) { ToolItem item = items [i]; - if (!item.isDisposed ()) { - item.releaseWidget (); - item.releaseHandle (); - } + if (!item.isDisposed ()) item.releaseResources (); } items = null; super.releaseWidget (); } -public void setBounds (int x, int y, int width, int height) { - fGotSize= true; - super.setBounds (x, y, width, height); - Rectangle rect = getClientArea (); - relayout (rect.width, rect.height); -} -public void setRedraw (boolean redraw) { - checkWidget(); - if (redraw) { - if (--drawCount == 0) relayout(); - } else { - drawCount++; + +int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) { + int result = super.setBounds (control, x, y, width, height, move, resize, events); + if ((result & RESIZED) != 0) { + Rectangle rect = getClientArea (); + relayout (rect.width, rect.height); } + return result; } -public void setSize (int width, int height) { - fGotSize= true; - super.setSize (width, height); - Rectangle rect = getClientArea (); - relayout (rect.width, rect.height); + +void setFontStyle (Font font) { + super.setFontStyle (font); + for (int i=0; i<itemCount; i++) { + ToolItem item = items [i]; + item.setFontStyle (font); + Point size = item.computeSize (); + item.setSize (size.x, size.y, false); + } + relayout (); } -/* AW -int traversalCode (int key, XKeyEvent xEvent) { - return super.traversalCode (key, xEvent) | SWT.TRAVERSE_MNEMONIC; + +public void setRedraw (boolean redraw) { + checkWidget(); + super.setRedraw (redraw); + if (redraw && drawCount == 0) relayout(); } -*/ + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java index 641b32b261..2af0dff1cd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java @@ -7,78 +7,28 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.ControlButtonContentInfo; +import org.eclipse.swt.internal.carbon.ControlFontStyleRec; +import org.eclipse.swt.internal.carbon.HMHelpContentRec; +import org.eclipse.swt.internal.carbon.Rect; + import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; import org.eclipse.swt.events.*; -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.graphics.*; -/** - * 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> - */ public class ToolItem extends Item { + int handle, iconHandle, labelHandle, arrowHandle; + int cIcon, labelCIcon, arrowCIcon; ToolBar parent; Image hotImage, disabledImage; String toolTipText; Control control; - boolean set; - - // AW - private boolean fPressed; - private short[] fPrevInfo; - private int fBackground; - // AW - + static final int DEFAULT_WIDTH = 24; static final int DEFAULT_HEIGHT = 22; static final int DEFAULT_SEPARATOR_WIDTH = 8; -/** - * 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; @@ -86,41 +36,6 @@ public ToolItem (ToolBar parent, int style) { parent.relayout (); } -/** - * Constructs a new instance of this class given its parent - * (which must be a <code>ToolBar</code>), a style value - * describing its behavior and appearance, and the index - * at which to place it in the items maintained by its parent. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * 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 index to store the receiver in its parent - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - * - * @see SWT#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; @@ -128,31 +43,6 @@ public ToolItem (ToolBar parent, int style, int index) { parent.relayout (); } -/** - * Adds the listener to the collection of listeners who will - * be notified when the control is selected, by sending - * it one of the messages defined in the <code>SelectionListener</code> - * interface. - * <p> - * 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 - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if 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); @@ -160,378 +50,323 @@ public void addSelectionListener(SelectionListener listener) { addListener(SWT.Selection,typedListener); addListener(SWT.DefaultSelection,typedListener); } + static int checkStyle (int style) { return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0); } + protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } -void createHandle (int index) { - state |= HANDLE; - int parentHandle = parent.handle; - /* AW - int [] argList = { - OS.XmNwidth, DEFAULT_WIDTH, - OS.XmNheight, DEFAULT_HEIGHT, - OS.XmNrecomputeSize, 0, - OS.XmNhighlightThickness, (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1, - OS.XmNmarginWidth, 2, - OS.XmNmarginHeight, 1, - OS.XmNtraversalOn, (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1, - OS.XmNpositionIndex, index, - OS.XmNshadowType, OS.XmSHADOW_OUT, - OS.XmNancestorSensitive, 1, - }; - handle = OS.XmCreateDrawnButton (parentHandle, null, argList, argList.length / 2); - */ - int width= DEFAULT_WIDTH; - int height= DEFAULT_HEIGHT; - if ((style & SWT.SEPARATOR) != 0) { - if ((parent.style & SWT.HORIZONTAL) != 0) - width= DEFAULT_SEPARATOR_WIDTH; - else - height= DEFAULT_SEPARATOR_WIDTH; - } - handle = MacUtil.createDrawingArea(parentHandle, index, false, width, height, 0); - if (handle == 0) error (SWT.ERROR_NO_HANDLES); -} -void click (boolean dropDown, MacMouseEvent mmEvent) { - if ((style & SWT.RADIO) != 0) { - selectRadio (); - } else { - if ((style & SWT.CHECK) != 0) setSelection(!set); - } - Event event = new Event (); - if ((style & SWT.DROP_DOWN) != 0) { - if (dropDown) event.detail = SWT.ARROW; - } - if (mmEvent != null) { - // AW setInputState (event, mEvent); - event.stateMask= mmEvent.getState(); - } - postEvent (SWT.Selection, event); -} + Point computeSize () { - if ((style & SWT.SEPARATOR) != 0) { - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - return bounds.getSize(); - } - /* AW - int [] argList = { - OS.XmNmarginHeight, 0, - OS.XmNmarginWidth, 0, - OS.XmNshadowThickness, 0, - }; - OS.XtGetValues (handle, argList, argList.length / 2); - int marginHeight = argList [1], marginWidth = argList [3]; - int shadowThickness = argList [5]; - */ - int marginHeight = 2, marginWidth = 2; - int shadowThickness = 1; - if ((parent.style & SWT.FLAT) != 0) { - Display display = getDisplay (); - shadowThickness = Math.min (2, display.buttonShadowThickness); - } - int textWidth = 0, textHeight = 0; - if (text.length () != 0) { - GC gc = new GC (parent); - int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC; - Point textExtent = gc.textExtent (text, flags); - textWidth = textExtent.x; - textHeight = textExtent.y; - gc.dispose (); - } - int imageWidth = 0, imageHeight = 0; - if (image != null) { - Rectangle rect = image.getBounds (); - imageWidth = rect.width; - imageHeight = rect.height; - } + checkWidget(); int width = 0, height = 0; - if ((parent.style & SWT.RIGHT) != 0) { - width = imageWidth + textWidth; - height = Math.max (imageHeight, textHeight); - if (imageWidth != 0 && textWidth != 0) width += 2; - } else { - height = imageHeight + textHeight; - if (imageHeight != 0 && textHeight != 0) height += 2; - width = Math.max (imageWidth, textWidth); - } - if ((style & SWT.DROP_DOWN) != 0) width += 12; - - if (width != 0) { - width += (marginWidth + shadowThickness) * 2 + 2; - } else { - width = DEFAULT_WIDTH; - } - if (height != 0) { - height += (marginHeight + shadowThickness) * 2 + 2; + if ((style & SWT.SEPARATOR) != 0) { + if ((style & SWT.HORIZONTAL) != 0) { + width = getWidth (); + height = DEFAULT_HEIGHT; + } else { + width = DEFAULT_WIDTH; + height = getWidth (); + } } else { - height = DEFAULT_HEIGHT; + int space = 0; + int stringWidth = 0, stringHeight = 0; + if (text.length () != 0) { + GC gc = new GC (parent); + Point size = gc.stringExtent (text); + stringWidth = size.x; + stringHeight = size.y; + gc.dispose (); + } + int imageWidth = 0, imageHeight = 0; + if (image != null) { + if (text.length () != 0) space = 2; + Rectangle rect = image.getBounds (); + imageWidth = rect.width; + imageHeight = rect.height; + } + if ((parent.style & SWT.RIGHT) != 0) { + width = stringWidth + imageWidth; + height = Math.max (stringHeight, imageHeight); + } else { + width = Math.max (stringWidth, imageWidth); + height = stringHeight + imageHeight; + } + if ((style & SWT.DROP_DOWN) != 0) { + int arrowWidth = 6; //NOT DONE + width += 3 + arrowWidth; + } + int inset = 3; + width += space + inset * 2; + height += space + inset * 2; } return new Point (width, height); } -void createWidget (int index) { - super.createWidget (index); - toolTipText = ""; + +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + int features = OS.kControlSupportsEmbedding | 1 << 4; + OS.CreateUserPaneControl (window, null, features, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + int width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT; + if ((style & SWT.SEPARATOR) == 0) { + ControlButtonContentInfo inContent = new ControlButtonContentInfo (); + if ((style & SWT.DROP_DOWN) != 0) { + OS.CreateIconControl(window, null, inContent, false, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + arrowHandle = outControl [0]; + updateArrow (); + } + OS.CreateIconControl(window, null, inContent, false, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + iconHandle = outControl [0]; + OS.CreateIconControl(window, null, inContent, false, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + labelHandle = outControl [0]; + } else { + if ((parent.style & SWT.HORIZONTAL) != 0) { + width = DEFAULT_SEPARATOR_WIDTH; + } else { + height = DEFAULT_SEPARATOR_WIDTH; + } + } + setBounds (0, 0, width, height); parent.relayout (); } + +void createWidget () { + super.createWidget (); + setZOrder (); + toolTipText = ""; +} + +int defaultThemeFont () { + return OS.kThemeToolbarFont; +} + +void deregister () { + super.deregister (); + WidgetTable.remove (handle); + if (iconHandle != 0) WidgetTable.remove (iconHandle); + if (labelHandle != 0) WidgetTable.remove (labelHandle); + if (arrowHandle != 0) WidgetTable.remove (arrowHandle); +} + +void destroyWidget () { + int theControl = handle; + releaseHandle (); + if (theControl != 0) { + OS.DisposeControl (theControl); + } +} + public void dispose () { if (isDisposed()) return; ToolBar parent = this.parent; - parent.redraw(); // AW workaround for Toolbar update problem super.dispose (); parent.relayout (); } -/** - * Returns a rectangle describing the receiver's size and location - * relative to its parent. - * - * @return the receiver's bounding rectangle - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +void drawWidget (int control) { + drawBackground (control, null); + if ((style & SWT.SEPARATOR) != 0) { + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + rect.top += 2; + rect.bottom -= 2; + OS.DrawThemeSeparator (rect, 0); + } +} + public Rectangle getBounds () { checkWidget(); - if (MacUtil.USE_FRAME) { - float[] f= new float[4]; - OS.HIViewGetFrame(handle, f); - return new Rectangle((int)f[0], (int)f[1], (int)f[2], (int)f[3]); - } else { - short[] bounds= new short[4]; - short[] pbounds= new short[4]; - OS.GetControlBounds(handle, bounds); - OS.GetControlBounds(parent.handle, pbounds); - return new Rectangle(bounds[1]-pbounds[1], bounds[0]-pbounds[0], bounds[3]-bounds[1], bounds[2]-bounds[0]); - } + Rect rect = getControlBounds (handle); + return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } -/** - * Returns the control that is used to fill the bounds of - * the item when the items is a <code>SEPARATOR</code>. - * - * @return the control - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Control getControl () { checkWidget(); 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. - * <p> - * A disabled control is typically not selectable from the - * user interface and draws with an inactive or "grayed" look. - * </p> - * - * @return the receiver's enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public boolean getEnabled () { checkWidget(); return OS.IsControlEnabled(handle); } + public Display getDisplay () { Composite parent = this.parent; if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); return parent.getDisplay (); } -/** - * Returns the receiver's hot image if it has one, or null - * if it does not. - * <p> - * The hot image is displayed when the mouse enters the receiver. - * </p> - * - * @return the receiver's hot image - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + 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)) == 0) return false; - return set; + short [] transform = new short [1]; + OS.GetControlData (iconHandle, (short) OS.kControlEntireControl, OS.kControlIconTransformTag, 2, transform, null); + return (transform [0] & OS.kTransformSelected) != 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(); - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - return bounds.getWidth(); + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + return rect.right - rect.left; } -boolean hasCursor () { - MacPoint mp= new MacPoint(); - OS.GetMouse(mp.getData()); - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - return bounds.toRectangle().contains(mp.toPoint()); + +int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) { + Display display = getDisplay (); + switch (inRequest) { + case OS.kHMSupplyContent: { + int [] contentProvided = new int [] {OS.kHMContentNotProvided}; + if (toolTipText != null && toolTipText.length () != 0) { + char [] buffer = new char [toolTipText.length ()]; + toolTipText.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} + j--; + } + } + if (display.helpString != 0) OS.CFRelease (display.helpString); + display.helpString = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j); + HMHelpContentRec helpContent = new HMHelpContentRec (); + OS.memcpy (helpContent, ioHelpContent, HMHelpContentRec.sizeof); + helpContent.version = OS.kMacHelpVersion; + helpContent.tagSide = OS.kHMDefaultSide; + display.helpControl = null; + helpContent.absHotRect_left = (short) 0; + helpContent.absHotRect_top = (short) 0; + helpContent.absHotRect_right = (short) 0; + helpContent.absHotRect_bottom = (short) 0; + helpContent.content0_contentType = OS.kHMCFStringContent; + helpContent.content0_tagCFString = display.helpString; + helpContent.content1_contentType = OS.kHMCFStringContent; + helpContent.content1_tagCFString = display.helpString; + OS.memcpy (ioHelpContent, helpContent, HMHelpContentRec.sizeof); + contentProvided [0] = OS.kHMContentProvided; + } + OS.memcpy (outContentProvided, contentProvided, 4); + break; + } + case OS.kHMDisposeContent: { + if (display.helpString != 0) OS.CFRelease (display.helpString); + display.helpString = 0; + break; + } + } + return OS.noErr; } void hookEvents () { super.hookEvents (); - /* AW - int windowProc = getDisplay ().windowProc; - OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, SWT.KeyDown); - OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, SWT.KeyUp); - OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, SWT.MouseDown); - OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, SWT.MouseUp); - OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, SWT.MouseMove); - OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, SWT.MouseEnter); - OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, SWT.MouseExit); - OS.XtAddCallback (handle, OS.XmNexposeCallback, windowProc, SWT.Paint); - */ - Display display= getDisplay(); - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneDrawProcTag, display.fUserPaneDrawProc); - if ((style & SWT.SEPARATOR) != 0) return; - OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneHitTestProcTag, display.fUserPaneHitTestProc); + Display display = getDisplay (); + int controlProc = display.controlProc; + int [] mask1 = new int [] { + OS.kEventClassControl, OS.kEventControlDraw, + OS.kEventClassControl, OS.kEventControlHit, + }; + int controlTarget = OS.GetControlEventTarget (handle); + OS.InstallEventHandler (controlTarget, controlProc, mask1.length / 2, mask1, handle, null); + int [] mask2 = new int [] { + OS.kEventClassControl, OS.kEventControlDraw, + }; + if (iconHandle != 0) { + controlTarget = OS.GetControlEventTarget (iconHandle); + OS.InstallEventHandler (controlTarget, controlProc, mask2.length / 2, mask2, iconHandle, null); + } + if (labelHandle != 0) { + controlTarget = OS.GetControlEventTarget (labelHandle); + OS.InstallEventHandler (controlTarget, controlProc, mask2.length / 2, mask2, labelHandle, null); + } + if (arrowHandle != 0) { + controlTarget = OS.GetControlEventTarget (arrowHandle); + OS.InstallEventHandler (controlTarget, controlProc, mask2.length / 2, mask2, arrowHandle, null); + } + int helpProc = display.helpProc; + OS.HMInstallControlContentCallback (handle, helpProc); } -/** - * 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 (); } -/* AW -void manageChildren () { - OS.XtManageChild (handle); + +int kEventControlHit (int nextHandler, int theEvent, int userData) { + int result = super.kEventControlHit (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + Event event = new Event (); + if ((style & SWT.RADIO) != 0) { + if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) { + selectRadio (); + } + } + if ((style & SWT.CHECK) != 0) setSelection (!getSelection ()); + if ((style & SWT.DROP_DOWN) != 0) { + int [] theControl = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeControlRef, null, 4, null, theControl); + if (theControl [0] == arrowHandle) event.detail = SWT.ARROW; + } + postEvent (SWT.Selection, event); + return OS.eventNotHandledErr; } -*/ -void redraw () { - redrawHandle (0, 0, 0, 0, handle, true); + +void register () { + super.register (); + WidgetTable.put (handle, this); + if (iconHandle != 0) WidgetTable.put (iconHandle, this); + if (labelHandle != 0) WidgetTable.put (labelHandle, this); + if (arrowHandle != 0) WidgetTable.put (arrowHandle, this); } + void releaseChild () { super.releaseChild (); parent.destroyItem (this); } + +void releaseHandle () { + super.releaseHandle (); + handle = iconHandle = labelHandle = arrowHandle = 0; +} + void releaseWidget () { - Display display = getDisplay (); - display.releaseToolTipHandle (handle); super.releaseWidget (); + if (cIcon != 0) destroyCIcon (cIcon); + if (labelCIcon != 0) destroyCIcon (labelCIcon); + if (arrowCIcon != 0) destroyCIcon (arrowCIcon); + cIcon = labelCIcon = arrowCIcon = 0; parent = null; control = null; toolTipText = null; image = disabledImage = hotImage = null; } -/** - * Removes the listener from the collection of listeners who will - * be notified when the control is selected. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see SelectionListener - * @see #addSelectionListener - */ + public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -539,67 +374,66 @@ public void removeSelectionListener(SelectionListener listener) { eventTable.unhook(SWT.Selection, listener); eventTable.unhook(SWT.DefaultSelection,listener); } + void selectRadio () { - this.setSelection (true); - ToolItem [] items = parent.getItems (); int index = 0; + ToolItem [] items = parent.getItems (); while (index < items.length && items [index] != this) index++; - ToolItem item; - int i = index; - while (--i >= 0 && ((item = items [i]).style & SWT.RADIO) != 0) { - item.setSelection (false); - } - i = index; - while (++i < items.length && ((item = items [i]).style & SWT.RADIO) != 0) { - item.setSelection (false); - } + 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); } -/* - * This setBounds is only called from ToolBar.relayout() - */ -void setBounds (int x, int y, int width, int height) { - if (control != null) - control.setBounds(x, y, width, height); - - width = Math.max(width, 0); - height = Math.max(height, 0); - - if (MacUtil.USE_FRAME) { - float[] f= new float[4]; - OS.HIViewGetFrame(handle, f); - if (f[0] != x || f[1] != y || f[2] != width || f[3] != height) - OS.HIViewSetFrame(handle, x, y, width, height); +void setBounds (int x, int y, int width, int height) { + if (control != null) control.setBounds (x, y, width, height); + setBounds (handle, x, y, width, height, true, true, false); + if ((style & SWT.SEPARATOR) != 0) return; + int space = 0; + int inset = 3; + int stringWidth = 0, stringHeight = 0; + if (text.length () != 0) { + GC gc = new GC (parent); + Point size = gc.stringExtent (text); + stringWidth = size.x; + stringHeight = size.y; + gc.dispose (); + } + int imageWidth = 0, imageHeight = 0; + if (image != null) { + if (text.length () != 0) space = 2; + Rectangle rect = image.getBounds (); + imageWidth = rect.width; + imageHeight = rect.height; + } + int arrowWidth = 0, arrowHeight = 0; + if ((style & SWT.DROP_DOWN) != 0) { + arrowWidth = 6; + arrowHeight = 4; //NOT DONE + } + if ((parent.style & SWT.RIGHT) != 0) { + int imageX = inset; + int imageY = inset + (height - (inset * 2) - imageHeight) / 2; + setBounds (iconHandle, imageX, imageY, imageWidth, imageHeight, true, true, false); + int labelX = imageX + imageWidth + space; + int labelY = inset + (height - (inset * 2) - stringHeight) / 2; + setBounds (labelHandle, labelX, labelY, stringWidth, stringHeight, true, true, false); } else { - short[] bounds= new short[4]; - short[] pbounds= new short[4]; - OS.GetControlBounds(handle, bounds); - OS.GetControlBounds(parent.handle, pbounds); - - boolean sameOrigin = (bounds[1]-pbounds[1]) == x && (bounds[0]-pbounds[0]) == y; - boolean sameExtent = (bounds[3]-bounds[1]) == width && (bounds[2]-bounds[0]) == height; - if (!sameOrigin || !sameExtent) - OS.SetControlBounds(handle, new MacRect(pbounds[1]+x, pbounds[0]+y, width, height).getData()); + int imageX = inset + (width - (inset * 2) - (arrowWidth + 3) - imageWidth) / 2; + int imageY = inset; + setBounds (iconHandle, imageX, imageY, imageWidth, imageHeight, true, true, false); + int labelX = inset + (width - (inset * 2) - (arrowWidth + 3) - stringWidth) / 2; + int labelY = imageY + imageHeight + space; + setBounds (labelHandle, labelX, labelY, stringWidth, stringHeight, true, true, false); + } + if ((style & SWT.DROP_DOWN) != 0) { + int arrowX = width - inset - arrowWidth; + int arrowY = inset + (height - (inset * 2) - arrowHeight) / 2; + setBounds (arrowHandle, arrowX, arrowY, arrowWidth, arrowHeight, true, true, false); } - - if (parent.fGotSize) - OS.HIViewSetVisible(handle, true); } -/** - * Sets the control that is used to fill the bounds of - * the item when the items is a <code>SEPARATOR</code>. - * - * @param control the new control - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> - * <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) { @@ -612,530 +446,202 @@ public void setControl (Control control) { control.setBounds (getBounds ()); } } -/** - * Enables the receiver if the argument is <code>true</code>, - * and disables it otherwise. - * <p> - * A disabled control is typically - * not selectable from the user interface and draws with an - * inactive or "grayed" look. - * </p> - * - * @param enabled the new enabled state - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setEnabled (boolean enabled) { checkWidget(); - if (enabled) - OS.EnableControl(handle); - else - OS.DisableControl(handle); + if (enabled) { + OS.EnableControl (handle); + } else { + OS.DisableControl (handle); + } } -/** - * Sets the receiver's disabled image to the argument, which may be - * null indicating that no disabled image should be displayed. - * <p> - * The disbled image is displayed when the receiver is disabled. - * </p> - * - * @param image the disabled image to display on the receiver (may be null) - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + +void setFontStyle (Font font) { + /* This code is intentionaly commented. */ +// ControlFontStyleRec fontStyle = new ControlFontStyleRec (); +// if (font != null) { +// fontStyle.flags |= OS.kControlUseFontMask | OS.kControlUseSizeMask | OS.kControlUseFaceMask; +// fontStyle.font = font.id; +// fontStyle.style = font.style; +// fontStyle.size = font.size; +// } else { +// fontStyle.flags |= OS.kControlUseThemeFontIDMask; +// fontStyle.font = (short) defaultThemeFont (); +// } +// OS.SetControlFontStyle (labelHandle, fontStyle); + updateText (); +} + public void setDisabledImage (Image image) { checkWidget(); if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); if ((style & SWT.SEPARATOR) != 0) return; disabledImage = image; - if (!getEnabled ()) redraw (); + updateImage (); } -/** - * 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; hotImage = image; - if ((parent.style & SWT.FLAT) != 0) redraw (); + updateImage (); } + 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); - Point size = computeSize (); - setSize (size.x, size.y); - //redraw (); + updateImage (); +} + +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)) == 0) return; - if (selected == set) return; - set = selected; - setDrawPressed (set); + int transform = selected ? OS.kTransformSelected : 0; + OS.SetControlData (iconHandle, OS.kControlEntireControl, OS.kControlIconTransformTag, 2, new short [] {(short)transform}); + OS.SetControlData (labelHandle, OS.kControlEntireControl, OS.kControlIconTransformTag, 2, new short [] {(short)transform}); + redrawWidget (handle); } -void setSize (int width, int height) { - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - if (bounds.getWidth() != width || bounds.getHeight() != height) { - OS.SizeControl(handle, (short) width, (short) height); - parent.relayout(); +void setSize (int width, int height, boolean layout) { + Rect rect = new Rect(); + OS.GetControlBounds (handle, rect); + if ((rect.right - rect.left) != width || (rect.bottom - rect.top) != height) { + setBounds (handle, 0, 0, width, height, false, true, false); + if (layout) parent.relayout (); } } + public void setText (String string) { checkWidget(); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); if ((style & SWT.SEPARATOR) != 0) return; super.setText (string); - Point size = computeSize (); - setSize (size.x, size.y); + updateText (); } -/** - * Sets the receiver's tool tip text to the argument, which - * may be null indicating that no tool tip text should be shown. - * - * @param string the new tool tip text (or null) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public void setToolTipText (String string) { checkWidget(); toolTipText = string; } -/** - * Sets the width of the receiver. - * - * @param width the new width - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setWidth (int width) { checkWidget(); if ((style & SWT.SEPARATOR) == 0) return; if (width < 0) return; - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - setSize (width, bounds.getHeight()); + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + setSize (width, rect.bottom - rect.top, true); if (control != null && !control.isDisposed ()) { control.setBounds (getBounds ()); } } -void setDrawPressed (boolean value) { - /* AW - int shadowType = value ? OS.XmSHADOW_IN : OS.XmSHADOW_OUT; - int [] argList = {OS.XmNshadowType, shadowType}; - OS.XtSetValues(handle, argList, argList.length / 2); - */ - if (fPressed != value) { - fPressed= value; - redraw(); - } -} -int processKeyDown (Object callData) { - /* AW - XKeyEvent xEvent = new XKeyEvent (); - OS.memmove (xEvent, callData, XKeyEvent.sizeof); - */ - /* - * Forward the key event to the parent. - * This is necessary so that mouse listeners - * in the parent will be called, despite the - * fact that the event did not really occur - * in X in the parent. This is done to be - * compatible with Windows. - */ - /* AW - xEvent.window = OS.XtWindow (parent.handle); -// OS.memmove (callData, xEvent, XKeyEvent.sizeof); - */ - parent.processKeyDown (callData); - return 0; -} -int processKeyUp (Object callData) { - /* AW - XKeyEvent xEvent = new XKeyEvent (); - OS.memmove (xEvent, callData, XKeyEvent.sizeof); - int [] keysym = new int [1]; - OS.XLookupString (xEvent, null, 0, keysym, null); - keysym [0] &= 0xFFFF; - switch (keysym [0]) { - case OS.XK_space: - case OS.XK_Return: - click (keysym [0] == OS.XK_Return, xEvent); - break; - } - */ - /* - * Forward the key event to the parent. - * This is necessary so that mouse listeners - * in the parent will be called, despite the - * fact that the event did not really occur - * in X in the parent. This is done to be - * compatible with Windows. - */ - /* AW - xEvent.window = OS.XtWindow (parent.handle); -// OS.memmove (callData, xEvent, XKeyEvent.sizeof); - */ - parent.processKeyUp (callData); - return 0; -} -int processMouseDown (MacMouseEvent mmEvent) { - Display display = getDisplay (); -// Shell shell = parent.getShell (); - display.hideToolTip (); - - /* AW - XButtonEvent xEvent = new XButtonEvent (); - OS.memmove (xEvent, callData, XButtonEvent.sizeof); - */ - if (mmEvent.getButton() == 1) { - if (!set && (style & SWT.RADIO) == 0) { - setDrawPressed (!set); - } - } - - /* - * Forward the mouse event to the parent. - * This is necessary so that mouse listeners - * in the parent will be called, despite the - * fact that the event did not really occur - * in X in the parent. This is done to be - * compatible with Windows. - */ - /* AW - int [] argList = {OS.XmNx, 0, OS.XmNy, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - xEvent.window = OS.XtWindow (parent.handle); - xEvent.x += argList [1]; xEvent.y += argList [3]; - OS.memmove (callData, xEvent, XButtonEvent.sizeof); - */ - parent.processMouseDown (mmEvent); - /* - * 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 (parent); -// } - return 0; -} -int processMouseEnter (MacMouseEvent mme) { - if (mme.getButton() == 1) setDrawPressed (!set); - else if ((parent.style & SWT.FLAT) != 0) redraw (); - return 0; -} -int processMouseExit (MacMouseEvent mme) { - Display display = getDisplay (); - display.removeMouseHoverTimeOut (); - display.hideToolTip (); - if (mme.getButton() == 1) setDrawPressed (set); - else if ((parent.style & SWT.FLAT) != 0) redraw (); - return 0; -} -Point toControl (Point point) { - return MacUtil.toControl(handle, point); -} -/* AW -boolean translateTraversal (int key, XKeyEvent xEvent) { - return parent.translateTraversal (key, xEvent); -} -*/ -int processMouseHover (MacMouseEvent mme) { - Display display = getDisplay (); - display.showToolTip (handle, toolTipText); - return 0; -} -int processMouseMove (MacMouseEvent mmEvent) { - Display display = getDisplay (); - display.addMouseHoverTimeOut (handle); - - /* - * Forward the mouse event to the parent. - * This is necessary so that mouse listeners - * in the parent will be called, despite the - * fact that the event did not really occur - * in X in the parent. This is done to be - * compatible with Windows. - */ - /* AW - XButtonEvent xEvent = new XButtonEvent (); - OS.memmove (xEvent, callData, XButtonEvent.sizeof); - int [] argList = {OS.XmNx, 0, OS.XmNy, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - xEvent.window = OS.XtWindow (parent.handle); - xEvent.x += argList [1]; xEvent.y += argList [3]; - */ - /* - * This code is intentionally commented. - * Currently, the implementation of the - * mouse move code in the parent interferes - * with tool tips for tool items. - */ -// OS.memmove (callData, xEvent, XButtonEvent.sizeof); -// parent.processMouseMove (callData); - parent.sendMouseEvent (SWT.MouseMove, 0, mmEvent); - - return 0; +void setZOrder () { + OS.HIViewAddSubview (parent.handle, handle); + if (iconHandle != 0) OS.HIViewAddSubview (handle, iconHandle); + if (labelHandle != 0) OS.HIViewAddSubview (handle, labelHandle); + if (arrowHandle != 0) OS.HIViewAddSubview (handle, arrowHandle); } -int processMouseUp (MacMouseEvent mmEvent) { - Display display = getDisplay (); - display.hideToolTip(); - - if (mmEvent.getButton() == 1) { - /* AW - int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - int width = argList [1], height = argList [3]; - */ - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - int width = bounds.getWidth(), height = bounds.getHeight(); - - Point mp= MacUtil.toControl(handle, mmEvent.getWhere()); - //System.out.println("ToolItem.processMouseUp: " + mp); - if (0 <= mp.x && mp.x < width && 0 <= mp.y && mp.y < height) { - click (mp.x > width - 12, mmEvent); +void updateImage () { + if (cIcon != 0) destroyCIcon (cIcon); + cIcon = 0; + Image image = null; + if (hotImage != null) { + image = hotImage; + } else { + if (this.image != null) { + image = this.image; + } else { + image = disabledImage; } - setDrawPressed(set); } - /* - * Forward the mouse event to the parent. - * This is necessary so that mouse listeners - * in the parent will be called, despite the - * fact that the event did not really occur - * in X in the parent. This is done to be - * compatible with Windows. - */ - /* AW - int [] argList = {OS.XmNx, 0, OS.XmNy, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - xEvent.window = OS.XtWindow (parent.handle); - xEvent.x += argList [1]; xEvent.y += argList [3]; - OS.memmove (callData, xEvent, XButtonEvent.sizeof); - */ - parent.processMouseUp (mmEvent); - - return 0; + ControlButtonContentInfo inContent = new ControlButtonContentInfo (); + if (image != null) { + cIcon = createCIcon (image); + inContent.contentType = (short) OS.kControlContentCIconHandle; + inContent.iconRef = cIcon; + } + OS.SetBevelButtonContentInfo (iconHandle, inContent); + redrawWidget (iconHandle); + Point size = computeSize (); + setSize (size.x, size.y, true); } -int processPaint (Object callData) { - - if ((style & SWT.SEPARATOR) != 0 && control != null) - return 0; - - MacRect bounds= new MacRect(); - OS.GetControlBounds(handle, bounds.getData()); - bounds.setLocation(0, 0); - - int width= bounds.getWidth(); - int height= bounds.getHeight(); - - final Display display = getDisplay (); - Drawable drawable= new Drawable() { - public int internal_new_GC (GCData data) { - data.device = display; - data.foreground = parent.getForegroundPixel(); - data.background = parent.getBackgroundPixel(); - data.font = parent.font.handle; - data.controlHandle = handle; - return OS.GetWindowPort(OS.GetControlOwner(handle)); - } - public void internal_dispose_GC (int xGC, GCData data) { - } - }; - - boolean hasCursor= hasCursor (); - - GC gc= new GC(drawable); - - MacControlEvent me= (MacControlEvent) callData; - Rectangle r= gc.carbon_focus(me.getDamageRegionHandle()); - if (!r.isEmpty()) { - - // erase background - gc.fillRectangle(0, 0, width, height); - - if ((style & SWT.SEPARATOR) != 0) { - - OS.DrawThemeSeparator(bounds.getData(), OS.kThemeStateActive); - - } else { - - if ((parent.style & SWT.FLAT) != 0 && set) { - gc.setBackground(Color.carbon_new(display, 0xE0E0E0, false)); - gc.fillRoundRectangle(1, 1, width-2, height-2, 8, 8); - gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY)); - gc.drawRoundRectangle(1, 1, width-3, height-3, 8, 8); - } - - Image currentImage = image; - boolean enabled = getEnabled(); - - short[] newInfo= new short[3]; - - newInfo[1]= set ? OS.kThemeButtonOn : OS.kThemeButtonOff; - - if ((parent.style & SWT.FLAT) != 0) { - - if (hasCursor && enabled) { - if (OS.StillDown()) - newInfo[0]= OS.kThemeStatePressed; - else - newInfo[0]= OS.kThemeStateActive; - } else - newInfo= null; - - /* Determine if hot image should be used */ - if (enabled && hasCursor && hotImage != null) { - currentImage = hotImage; - } - } else { - newInfo[0]= (hasCursor && OS.StillDown()) ? OS.kThemeStatePressed : OS.kThemeStateActive; - } - - if (newInfo != null) { - MacRect b= new MacRect(1, 1, width-2, height-2); - OS.DrawThemeButton(b.getData(), OS.kThemeSmallBevelButton, newInfo, fPrevInfo, 0, 0, 0); - } - fPrevInfo= newInfo; - - if (enabled) { - gc.setForeground (parent.getForeground()); - } else { - currentImage = disabledImage; - if (currentImage == null && image != null) { - currentImage = new Image (display, image, SWT.IMAGE_DISABLE); - } - Color disabledColor = display.getSystemColor (SWT.COLOR_WIDGET_NORMAL_SHADOW); - gc.setForeground (disabledColor); - } - - int textX = 0, textY = 0, textWidth = 0, textHeight = 0; - if (text.length() > 0) { - int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC; - Point textExtent = gc.textExtent (text, flags); - textWidth = textExtent.x; - textHeight = textExtent.y; - } - int imageX = 0, imageY = 0, imageWidth = 0, imageHeight = 0; - if (currentImage != null) { - try { // AW FIXME - Rectangle imageBounds = currentImage.getBounds (); - imageWidth = imageBounds.width; - imageHeight = imageBounds.height; - } catch (SWTError e) { - System.out.println("ToolItem.processPaint: error in image.getBounds: " + e); - } - } - - int spacing = 0; - if (textWidth != 0 && imageWidth != 0) spacing = 2; - if ((parent.style & SWT.RIGHT) != 0) { - imageX = (width - imageWidth - textWidth - spacing) / 2; - imageY = (height - imageHeight) / 2; - textX = spacing + imageX + imageWidth; - textY = (height - textHeight) / 2; - } else { - imageX = (width - imageWidth) / 2; - imageY = (height - imageHeight - textHeight - spacing) / 2; - textX = (width - textWidth) / 2; - textY = spacing + imageY + imageHeight; - } - - if ((style & SWT.DROP_DOWN) != 0) { - textX -= 6; imageX -=6; - } - if (textWidth > 0) { - int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC | SWT.DRAW_TRANSPARENT; - gc.drawText(text, textX, textY, flags); - } - if (imageWidth > 0) - gc.drawImage(currentImage, imageX, imageY); - - if ((style & SWT.DROP_DOWN) != 0) { - int startX = width - 12, startY = (height - 2) / 2; - int [] arrow = {startX, startY, startX + 3, startY + 3, startX + 6, startY}; - gc.setBackground (gc.getForeground ()); - gc.fillPolygon (arrow); - gc.drawPolygon (arrow); - } - if (!enabled && disabledImage == null) { - if (currentImage != null) currentImage.dispose (); - } - } - } - gc.carbon_unfocus(); +void updateArrow () { + if (arrowCIcon != 0) destroyCIcon (arrowCIcon); + arrowCIcon = 0; + Display display = getDisplay (); + Image image = new Image (display, 6, 4); + GC gc = new GC (image); + int startX = 0, startY = 0; + int [] arrow = {startX, startY, startX + 3, startY + 3, startX + 6, startY}; + gc.setBackground (parent.getForeground ()); + gc.fillPolygon (arrow); + gc.drawPolygon (arrow); gc.dispose (); - - return 0; + ImageData data = image.getImageData (); + data.transparentPixel = 0xFFFFFFFF; + image.dispose (); + image = new Image (getDisplay (), data, data.getTransparencyMask()); + arrowCIcon = createCIcon (image); + image.dispose (); + ControlButtonContentInfo inContent = new ControlButtonContentInfo (); + inContent.contentType = (short) OS.kControlContentCIconHandle; + inContent.iconRef = arrowCIcon; + OS.SetBevelButtonContentInfo (arrowHandle, inContent); } -void propagateWidget (boolean enabled) { - propagateHandle (enabled, handle); - /* - * Tool items participate in focus traversal only when - * the tool bar takes focus. - */ - /* AW - if ((parent.style & SWT.NO_FOCUS) != 0) { - if (enabled) { - int [] argList = {OS.XmNtraversalOn, 0}; - OS.XtSetValues (handle, argList, argList.length / 2); + +void updateText () { + if (labelCIcon != 0) destroyCIcon (labelCIcon); + labelCIcon = 0; + ControlButtonContentInfo inContent = new ControlButtonContentInfo (); + if (text.length () > 0) { + char [] buffer = new char [text.length ()]; + text.getChars (0, buffer.length, buffer, 0); + int i=0, j=0; + while (i < buffer.length) { + if ((buffer [j++] = buffer [i++]) == Mnemonic) { + if (i == buffer.length) {continue;} + if (buffer [i] == Mnemonic) {i++; continue;} + j--; + } } + Font font = parent.getFont (); + GC gc = new GC (parent); + Point size = gc.stringExtent (text); + gc.dispose (); + Display display = getDisplay (); + Image image = new Image (display, size.x, size.y); + gc = new GC (image); + gc.setFont (font); + gc.drawString (text, 0, 0); + gc.dispose (); + ImageData data = image.getImageData (); + data.transparentPixel = 0xFFFFFFFF; + image.dispose (); + image = new Image (display, data, data.getTransparencyMask()); + labelCIcon = createCIcon (image); + image.dispose (); + inContent.contentType = (short) OS.kControlContentCIconHandle; + inContent.iconRef = labelCIcon; } - */ + OS.SetBevelButtonContentInfo (labelHandle, inContent); + redrawWidget (labelHandle); + Point size = computeSize (); + setSize (size.x, size.y, true); } + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java index a4eeb8c421..cf505015c1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java @@ -11,108 +11,19 @@ import org.eclipse.swt.graphics.*; import org.eclipse.swt.*; import org.eclipse.swt.events.*; -/** - * Instances of this class implement rubber banding rectangles that are - * drawn onto a parent <code>Composite</code> or <code>Display</code>. - * These rectangles can be specified to respond to mouse and key events - * by either moving or resizing themselves accordingly. Trackers are - * typically used to represent window geometries in a lightweight manner. - * - * <dl> - * <dt><b>Styles:</b></dt> - * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd> - * <dt><b>Events:</b></dt> - * <dd>Move, Resize</dd> - * </dl> - * <p> - * Note: Rectangle move behavior is assumed unless RESIZE is specified. - * </p><p> - * IMPORTANT: This class is <em>not</em> intended to be subclassed. - * </p> - */ public class Tracker extends Widget { - Composite parent; - Display display; - boolean tracking, stippled; - Rectangle [] rectangles, proportions; - int cursorOrientation = SWT.NONE; - int cursor; - final static int STEPSIZE_SMALL = 1; - final static int STEPSIZE_LARGE = 9; + Control parent; + Display display; + boolean tracking, stippled; + Rectangle [] rectangles, proportions; + int cursorOrientation = SWT.NONE; -/** - * 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; display = parent.getDisplay (); } -/** - * Constructs a new instance of this class given the display - * to create it on and a style value describing its behavior - * and appearance. - * <p> - * The style value is either one of the style constants defined in - * class <code>SWT</code> which is applicable to instances of this - * class, or must be built by <em>bitwise OR</em>'ing together - * (that is, using the <code>int</code> "|" operator) two or more - * of those <code>SWT</code> style constants. The class description - * 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 (); @@ -123,25 +34,6 @@ public Tracker (Display display, int style) { this.display = display; } -/** - * Adds the listener to the collection of listeners who will - * be notified when the control is moved or resized, by sending - * it one of the messages defined in the <code>ControlListener</code> - * interface. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ControlListener - * @see #removeControlListener - */ public void addControlListener (ControlListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -150,80 +42,20 @@ public void addControlListener (ControlListener listener) { } Point adjustMoveCursor (int xDisplay, int xWindow) { - int actualX[] = new int[1]; - int actualY[] = new int[1]; - - /* AW - Rectangle bounds = computeBounds (); - int newX = bounds.x + bounds.width / 2; - int newY = bounds.y; - */ - - /* AW - OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, newX, newY); - */ - /* - * The call to XWarpPointer does not always place the pointer on the - * exact location that is specified, so do a query (below) to get the - * actual location of the pointer after it has been moved. - */ - /* AW - OS.XQueryPointer (xDisplay, xWindow, unused, unused, actualX, actualY, unused, unused, unused); - */ - return new Point (actualX[0], actualY[0]); + return new Point (0, 0); } -Point adjustResizeCursor (int xDisplay, int xWindow) { - /* AW - int newX, newY; - Rectangle bounds = computeBounds (); - if ((cursorOrientation & SWT.LEFT) != 0) { - newX = bounds.x; - } else if ((cursorOrientation & SWT.RIGHT) != 0) { - newX = bounds.x + bounds.width; - } else { - newX = bounds.x + bounds.width / 2; - } - - if ((cursorOrientation & SWT.UP) != 0) { - newY = bounds.y; - } else if ((cursorOrientation & SWT.DOWN) != 0) { - newY = bounds.y + bounds.height; - } else { - newY = bounds.y + bounds.height / 2; - } - */ - - int actualX[] = new int[1]; - int actualY[] = new int[1]; - /* AW - OS.XWarpPointer (xDisplay, SWT.NONE, xWindow, 0, 0, 0, 0, newX, newY); - */ - /* - * The call to XWarpPointer does not always place the pointer on the - * exact location that is specified, so do a query (below) to get the - * actual location of the pointer after it has been moved. - */ - /* AW - OS.XQueryPointer (xDisplay, xWindow, unused, unused, actualX, actualY, unused, unused, unused); - */ - return new Point (actualX[0], actualY[0]); +Point adjustResizeCursor (int xDisplay, int xWindow) { + return new Point (0, 0); } + 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; @@ -266,68 +98,17 @@ void drawRectangles () { } else { display.update (); } - /* AW - int xDisplay = display.xDisplay; - int color = OS.XWhitePixel (xDisplay, 0); - int xWindow = OS.XDefaultRootWindow (xDisplay); - if (parent != null) { - xWindow = OS.XtWindow (parent.handle); - if (xWindow == 0) return; - int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0}; - OS.XtGetValues (parent.handle, argList, argList.length / 2); - color = argList [1] ^ argList [3]; - } - int gc = OS.XCreateGC (xDisplay, xWindow, 0, null); - OS.XSetForeground (xDisplay, gc, color); - OS.XSetSubwindowMode (xDisplay, gc, OS.IncludeInferiors); - OS.XSetFunction (xDisplay, gc, OS.GXxor); - int stipplePixmap = 0; - if (stippled) { - byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0}; - stipplePixmap = OS.XCreateBitmapFromData (xDisplay, xWindow, bits, 8, 8); - OS.XSetStipple (xDisplay, gc, stipplePixmap); - OS.XSetFillStyle (xDisplay, gc, OS.FillStippled); - OS.XSetLineAttributes (xDisplay, gc, 3, OS.LineSolid, OS.CapButt, OS.JoinMiter); - } - for (int i=0; i<rectangles.length; i++) { - Rectangle rect = rectangles [i]; - OS.XDrawRectangle (xDisplay, xWindow, gc, rect.x, rect.y, rect.width, rect.height); - } - if (stippled) { - OS.XFreePixmap (xDisplay, stipplePixmap); - } - OS.XFreeGC (xDisplay, gc); - */ } + public Display getDisplay () { return display; } -/** - * Returns the bounds that are being drawn, expressed relative to the parent - * widget. If the parent is a <code>Display</code> then these are screen - * coordinates. - * - * @return the bounds of the Rectangles being drawn - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public Rectangle [] getRectangles () { checkWidget (); return rectangles; } -/** - * 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; @@ -344,237 +125,19 @@ void moveRectangles (int xChange, int yChange) { } } -/** - * Displays the Tracker rectangles for manipulation by the user. Returns when - * the user has either finished manipulating the rectangles or has cancelled the - * Tracker. - * - * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public boolean open () { checkWidget (); if (rectangles == null) return false; - /* AW - int xDisplay = display.xDisplay; - int color = OS.XWhitePixel (xDisplay, 0); - int xWindow = OS.XDefaultRootWindow (xDisplay); - if (parent != null) { - xWindow = OS.XtWindow (parent.handle); - if (xWindow == 0) return false; - } - boolean cancelled = false; - tracking = true; - drawRectangles (); - int [] oldX = new int [1], oldY = new int [1]; - int [] unused = new int [1]; - Point cursorPos; - if ((style & SWT.MENU) != 0) { - if ((style & SWT.RESIZE) != 0) { - cursorPos = adjustResizeCursor (xDisplay, xWindow); - } else { - cursorPos = adjustMoveCursor (xDisplay, xWindow); - } - oldX [0] = cursorPos.x; oldY [0] = cursorPos.y; - } else { - OS.XQueryPointer (xDisplay, xWindow, unused, unused, oldX, oldY, unused, unused, unused); - } - - XAnyEvent xEvent = new XAnyEvent (); - int [] newX = new int [1], newY = new int [1]; - int xtContext = OS.XtDisplayToApplicationContext (xDisplay); - - int ptrGrabResult = OS.XGrabPointer ( - xDisplay, - xWindow, - 0, - OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask, - OS.GrabModeAsync, - OS.GrabModeAsync, - OS.None, - OS.None, - OS.CurrentTime); - int kbdGrabResult = OS.XGrabKeyboard ( - xDisplay, - xWindow, - 0, - OS.GrabModeAsync, - OS.GrabModeAsync, - OS.CurrentTime); - */ - /* - * Tracker behaves like a Dialog with its own OS event loop. - */ - /* AW - while (tracking) { - if (parent != null && parent.isDisposed ()) break; - OS.XtAppNextEvent (xtContext, xEvent); - switch (xEvent.type) { - case OS.MotionNotify: - if (cursor != 0) { - OS.XChangeActivePointerGrab ( - xDisplay, - OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask, - cursor, - OS.CurrentTime); - } - // fall through - case OS.ButtonRelease: - OS.XQueryPointer (xDisplay, xWindow, unused, unused, newX, newY, unused, unused, unused); - if (oldX [0] != newX [0] || oldY [0] != newY [0]) { - drawRectangles (); - Event event = new Event (); - event.x = newX [0]; - event.y = newY [0]; - if ((style & SWT.RESIZE) != 0) { - resizeRectangles (newX [0] - oldX [0], newY [0] - oldY [0]); - sendEvent (SWT.Resize, event); - cursorPos = adjustResizeCursor (xDisplay, xWindow); - newX [0] = cursorPos.x; newY [0] = cursorPos.y; - } else { - moveRectangles (newX [0] - oldX [0], newY [0] - oldY [0]); - sendEvent (SWT.Move, event); - } - */ - /* - * It is possible (but unlikely) that application code - * could have disposed the widget in the move event. - * If this happens then return false to indicate that - * the move failed. - */ - /* AW - if (isDisposed ()) { - if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime); - if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime); - return false; - } - drawRectangles (); - oldX [0] = newX [0]; oldY [0] = newY [0]; - } - tracking = xEvent.type != OS.ButtonRelease; - break; - case OS.KeyPress: - XKeyEvent keyEvent = new XKeyEvent (); - OS.memmove (keyEvent, xEvent, XKeyEvent.sizeof); - if (keyEvent.keycode != 0) { - int [] keysym = new int [1]; - OS.XLookupString (keyEvent, null, 0, keysym, null); - keysym [0] &= 0xFFFF; - int xChange = 0, yChange = 0; - int stepSize = ((keyEvent.state & OS.ControlMask) != 0) ? STEPSIZE_SMALL : STEPSIZE_LARGE; - switch (keysym [0]) { - case OS.XK_Return: - tracking = false; - */ - /* - * Eat the subsequent KeyRelease event - */ - /* AW - OS.XtAppNextEvent (xtContext, xEvent); - break; - case OS.XK_Escape: - case OS.XK_Cancel: - tracking = false; - cancelled = true; - */ - /* - * Eat the subsequent KeyRelease event - */ - /* AW - OS.XtAppNextEvent (xtContext, xEvent); - break; - case OS.XK_Left: - xChange = -stepSize; - break; - case OS.XK_Right: - xChange = stepSize; - break; - case OS.XK_Up: - yChange = -stepSize; - break; - case OS.XK_Down: - yChange = stepSize; - break; - } - if (xChange != 0 || yChange != 0) { - drawRectangles (); - Event event = new Event (); - event.x = oldX[0] + xChange; - event.y = oldY[0] + yChange; - if ((style & SWT.RESIZE) != 0) { - resizeRectangles (xChange, yChange); - sendEvent (SWT.Resize, event); - cursorPos = adjustResizeCursor (xDisplay, xWindow); - } else { - moveRectangles (xChange, yChange); - sendEvent (SWT.Move, event); - cursorPos = adjustMoveCursor (xDisplay, xWindow); - } - */ - /* - * It is possible (but unlikely) that application code - * could have disposed the widget in the move event. - * If this happens then return false to indicate that - * the move failed. - */ - /* AW - if (isDisposed ()) { - if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime); - if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime); - return false; - } - drawRectangles (); - oldX[0] = cursorPos.x; oldY[0] = cursorPos.y; - } - } - break; - case OS.EnterNotify: - case OS.LeaveNotify: - */ - /* - * Do not dispatch these - */ - /* AW - break; - default: - OS.XtDispatchEvent (xEvent); - } - } - drawRectangles (); - tracking = false; - if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime); - if (kbdGrabResult == OS.GrabSuccess) OS.XUngrabKeyboard (xDisplay, OS.CurrentTime); - return !cancelled; - */ return false; } -/** - * Removes the listener from the collection of listeners who will - * be notified when the control is moved or resized. - * - * @param listener the listener which should be notified - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see ControlListener - * @see #addControlListener - */ + public void removeControlListener (ControlListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.Move, listener); } + void resizeRectangles (int xChange, int yChange) { /* * If the cursor orientation has not been set in the orientation of @@ -619,48 +182,16 @@ void resizeRectangles (int xChange, int yChange) { 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 value) { checkWidget (); - cursor = 0; - if (value != null) cursor = value.handle; } -/** - * 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 SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + public void setRectangles (Rectangle [] rectangles) { checkWidget (); this.rectangles = rectangles; 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; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java new file mode 100644 index 0000000000..bda8ef95aa --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java @@ -0,0 +1,731 @@ +package org.eclipse.swt.widgets; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.DataBrowserCallbacks; +import org.eclipse.swt.internal.carbon.DataBrowserCustomCallbacks; +import org.eclipse.swt.internal.carbon.DataBrowserListViewColumnDesc; +import org.eclipse.swt.internal.carbon.RGBColor; +import org.eclipse.swt.internal.carbon.Rect; + +import org.eclipse.swt.*; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; + +public class Tree extends Composite { + TreeItem [] items; + GC paintGC; + int anchorFirst, anchorLast; + boolean ignoreSelect, ignoreExpand; + static final int CHECK_COLUMN_ID = 1024; + static final int COLUMN_ID = 1025; + +public Tree (Composite parent, int style) { + super (parent, checkStyle (style)); +} + +public void addSelectionListener(SelectionListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Selection, typedListener); + addListener (SWT.DefaultSelection, typedListener); +} + +public void addTreeListener(TreeListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener (listener); + addListener (SWT.Expand, typedListener); + addListener (SWT.Collapse, typedListener); +} + +static int checkStyle (int style) { + /* + * Feature in Windows. It is not possible to create + * a tree that scrolls and does not have scroll bars. + * The TVS_NOSCROLL style will remove the scroll bars + * but the tree will never scroll. Therefore, no matter + * what style bits are specified, set the H_SCROLL and + * V_SCROLL bits so that the SWT style will match the + * widget that Windows creates. + */ + style |= SWT.H_SCROLL | SWT.V_SCROLL; + return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0); +} + +public Point computeSize (int wHint, int hHint, boolean changed) { + checkWidget (); + int width = 0; + if (wHint == SWT.DEFAULT) { + TreeItem [] items = getItems (); + GC gc = new GC (this); + for (int i=0; i<items.length; i++) { + Rectangle rect = items [i].getBounds (); + width = Math.max (width, rect.width); + } + gc.dispose (); + width = width * 2; + } else { + width = wHint; + } + if (width <= 0) width = DEFAULT_WIDTH; + int height = 0; + if (hHint == SWT.DEFAULT) { + height = getItemCount () * getItemHeight (); + } else { + height = hHint; + } + if (height <= 0) height = DEFAULT_HEIGHT; + Rectangle rect = computeTrim (0, 0, width, height); + return new Point (rect.width, rect.height); +} + +public Rectangle computeTrim (int x, int y, int width, int height) { + checkWidget(); + Rect rect = new Rect (); + OS.GetDataBrowserScrollBarInset (handle, rect); + x -= rect.left; + y -= rect.top; + width += (rect.left + rect.right) * 3; + height += rect.top + rect.bottom; + return new Rectangle (x, y, width, height); +} + +void createHandle () { + int [] outControl = new int [1]; + int window = OS.GetControlOwner (parent.handle); + OS.CreateDataBrowserControl (window, null, OS.kDataBrowserListView, outControl); + if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES); + handle = outControl [0]; + int selectionFlags = (style & SWT.SINGLE) != 0 ? OS.kDataBrowserSelectOnlyOne : OS.kDataBrowserCmdTogglesSelection; + OS.SetDataBrowserSelectionFlags (handle, selectionFlags); + OS.SetDataBrowserListViewHeaderBtnHeight (handle, (short) 0); + OS.SetDataBrowserHasScrollBars (handle, (style & SWT.H_SCROLL) != 0, (style & SWT.V_SCROLL) != 0); + //NOT DONE + if ((style & SWT.H_SCROLL) == 0) OS.AutoSizeDataBrowserListViewColumns (handle); + int position = 0; + if ((style & SWT.CHECK) != 0) { + DataBrowserListViewColumnDesc checkColumn = new DataBrowserListViewColumnDesc (); + checkColumn.headerBtnDesc_version = OS.kDataBrowserListViewLatestHeaderDesc; + checkColumn.propertyDesc_propertyID = CHECK_COLUMN_ID; + checkColumn.propertyDesc_propertyType = OS.kDataBrowserCheckboxType; + checkColumn.propertyDesc_propertyFlags = OS.kDataBrowserPropertyIsMutable; + //NOT DONE + checkColumn.headerBtnDesc_minimumWidth = 40; + checkColumn.headerBtnDesc_maximumWidth = 40; + checkColumn.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing; + OS.AddDataBrowserListViewColumn (handle, checkColumn, position++); + } + DataBrowserListViewColumnDesc column = new DataBrowserListViewColumnDesc (); + column.headerBtnDesc_version = OS.kDataBrowserListViewLatestHeaderDesc; + column.propertyDesc_propertyID = COLUMN_ID; +// column.propertyDesc_propertyType = OS.kDataBrowserTextType; // OS.kDataBrowserIconAndTextType + column.propertyDesc_propertyType = OS.kDataBrowserCustomType; + column.propertyDesc_propertyFlags = OS.kDataBrowserListViewSelectionColumn | OS.kDataBrowserDefaultPropertyFlags; + //NOT DONE + column.headerBtnDesc_maximumWidth = 0x7FFF; + column.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing; + OS.AddDataBrowserListViewColumn (handle, column, position); + OS.SetDataBrowserListViewDisclosureColumn (handle, COLUMN_ID, true); + OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short)800); + + /* + * Feature in the Macintosh. Scroll bars are not created until + * the widget has a minimum size. The fix is to force the scroll + * bars to be created by temporarily giving the widget a size and + * then restoring it to zero. + * + * NOTE: The widget must be visible and SizeControl() must be used + * to resize the widget to a minimim size or the widget will not + * create the scroll bars. This work around currently flashes. + */ + OS.SizeControl (handle, (short) 0xFF, (short) 0xFF); + OS.SizeControl (handle, (short) 0, (short) 0); +} + +void createItem (TreeItem item, TreeItem parentItem, int index) { + int count = 0; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == parentItem) count++; + } + if (index == -1) index = count; + item.index = index; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == parentItem) { + if (items [i].index >= item.index) items [i].index++; + } + } + int id = 0; + while (id < items.length && items [id] != null) id++; + if (id == items.length) { + TreeItem [] newItems = new TreeItem [items.length + 4]; + System.arraycopy (items, 0, newItems, 0, items.length); + items = newItems; + } + items [id] = item; + item.id = id + 1; + int parentID = OS.kDataBrowserNoItem; + boolean expanded = true; + if (parentItem != null) { + parentID = parentItem.id; + expanded = parentItem.getExpanded (); + } + if (expanded) { + if (OS.AddDataBrowserItems (handle, parentID, 1, new int[] {item.id}, 0) != OS.noErr) { + items [id] = null; + error (SWT.ERROR_ITEM_NOT_ADDED); + } + } +} + +ScrollBar createScrollBar (int style) { + return createStandardBar (style); +} + +void createWidget () { + super.createWidget (); + items = new TreeItem [4]; +} + +int defaultThemeFont () { + return OS.kThemeViewsFont; +} + +public void deselectAll () { + checkWidget (); + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsRemove); + ignoreSelect = false; +} + +void destroyItem (TreeItem item) { + int parentID = item.parentItem == null ? OS.kDataBrowserNoItem : item.parentItem.id; + if (OS.RemoveDataBrowserItems (handle, parentID, 1, new int[] {item.id}, 0) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_REMOVED); + } + for (int i=0; i<items.length; i++) { + if (items [i] != null) { + TreeItem parentItem = items [i].parentItem; + while (parentItem != null && parentItem != item) { + parentItem = parentItem.parentItem; + } + if (parentItem == item) { + TreeItem oldItem = items [i]; + items [i].id = 0; + items [i].index = -1; + items [i] = null; + oldItem.releaseResources (); + } + } + } + TreeItem parentItem = item.parentItem; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == parentItem) { + if (items [i].index >= item.index) --items [i].index; + } + } + items [item.id - 1] = null; + item.id = 0; + item.index = -1; +} + +int drawItemProc (int browser, int id, int property, int itemState, int theRect, int gdDepth, int colorDevice) { + int index = id - 1; + if (!(0 <= index && index < items.length)) return OS.noErr; + TreeItem item = items [index]; + +// if (false) { +// int [] port = new int [1], gdh = new int [1]; +// OS.GetGWorld (port, gdh); +// byte [] buffer = item.text.getBytes(); +// Rect rect = new Rect (); +// OS.memcpy (rect, theRect, Rect.sizeof); +// Display display = getDisplay (); +// Color foreground = null, background = null; +// if ((itemState & OS.kDataBrowserItemIsSelected) != 0) { +// foreground = display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT); +// background = display.getSystemColor (SWT.COLOR_LIST_SELECTION); +// } else { +// foreground = display.getSystemColor (SWT.COLOR_LIST_FOREGROUND); +// background = display.getSystemColor (SWT.COLOR_LIST_BACKGROUND); +// } +// int red = (short) (background.handle [0] * 255); +// int green = (short) (background.handle [1] * 255); +// int blue = (short) (background.handle [2] * 255); +// RGBColor color = new RGBColor (); +// color.red = (short) (red << 8 | red); +// color.green = (short) (green << 8 | green); +// color.blue = (short) (blue << 8 | blue); +// OS.RGBForeColor (color); +// OS.PaintRect (rect); +// red = (short) (foreground.handle [0] * 255); +// green = (short) (foreground.handle [1] * 255); +// blue = (short) (foreground.handle [2] * 255); +// color.red = (short) (red << 8 | red); +// color.green = (short) (green << 8 | green); +// color.blue = (short) (blue << 8 | blue); +// OS.RGBForeColor (color); +// OS.MoveTo (rect.left, (short)(rect.top + 13)); +// OS.DrawText (buffer, (short) 0, (short) buffer.length); +// OS.SetGWorld (port [0], gdh [0]); +//// System.out.println("x=" + rect.left + " y=" + rect.top + " width=" + (rect.right - rect.left) + " height=" + (rect.bottom - rect.top)); +// return OS.noErr; +// } + + Rect rect = new Rect (); + OS.memcpy (rect, theRect, Rect.sizeof); +// System.out.println("x=" + rect.left + " y=" + rect.top + " width=" + (rect.right - rect.left) + " height=" + (rect.bottom - rect.top)); + int x = rect.left; + int y = rect.top; + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + Rect controlRect = new Rect (); + OS.GetControlBounds (handle, controlRect); + x -= controlRect.left; + y -= controlRect.top; + GC gc = paintGC == null ? new GC (this) : paintGC; + int clip = OS.NewRgn (); + OS.GetClip (clip); + OS.OffsetRgn (clip, (short)-controlRect.left, (short)-controlRect.top); + gc.setClipping (Region.carbon_new (clip)); + OS.DisposeRgn (clip); + Display display = getDisplay (); + Color foreground = item.foreground != null ? item.foreground : display.getSystemColor (SWT.COLOR_LIST_FOREGROUND); + Color background = item.background != null ? item.background : display.getSystemColor (SWT.COLOR_LIST_BACKGROUND); + gc.setForeground (foreground); + gc.setBackground (background); + gc.fillRectangle (x, y, width, height); + Image image = item.image; + if (image != null) { + Rectangle bounds = image.getBounds (); + gc.drawImage (image, 0, 0, bounds.width, bounds.height, x, y, bounds.width, height); + x += bounds.width + 2; + } + Point extent = gc.stringExtent (item.text); + if ((itemState & OS.kDataBrowserItemIsSelected) != 0) { + gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT)); + gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); + gc.fillRectangle (x, y, extent.x, height); + } + gc.drawString (item.text, x, y + (Math.max (0, (height - extent.y) / 2))); + if (paintGC == null) gc.dispose (); + return OS.noErr; +} + +public Rectangle getClientArea () { + checkWidget(); + Rect rect = new Rect (), inset = new Rect (); + OS.GetControlBounds (handle, rect); + OS.GetDataBrowserScrollBarInset (handle, inset); + return new Rectangle (inset.left, inset.top, rect.right - rect.left + inset.right, rect.bottom - rect.top + inset.bottom); +} + +public TreeItem getItem (Point point) { + checkWidget (); + if (point == null) error (SWT.ERROR_NULL_ARGUMENT); + Rect rect = new Rect (); + OS.GetControlBounds (handle, rect); + org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); + OS.SetPt (pt, (short) (point.x + rect.left), (short) (point.y + rect.top)); + //OPTIMIZE + for (int i=0; i<items.length; i++) { + TreeItem item = items [i]; + if (item != null) { + OS.GetDataBrowserItemPartBounds (handle, item.id, COLUMN_ID, OS.kDataBrowserPropertyEnclosingPart, rect); + if (OS.PtInRect (pt, rect)) return item; + } + } + return null; +} + +public int getItemCount () { + checkWidget (); + return getItemCount (null); +} + +int getItemCount (TreeItem item) { + checkWidget (); + int count = 0; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == item) count++; + } + return count; +} + +public int getItemHeight () { + checkWidget (); + short [] height = new short [1]; + if (OS.GetDataBrowserTableViewRowHeight (handle, height) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT); + } + return height [0]; +} + +public TreeItem [] getItems () { + checkWidget (); + return getItems (null); +} + +public TreeItem [] getItems (TreeItem item) { + int count = 0; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == item) count++; + } + TreeItem [] result = new TreeItem [count]; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == item) { + result [items [i].index] = items [i]; + } + } + return result; +} + +public TreeItem getParentItem () { + checkWidget (); + return null; +} + +public TreeItem [] getSelection () { + checkWidget (); + int ptr = OS.NewHandle (0); + if (OS.GetDataBrowserItems (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, ptr) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_SELECTION); + } + int count = OS.GetHandleSize (ptr) / 4; + TreeItem [] result = new TreeItem [count]; + OS.HLock (ptr); + int [] start = new int [1]; + OS.memcpy (start, ptr, 4); + int [] id = new int [1]; + for (int i=0; i<count; i++) { + OS.memcpy (id, start [0] + (i * 4), 4); + result [i] = items [id [0] - 1]; + } + OS.HUnlock (ptr); + OS.DisposeHandle (ptr); + return result; +} + +public int getSelectionCount () { + checkWidget (); + int [] count = new int [1]; + if (OS.GetDataBrowserItemCount (handle, OS.kDataBrowserNoItem, true, OS.kDataBrowserItemIsSelected, count) != OS.noErr) { + error (SWT.ERROR_CANNOT_GET_COUNT); + } + return count [0]; +} + +int hitTestProc (int browser, int id, int property, int theRect, int mouseRect) { +// int index = id - 1; +// if (!(0 <= index && index < items.length)) return 0; +// TreeItem item = items [index]; + return 1; +} + +void hookEvents () { + super.hookEvents (); + Display display= getDisplay(); + DataBrowserCallbacks callbacks = new DataBrowserCallbacks (); + callbacks.version = OS.kDataBrowserLatestCallbacks; + OS.InitDataBrowserCallbacks (callbacks); + callbacks.v1_itemDataCallback = display.itemDataProc; + callbacks.v1_itemNotificationCallback = display.itemNotificationProc; + OS.SetDataBrowserCallbacks (handle, callbacks); + DataBrowserCustomCallbacks custom = new DataBrowserCustomCallbacks (); + custom.version = OS.kDataBrowserLatestCustomCallbacks; + OS.InitDataBrowserCustomCallbacks (custom); + custom.v1_drawItemCallback = display.drawItemProc; + custom.v1_hitTestCallback = display.hitTestProc; + custom.v1_trackingCallback = display.trackingProc; + OS.SetDataBrowserCustomCallbacks (handle, custom); +} + +int itemDataProc (int browser, int id, int property, int itemData, int setValue) { + int index = id - 1; + if (!(0 <= index && index < items.length)) return OS.noErr; + TreeItem item = items [index]; + switch (property) { + case CHECK_COLUMN_ID: { + if (setValue != 0) { + short [] theData = new short [1]; + OS.GetDataBrowserItemDataButtonValue (itemData, theData); + item.checked = theData [0] == OS.kThemeButtonOn; + Event event = new Event (); + event.item = item; + event.detail = SWT.CHECK; + postEvent (SWT.Selection, event); + } else { + short theData = (short)(item.checked ? OS.kThemeButtonOn : OS.kThemeButtonOff); + OS.SetDataBrowserItemDataButtonValue (itemData, theData); + } + break; + } +// case COLUMN_ID: { +// String text = item.text; +// char [] buffer = new char [text.length ()]; +// text.getChars (0, buffer.length, buffer, 0); +// int ptr = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, buffer.length); +// if (ptr == 0) error (SWT.ERROR_CANNOT_SET_TEXT); +// OS.SetDataBrowserItemDataText (itemData, ptr); +// OS.CFRelease (ptr); +// break; +// } + case OS.kDataBrowserItemIsContainerProperty: { + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == item) { + OS.SetDataBrowserItemDataBooleanValue (itemData, true); + } + } + break; + } + } + return OS.noErr; +} + +int itemNotificationProc (int browser, int id, int message) { + int index = id - 1; + if (!(0 <= index && index < items.length)) return OS.noErr; + TreeItem item = items [index]; + switch (message) { + case OS.kDataBrowserItemSelected: + case OS.kDataBrowserItemDeselected: { + if (ignoreSelect) break; + int [] first = new int [1], last = new int [1]; + OS.GetDataBrowserSelectionAnchor (handle, first, last); + boolean selected = false; + if ((style & SWT.MULTI) != 0) { + int modifiers = OS.GetCurrentEventKeyModifiers (); + if ((modifiers & OS.shiftKey) != 0) { + if (message == OS.kDataBrowserItemSelected) { + selected = first [0] == id || last [0] == id; + } else { + selected = id == anchorFirst || id == anchorLast; + } + } else { + if ((modifiers & OS.cmdKey) != 0) { + selected = true; + } else { + selected = first [0] == last [0]; + } + } + } else { + selected = message == OS.kDataBrowserItemSelected; + } + if (selected) { + anchorFirst = first [0]; + anchorLast = last [0]; + Event event = new Event (); + event.item = item; + postEvent (SWT.Selection, event); + } + break; + } + case OS.kDataBrowserItemDoubleClicked: { + Event event = new Event (); + event.item = item; + postEvent (SWT.DefaultSelection, event); + break; + } + case OS.kDataBrowserContainerClosed: { + if (ignoreExpand) break; + Event event = new Event (); + event.item = item; + sendEvent (SWT.Collapse, event); + break; + } + case OS.kDataBrowserContainerOpened: { + if (!ignoreExpand) { + Event event = new Event (); + event.item = item; + sendEvent (SWT.Expand, event); + } + int count = 0; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == item) count++; + } + int [] ids = new int [count]; + for (int i=0; i<items.length; i++) { + if (items [i] != null && items [i].parentItem == item) { + ids [items [i].index] = items [i].id; + } + } + OS.AddDataBrowserItems (handle, id, ids.length, ids, 0); + break; + } + } + return OS.noErr; +} + +int kEventControlDraw (int nextHandler, int theEvent, int userData) { + GC currentGC = paintGC; + if (currentGC == null) paintGC = new GC (this); + int result = super.kEventControlDraw (nextHandler, theEvent, userData); + if (currentGC == null) { + paintGC.dispose (); + paintGC = null; + } + return result; +} + +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + int result = super.kEventMouseDown (nextHandler, theEvent, userData); + if (result == OS.noErr) return result; + /* + * Feature in the Macintosh. For some reason, when the user + * clicks on the data browser, focus is assigned, then lost + * and then reassigned causing kEvenControlSetFocusPart events. + * The fix is to ignore kEvenControlSetFocusPart when the user + * clicks and send the focus events from kEventMouseDown. + */ + Display display = getDisplay (); + Control oldFocus = display.getFocusControl (); + display.ignoreFocus = true; + result = OS.CallNextEventHandler (nextHandler, theEvent); + display.ignoreFocus = false; + if (oldFocus != this) { + if (oldFocus != null) oldFocus.sendFocusEvent (false); + if (isEnabled ()) sendFocusEvent (true); + } + return result; +} + +void releaseWidget () { + for (int i=0; i<items.length; i++) { + TreeItem item = items [i]; + if (item != null && !item.isDisposed ()) { + item.releaseResources (); + } + } + super.releaseWidget (); +} + +public void removeAll () { + checkWidget (); + if (OS.RemoveDataBrowserItems (handle, OS.kDataBrowserNoItem, 0, null, 0) != OS.noErr) { + error (SWT.ERROR_ITEM_NOT_REMOVED); + } + for (int i=0; i<items.length; i++) { + TreeItem item = items [i]; + if (item != null && !item.isDisposed ()) item.releaseResources (); + } + items = new TreeItem [4]; + anchorFirst = anchorLast = 0; +} + +public void removeSelectionListener (SelectionListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + eventTable.unhook (SWT.Selection, listener); + eventTable.unhook (SWT.DefaultSelection, listener); +} + +public void removeTreeListener(TreeListener listener) { + checkWidget (); + if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + eventTable.unhook (SWT.Expand, listener); + eventTable.unhook (SWT.Collapse, listener); +} + +public void setInsertMark (TreeItem item, boolean before) { + checkWidget (); + if (item != null) { + if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); + } +} + +public void selectAll () { + checkWidget (); + if ((style & SWT.SINGLE) != 0) return; + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsAssign); + ignoreSelect = false; +} + +public void setSelection (TreeItem [] items) { + checkWidget (); + if (items == null) error (SWT.ERROR_NULL_ARGUMENT); + int[] ids = new int [items.length]; + for (int i=0; i<items.length; i++) { + if (items [i] == null) error (SWT.ERROR_INVALID_ARGUMENT); + if (items [i].isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + ids [i] = items [i].id; + showItem (items [i], false); + } + ignoreSelect = true; + OS.SetDataBrowserSelectedItems (handle, ids.length, ids, OS.kDataBrowserItemsAssign); + ignoreSelect = false; + if (items.length > 0) showItem (items [0], true); +} + +public void showItem (TreeItem item) { + checkWidget (); + if (item == null) error (SWT.ERROR_NULL_ARGUMENT); + if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + showItem (item, true); +} + +void showItem (TreeItem item, boolean scroll) { + int count = 0; + TreeItem parentItem = item.parentItem; + while (parentItem != null && !parentItem.getExpanded ()) { + count++; + parentItem = parentItem.parentItem; + } + int index = 0; + parentItem = item.parentItem; + TreeItem [] path = new TreeItem [count]; + while (parentItem != null && !parentItem.getExpanded ()) { + path [index++] = parentItem; + parentItem = parentItem.parentItem; + } + for (int i=path.length-1; i>=0; --i) { + path [i].setExpanded (true); + } +// if (scroll) { +// short [] width = new short [1]; +// OS.GetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, width); +// Rect rect = new Rect (), inset = new Rect (); +// OS.GetControlBounds (handle, rect); +// OS.GetDataBrowserScrollBarInset (handle, inset); +// OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short)(rect.right - rect.left - inset.left - inset.right)); +// OS.RevealDataBrowserItem (handle, item.id, COLUMN_ID, (byte) OS.kDataBrowserRevealWithoutSelecting); +// OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short)width [0]); +// } + if (scroll) { + Rectangle treeRect = getClientArea (); + Rectangle itemRect = item.getBounds (); + if (treeRect.contains (itemRect.x, itemRect.y)) return; + OS.RevealDataBrowserItem (handle, item.id, COLUMN_ID, (byte) OS.kDataBrowserRevealWithoutSelecting); + int [] top = new int [1], left = new int [1]; + OS.GetDataBrowserScrollPosition (handle, top, left); + OS.SetDataBrowserScrollPosition (handle, top [0], 0); + itemRect = item.getBounds (); + if (!treeRect.contains (itemRect.x, itemRect.y)) { + OS.RevealDataBrowserItem (handle, item.id, COLUMN_ID, (byte) OS.kDataBrowserRevealWithoutSelecting); + } + } +} + +public void showSelection () { + checkWidget (); + //OPTIMIZE + TreeItem [] selection = getSelection (); + if (selection.length > 0) showItem (selection [0], true); +} + +int trackingProc (int browser, int id, int property, int theRect, int startPt, int modifiers) { +// int index = id - 1; +// if (!(0 <= index && index < items.length)) return 0; +// TreeItem item = items [index]; + return 1; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java new file mode 100644 index 0000000000..e89cb91a3c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java @@ -0,0 +1,211 @@ +package org.eclipse.swt.widgets; + +/* + * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + * This file is made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + */ + +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.Rect; + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; + +public class TreeItem extends Item { + Tree parent; + TreeItem parentItem; + int id, index = -1; + boolean checked; + Color foreground, background; + +public TreeItem (Tree parent, int style) { + super (parent, style); + this.parent = parent; + parent.createItem (this, null, -1); +} + +public TreeItem (Tree parent, int style, int index) { + super (parent, style); + if (index < 0) error (SWT.ERROR_INVALID_RANGE); + this.parent = parent; + parent.createItem (this, null, index); +} + +public TreeItem (TreeItem parentItem, int style) { + super (checkNull (parentItem).parent, style); + parent = parentItem.parent; + this.parentItem = parentItem; + parent.createItem (this, parentItem, -1); +} + +public TreeItem (TreeItem parentItem, int style, int index) { + super (checkNull (parentItem).parent, style); + if (index < 0) error (SWT.ERROR_INVALID_RANGE); + parent = parentItem.parent; + this.parentItem = parentItem; + parent.createItem (this, parentItem, index); +} + +static TreeItem checkNull (TreeItem item) { + if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); + return item; +} + +protected void checkSubclass () { + if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); +} + +public Color getBackground () { + checkWidget (); + return background != null ? background : getDisplay ().getSystemColor (SWT.COLOR_LIST_BACKGROUND); +} + +public Rectangle getBounds () { + checkWidget (); + Rect rect = new Rect(); + OS.GetDataBrowserItemPartBounds (parent.handle, id, Tree.COLUMN_ID, OS.kDataBrowserPropertyEnclosingPart, rect); + int x = rect.left, y = rect.top; + int width = 0; + if (image != null) { + Rectangle bounds = image.getBounds (); + width += bounds.width + 2; + } + GC gc = new GC (parent); + Point extent = gc.stringExtent (text); + gc.dispose (); + width += extent.x; + int height = rect.bottom - rect.top; + OS.GetControlBounds (parent.handle, rect); + x -= rect.left; + y -= rect.top; + return new Rectangle (x, y, width, height); +} + +public boolean getChecked () { + checkWidget (); + if ((parent.style & SWT.CHECK) == 0) return false; + return checked; +} + +public Display getDisplay () { + Tree parent = this.parent; + if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); + return parent.getDisplay (); +} + +public boolean getExpanded () { + checkWidget (); + int [] state = new int [1]; + OS.GetDataBrowserItemState (parent.handle, id, state); + return (state [0] & OS.kDataBrowserContainerIsOpen) != 0; +} + +public Color getForeground () { + checkWidget (); + return foreground != null ? foreground : getDisplay ().getSystemColor (SWT.COLOR_LIST_FOREGROUND); +} + +public boolean getGrayed () { + checkWidget (); + if ((parent.style & SWT.CHECK) == 0) return false; + //NOT DONE + return false; +} + +public int getItemCount () { + checkWidget (); + return parent.getItemCount (this); +} + +public TreeItem [] getItems () { + checkWidget (); + return parent.getItems (this); +} + +public Tree getParent () { + checkWidget (); + return parent; +} + +public TreeItem getParentItem () { + checkWidget (); + return parentItem; +} + +void releaseChild () { + super.releaseChild (); + parent.destroyItem (this); +} + +void releaseWidget () { + super.releaseWidget (); + parentItem = null; + parent = null; + id = 0; + index = -1; +} + +public void setBackground (Color color) { + checkWidget (); + if (color != null && color.isDisposed ()) { + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } + background = color; + redraw (); +} + +public void setChecked (boolean checked) { + checkWidget (); + if ((parent.style & SWT.CHECK) == 0) return; + this.checked = checked; + redraw (); +} + +public void setExpanded (boolean expanded) { + checkWidget (); + parent.ignoreExpand = true; + if (expanded) { + OS.OpenDataBrowserContainer (parent.handle, id); + } else { + OS.CloseDataBrowserContainer (parent.handle, id); + } + parent.ignoreExpand = false; +} + +public void setForeground (Color color) { + checkWidget (); + if (color != null && color.isDisposed ()) { + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } + foreground = color; + redraw (); +} + +public void setGrayed (boolean grayed) { + checkWidget (); + if ((parent.style & SWT.CHECK) == 0) return; + //NOT DONE +} + +public void setImage (Image image) { + checkWidget (); + super.setImage (image); + redraw (); +} + +public void setText (String string) { + checkWidget (); + if (string == null) error (SWT.ERROR_NULL_ARGUMENT); + super.setText (string); + redraw (); +} + +void redraw () { + int parentID = parentItem == null ? OS.kDataBrowserNoItem : parentItem.id; + OS.UpdateDataBrowserItems (parent.handle, parentID, 1, new int[] {id}, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem); + +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java index d944f53cb8..35dc90af4b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java @@ -8,39 +8,17 @@ package org.eclipse.swt.widgets; */ import org.eclipse.swt.internal.*; -import org.eclipse.swt.internal.carbon.*; +import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.carbon.RGBColor; +import org.eclipse.swt.internal.carbon.Rect; +import org.eclipse.swt.internal.carbon.PixMap; +import org.eclipse.swt.internal.carbon.BitMap; + import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; 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 - */ public abstract class Widget { - - public int handle; int style, state; EventTable eventTable; Object data; @@ -48,113 +26,56 @@ public abstract class Widget { Object [] values; /* Global state flags */ -// static final int AUTOMATIC = 0x00000001; -// static final int ACTIVE = 0x00000002; -// static final int AUTOGRAB = 0x00000004; -// static final int MULTIEXPOSE = 0x00000008; -// static final int RESIZEREDRAW = 0x00000010; -// static final int WRAP = 0x00000020; -// static final int DISABLED = 0x00000040; - static final int HIDDEN = 0x00000080; -// static final int FOREGROUND = 0x00000100; -// static final int BACKGROUND = 0x00000200; - static final int DISPOSED = 0x00000400; - static final int HANDLE = 0x00000800; - static final int CANVAS = 0x00001000; +// static final int AUTOMATIC = 1 << 0; +// static final int ACTIVE = 1 << 1; + static final int GRAB = 1 << 2; +// static final int MULTIEXPOSE = 1 << 3; +// static final int RESIZEREDRAW = 1 << 4; +// static final int WRAP = 1 << 5; + static final int DISABLED = 1 << 6; + static final int HIDDEN = 1 << 7; +// static final int FOREGROUND = 1 << 8; +// static final int BACKGROUND = 1 << 9; + static final int DISPOSED = 1 << 10; +// static final int HANDLE = 1 << 11; + static final int CANVAS = 1 << 12; + static final int MOVED = 1 << 13; + static final int RESIZED = 1 << 14; static final int DEFAULT_WIDTH = 64; static final int DEFAULT_HEIGHT = 64; - - /* Global widget variables */ static final char Mnemonic = '&'; + + static final Rect EMPTY_RECT = new Rect (); 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> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - * - * @see SWT - * @see #checkSubclass - * @see #getStyle - */ + public Widget (Widget parent, int style) { - if (parent == null) error (SWT.ERROR_NULL_ARGUMENT); - if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); + checkSubclass (); + checkParent (parent); this.style = style; } -/** - * Adds the listener to the collection of listeners who will - * be notifed when an event of the given type occurs. When the - * event does occur in the widget, the listener is notified by - * sending it the <code>handleEvent()</code> message. - * - * @param eventType the type of event to listen for - * @param listener the listener which should be notified when the event occurs - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see Listener - * @see #removeListener - */ + +int actionProc (int theControl, int partCode) { + return OS.noErr; +} + public void addListener (int eventType, Listener handler) { checkWidget(); if (handler == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) eventTable = new EventTable (); eventTable.hook (eventType, handler); } -/** - * Adds the listener to the collection of listeners who will - * be notifed when the widget is disposed. When the widget is - * 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); } + 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; @@ -166,118 +87,165 @@ static int checkBits (int style, int int0, int int1, int int2, int int3, int int if ((style & int5) != 0) style = (style & ~mask) | int5; return style; } + void checkParent (Widget parent) { if (parent == null) error (SWT.ERROR_NULL_ARGUMENT); if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); } -/** - * Checks that this class can be subclassed. - * <p> - * The SWT class library is intended to be subclassed - * only at specific, controlled points (most notably, - * <code>Composite</code> and <code>Canvas</code> when - * implementing new widgets). This method enforces this - * rule unless it is overridden. - * </p><p> - * <em>IMPORTANT:</em> By providing an implementation of this - * method that allows a subclass of a class which does not - * normally allow subclassing to be created, the implementer - * agrees to be fully responsible for the fact that any such - * subclass will likely fail between SWT releases and will be - * strongly platform specific. No support is provided for - * user-written classes which are implemented in this fashion. - * </p><p> - * The ability to subclass outside of the allowed SWT classes - * is intended purely to enable those not on the SWT development - * team to implement patches in order to get around specific - * limitations in advance of when those limitations can be - * addressed by the team. Subclassing should not be attempted - * without an intimate and detailed understanding of the hierarchy. - * </p> - * - * @exception SWTException <ul> - * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> - * </ul> - */ + protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } -/** - * Throws an <code>SWTException</code> if the receiver can not - * be accessed by the caller. This may include both checks on - * the state of the receiver and more generally on the entire - * execution context. This method <em>should</em> be called by - * widget implementors to enforce the standard SWT invariants. - * <p> - * Currently, it is an error to invoke any method (other than - * <code>isDisposed()</code>) on a widget that has had its - * <code>dispose()</code> method called. It is also an error - * to call widget methods from any thread that is different - * from the thread that created the widget. - * </p><p> - * In future releases of SWT, there may be more or fewer error - * checks and exceptions may be thrown for different reasons. - * </p> - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ + protected void checkWidget () { if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED); } -void createHandle (int index) { - /* Do nothing */ + +int controlProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + switch (eventKind) { + case OS.kEventControlActivate: return kEventControlActivate (nextHandler, theEvent, userData); + case OS.kEventControlBoundsChanged: return kEventControlBoundsChanged (nextHandler, theEvent, userData); + case OS.kEventControlClick: return kEventControlClick (nextHandler, theEvent, userData); + case OS.kEventControlContextualMenuClick: return kEventControlContextualMenuClick (nextHandler, theEvent, userData); + case OS.kEventControlDeactivate: return kEventControlDeactivate (nextHandler, theEvent, userData); + case OS.kEventControlDraw: return kEventControlDraw (nextHandler, theEvent, userData); + case OS.kEventControlHit: return kEventControlHit (nextHandler, theEvent, userData); + case OS.kEventControlSetCursor: return kEventControlSetCursor (nextHandler, theEvent, userData); + case OS.kEventControlSetFocusPart: return kEventControlSetFocusPart (nextHandler, theEvent, userData); + } + return OS.eventNotHandledErr; } -void createWidget (int index) { - createHandle (index); - hookEvents (); + +int createCIcon (Image image) { + int imageHandle = image.handle; + int width = OS.CGImageGetWidth(imageHandle); + int height = OS.CGImageGetHeight(imageHandle); + int bpr = OS.CGImageGetBytesPerRow(imageHandle); + int bpp = OS.CGImageGetBitsPerPixel(imageHandle); + int bpc = OS.CGImageGetBitsPerComponent(imageHandle); + int alphaInfo = OS.CGImageGetAlphaInfo(imageHandle); + + int maskBpl = (((width + 7) / 8) + 3) / 4 * 4; + int maskSize = height * maskBpl; + int pixmapSize = height * bpr; + + /* Create the icon */ + int iconSize = PixMap.sizeof + BitMap.sizeof * 2 + 4 + maskSize; + int iconHandle = OS.NewHandle(iconSize); + if (iconHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES); + OS.HLock(iconHandle); + int[] iconPtr = new int[1]; + OS.memcpy(iconPtr, iconHandle, 4); + + /* Initialize the pixmap */ + PixMap iconPMap = new PixMap(); + iconPMap.rowBytes = (short)(bpr | 0x8000); + iconPMap.right = (short)width; + iconPMap.bottom = (short)height; + iconPMap.cmpCount = 3; + iconPMap.cmpSize = (short)bpc; + iconPMap.pmTable = OS.NewHandle(0); + iconPMap.hRes = 72 << 16; + iconPMap.vRes = 72 << 16; + iconPMap.pixelType = (short)OS.RGBDirect; + iconPMap.pixelSize = (short)bpp; + iconPMap.pixelFormat = (short)bpp; + OS.memcpy(iconPtr[0], iconPMap, PixMap.sizeof); + + /* Initialize the mask */ + BitMap iconMask = new BitMap(); + iconMask.rowBytes = (short)maskBpl; + iconMask.right = (short)width; + iconMask.bottom = (short)height; + OS.memcpy(iconPtr[0] + PixMap.sizeof, iconMask, BitMap.sizeof); + + /* Initialize the icon data */ + int iconData = OS.NewHandle(pixmapSize); + OS.HLock(iconData); + int[] iconDataPtr = new int[1]; + OS.memcpy(iconDataPtr, iconData, 4); + OS.memcpy(iconDataPtr[0], image.data, pixmapSize); + OS.HUnlock(iconData); + OS.memcpy(iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof, new int[]{iconData}, 4); + + /* Initialize the mask data */ + if (alphaInfo != OS.kCGImageAlphaFirst) { + OS.memset(iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof + 4, -1, maskSize); + } else { + byte[] srcData = new byte[pixmapSize]; + OS.memcpy(srcData, image.data, pixmapSize); + byte[] maskData = new byte[maskSize]; + int offset = 0, maskOffset = 0; + for (int y = 0; y<height; y++) { + for (int x = 0; x<width; x++) { + if ((srcData[offset] & 0xFF) > 128) { + maskData[maskOffset + (x >> 3)] |= (1 << (7 - (x & 0x7))); + } else { + maskData[maskOffset + (x >> 3)] &= ~(1 << (7 - (x & 0x7))); + } + offset += 4; + } + maskOffset += maskBpl; + } + OS.memcpy(iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof + 4, maskData, maskData.length); + } + + OS.HUnlock(iconHandle); + return iconHandle; +} + +void createHandle () { +} + +void createWidget () { + createHandle (); register (); - manageChildren (); + hookEvents (); +} + +int commandProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + switch (eventKind) { + case OS.kEventProcessCommand: return kEventProcessCommand (nextHandler, theEvent, userData); + } + return OS.eventNotHandledErr; } + void deregister () { - if (handle == 0) return; - WidgetTable.remove (handle); } + void destroyWidget () { - int topHandle = topHandle (); releaseHandle (); - if (topHandle != 0) { - if (OS.IsValidControlHandle(topHandle)) { - OS.DisposeControl(topHandle); - } else if (OS.IsValidWindowPtr(topHandle)) { - OS.DisposeWindow(topHandle); - } else { - System.out.println("Widget.destroyWidget: wrong handle"); - } - } } -/** - * Disposes of the operating system resources associated with - * the receiver and all its descendents. After this method has - * been invoked, the receiver and all descendents will answer - * <code>true</code> when sent the message <code>isDisposed()</code>. - * Any internal connections between the widgets in the tree will - * have been removed to facilitate garbage collection. - * <p> - * NOTE: This method is not called recursively on the descendents - * of the receiver. This means that, widget implementers can not - * detect when a widget is being disposed of by re-implementing - * this method, but should instead listen for the <code>Dispose</code> - * event. - * </p> - * - * @exception SWTException <ul> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #addDisposeListener - * @see #removeDisposeListener - * @see #checkWidget - */ + +void destroyCIcon (int iconHandle) { + OS.HLock(iconHandle); + + /* Dispose the ColorTable */ + int[] iconPtr = new int[1]; + OS.memcpy(iconPtr, iconHandle, 4); + PixMap iconPMap = new PixMap(); + OS.memcpy(iconPMap, iconPtr[0], PixMap.sizeof); + if (iconPMap.pmTable != 0) OS.DisposeHandle(iconPMap.pmTable); + + /* Dispose the icon data */ + int[] iconData = new int[1]; + OS.memcpy(iconData, iconPtr[0] + PixMap.sizeof + 2 * BitMap.sizeof, 4); + if (iconData[0] != 0) OS.DisposeHandle(iconData[0]); + + OS.HUnlock(iconHandle); + + /* Dispose the icon */ + OS.DisposeHandle(iconHandle); +} + +int drawItemProc (int browser, int item, int property, int itemState, int theRect, int gdDepth, int colorDevice) { + return OS.noErr; +} + public void dispose () { /* * Note: It is valid to attempt to dispose a widget @@ -289,66 +257,74 @@ public void dispose () { releaseWidget (); destroyWidget (); } -void enableHandle (boolean enabled, int widgetHandle) { - if (enabled) - OS.EnableControl(widgetHandle); - else - OS.DisableControl(widgetHandle); -} + +void drawBackground (int control, float [] background) { + Rect rect = new Rect (); + OS.GetControlBounds (control, rect); + if (background != null) { + int red = (short) (background [0] * 255); + int green = (short) (background [1] * 255); + int blue = (short) (background [2] * 255); + RGBColor color = new RGBColor (); + color.red = (short) (red << 8 | red); + color.green = (short) (green << 8 | green); + color.blue = (short) (blue << 8 | blue); + OS.RGBForeColor (color); + OS.PaintRect (rect); + } else { + OS.EraseRect (rect); + } +} + +void drawWidget (int control) { +} + void error (int code) { SWT.error(code); } -/** - * Returns the application defined widget data associated - * with the receiver, or null if it has not been set. The - * <em>widget data</em> is a single, unnamed field that is - * stored with every widget. - * <p> - * Applications may put arbitrary objects in this field. If - * the object stored in the widget data needs to be notified - * when the widget is disposed of, it is the application's - * responsibility to hook the Dispose event on the widget and - * do so. - * </p> - * - * @return the widget data - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li> - * </ul> - * - * @see #setData - */ + +boolean filters (int eventType) { + Display display = getDisplay (); + return display.filters (eventType); +} + +Rect getControlBounds (int control) { + Rect rect = new Rect(); + OS.GetControlBounds (control, rect); + int window = OS.GetControlOwner (control); + int [] theRoot = new int [1]; + OS.GetRootControl (window, theRoot); + int [] parentHandle = new int [1]; + OS.GetSuperControl (control, parentHandle); + if (parentHandle [0] != theRoot [0]) { + Rect parentRect = new Rect (); + OS.GetControlBounds (parentHandle [0], parentRect); + OS.OffsetRect (rect, (short) -parentRect.left, (short) -parentRect.top); + } + Rect inset = getInset (); + rect.left -= inset.left; + rect.top -= inset.top; + rect.right += inset.right; + rect.bottom += inset.bottom; + return rect; +} + +Rect getControlSize (int control) { + Rect rect = new Rect (); + OS.GetControlBounds (control, rect); + Rect inset = getInset (); + rect.left -= inset.left; + rect.top -= inset.top; + rect.right += inset.right; + rect.bottom += inset.bottom; + return rect; +} + public Object getData () { checkWidget(); return data; } -/** - * Returns the application defined property of the receiver - * with the specified name, or null if it has not been set. - * <p> - * Applications may have associated arbitrary objects with the - * receiver in this fashion. If the objects stored in the - * properties need to be notified when the widget is disposed - * of, it is the application's responsibility to hook the - * Dispose event on the widget and do so. - * </p> - * - * @param key the name of the property - * @return the value of the property or null if it has not been set - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the key is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #setData - */ public Object getData (String key) { checkWidget(); if (key == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -359,362 +335,306 @@ public Object getData (String key) { return null; } -/** - * Returns the <code>Display</code> that is associated with - * the receiver. - * <p> - * A widget's display is either provided when it is created - * (for example, top level <code>Shell</code>s) or is the - * same as its parent's display. - * </p> - * - * @return the receiver's display - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ public abstract Display getDisplay (); + String getName () { String string = getClass ().getName (); - int index = string.lastIndexOf ('.'); + int index = string.lastIndexOf("."); if (index == -1) return string; - return string.substring (index + 1, string.length ()); + 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; } + +int getVisibleRegion (int control) { + int visibleRgn = OS.NewRgn (), childRgn = OS.NewRgn (), tempRgn = OS.NewRgn (); + int window = OS.GetControlOwner (control); + int port = OS.GetWindowPort (window); + OS.GetPortVisibleRegion (port, visibleRgn); + short [] count = new short [1]; + int [] outControl = new int [1]; + int tempControl = control, lastControl = 0; + while (tempControl != 0) { + OS.GetControlRegion (tempControl, (short) OS.kControlStructureMetaPart, tempRgn); + OS.SectRgn (tempRgn, visibleRgn, visibleRgn); + if (OS.EmptyRgn (visibleRgn)) break; + OS.CountSubControls (tempControl, count); + for (int i = 0; i < count [0]; i++) { + OS.GetIndexedSubControl (tempControl, (short)(i + 1), outControl); + int child = outControl [0]; + if (child == lastControl) break; + if (!OS.IsControlVisible (child)) continue; + OS.GetControlRegion (child, (short) OS.kControlStructureMetaPart, tempRgn); + OS.UnionRgn (tempRgn, childRgn, childRgn); + } + lastControl = tempControl; + OS.GetSuperControl (tempControl, outControl); + tempControl = outControl [0]; + } + OS.DiffRgn (visibleRgn, childRgn, visibleRgn); + OS.DisposeRgn (childRgn); + OS.DisposeRgn (tempRgn); + return visibleRgn; +} + +int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) { + return OS.eventNotHandledErr; +} + +int hitTestProc (int browser, int item, int property, int theRect, int mouseRect) { + /* Return true to indicate that the item can be selected */ + return 1; +} + void hookEvents () { - /* Do nothing */ } + boolean hooks (int eventType) { if (eventTable == null) return false; return eventTable.hooks (eventType); } -/** - * Returns <code>true</code> if the widget has been disposed, - * and <code>false</code> otherwise. - * <p> - * This method gets the dispose state for the widget. - * When a widget has been disposed, it is an error to - * invoke any other method using the widget. - * </p> - * - * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise - */ + +Rect getInset () { + return EMPTY_RECT; +} + public boolean isDisposed () { - if (handle != 0) return false; - if ((state & HANDLE) != 0) return true; return (state & DISPOSED) != 0; } -/** - * Return the listening state. - * <p> - * Returns true if there is a listener, listening for the eventType. - * Otherwise, returns false. - * - * @param eventType the type of event - * @return true if the event is hooked - * - * @exception SWTError <ul> - * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> - * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> - * <li>ERROR_NULL_ARGUMENT when the name is null</li> - * </ul> - */ + protected boolean isListening (int eventType) { checkWidget(); return hooks (eventType); } + boolean isValidSubclass () { return Display.isValidClass (getClass ()); } + boolean isValidThread () { return getDisplay ().isValidThread (); } -void manageChildren () { - /* Do nothing */ + +int itemDataProc (int browser, int item, int property, int itemData, int setValue) { + return OS.noErr; } -/** - * Notifies all of the receiver's listeners for events - * of the given type that one such event has occurred by - * invoking their <code>handleEvent()</code> method. - * - * @param eventType the type of event which has occurred - * @param event the event data - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the event is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void notifyListeners (int eventType, Event event) { - checkWidget(); - if (event == null) error (SWT.ERROR_NULL_ARGUMENT); - if (eventTable == null) return; - event.type = eventType; - event.widget = this; - eventTable.sendEvent (event); + +int itemNotificationProc (int browser, int item, int message) { + return OS.noErr; } -void postEvent (int eventType) { - if (eventTable == null) return; - postEvent (eventType, new Event ()); + +int kEventProcessCommand (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -void postEvent (int eventType, Event event) { - if (eventTable == null) return; - Display display = getDisplay (); - event.type = eventType; - event.widget = this; - event.display = display; - if (event.time == 0) { - /* AW - event.time = OS.XtLastTimestampProcessed (display.xDisplay); - */ - event.time = (int)(OS.GetLastUserEventTime() * 1000.0); - } - display.postEvent (event); + +int kEventControlActivate (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processArm (Object callData) { - return 0; + +int kEventControlBoundsChanged (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processDispose (Object callData) { - return 0; + +int kEventControlClick (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processDefaultSelection (Object callData) { - return 0; + +int kEventControlContextualMenuClick (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -final int processEvent (int eventNumber) { - switch (eventNumber) { - case SWT.Dispose: return processDispose (null); - case SWT.Help: return processHelp (null); - default: - System.out.println("Widget.processEvent(): unexpected event"); - break; - } - return 0; -} -final int processEvent (int eventNumber, MacControlEvent mcEvent) { - switch (eventNumber) { - case SWT.Selection: return processSelection (mcEvent); - case SWT.Paint: return processPaint (mcEvent); - default: - System.out.println("Widget.processEvent(MacMouseEvent): unexpected event"); - break; - } - return 0; -} -final int processEvent (int eventNumber, MacMouseEvent mmEvent) { - switch (eventNumber) { - case SWT.MouseDown: return processMouseDown (mmEvent); - case SWT.MouseEnter: return processMouseEnter (mmEvent); - case SWT.MouseExit: return processMouseExit (mmEvent); - case SWT.MouseHover: return processMouseHover (mmEvent); - case SWT.MouseMove: return processMouseMove (mmEvent); - case SWT.MouseUp: return processMouseUp (mmEvent); - default: - System.out.println("Widget.processEvent(MacMouseEvent): unexpected event"); - break; - } - return 0; -} -final int processEvent (int eventNumber, MacEvent me) { - switch (eventNumber) { - case SWT.Arm: return processArm (me); - case SWT.DefaultSelection: return processDefaultSelection (me); - case SWT.Hide: return processHide (me); - case SWT.KeyDown: return processKeyDown (me); - case SWT.KeyUp: return processKeyUp (me); - case SWT.Modify: return processModify (me); - case SWT.Show: return processShow (me); - case SWT.Verify: return processVerify (me); - case -1: return processNonMaskable (me); - default: - System.out.println("Widget.processEvent(Object): unexpected event"); - break; - } - return 0; + +int kEventControlDeactivate (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processHelp (Object callData) { - return 0; + +int kEventControlDraw (int nextHandler, int theEvent, int userData) { + int [] theControl = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeControlRef, null, 4, null, theControl); + int [] region = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle, OS.typeQDRgnHandle, null, 4, null, region); + int visibleRgn = getVisibleRegion (theControl [0]); + int oldClip = OS.NewRgn (); + OS.GetClip (oldClip); + OS.SectRgn(region [0], visibleRgn, visibleRgn); + OS.SetClip (visibleRgn); + drawWidget (theControl [0]); + int result = OS.CallNextEventHandler (nextHandler, theEvent); + OS.SetClip (oldClip); + OS.DisposeRgn (visibleRgn); + OS.DisposeRgn (oldClip); + return result; } -int processHide (Object callData) { - return 0; + +int kEventControlHit (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processKeyDown (Object callData) { - return 0; + +int kEventControlSetCursor (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processKeyUp (Object callData) { - return 0; + +int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processModify (Object callData) { - return 0; + +int kEventMenuClosed (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processMouseDown (MacMouseEvent mme) { - return 0; + +int kEventMenuOpening (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processMouseEnter (MacMouseEvent mme) { - return 0; + +int kEventMouseDown (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processMouseExit (MacMouseEvent mme) { - return 0; + +int kEventMouseDragged (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processMouseHover (MacMouseEvent mme) { - return 0; + +int kEventMouseMoved (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processMouseMove (MacMouseEvent mme) { - return 0; + +int kEventMouseUp (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processMouseUp (MacMouseEvent mme) { - return 0; + +int kEventMouseWheelMoved (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processNonMaskable (Object callData) { - return 0; + +int kEventRawKeyUp (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processPaint (Object callData) { - return 0; + +int kEventRawKeyRepeat (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processResize (Object callData) { - return 0; + +int kEventRawKeyModifiersChanged (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processSelection (Object callData) { - return 0; + +int kEventRawKeyDown (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processSetFocus (Object callData) { - return 0; + +int kEventWindowActivated (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processShow (Object callData) { - return 0; + +int kEventWindowBoundsChanged (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -int processVerify (Object callData) { - return 0; + +int kEventWindowClose (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; } -void propagateHandle (boolean enabled, int widgetHandle) { - /* AW - int xDisplay = OS.XtDisplay (widgetHandle); - if (xDisplay == 0) return; - int xWindow = OS.XtWindow (widgetHandle); - if (xWindow == 0) return; - */ - /* - * Get the event mask from the widget. The event mask - * returned by XtBuildEventMask () includes the masks - * associated with all callbacks and event handlers - * that have been hooked on the widget. - */ - /* AW - int event_mask = OS.XtBuildEventMask (widgetHandle); - int do_not_propagate_mask = - OS.KeyPressMask | OS.KeyReleaseMask | OS.ButtonPressMask | - OS.ButtonReleaseMask | OS.PointerMotionMask; - if (!enabled) { - */ - /* - * Attempting to propogate EnterWindowMask and LeaveWindowMask - * causes an X error so these must be specially cleared out from - * the event mask, not included in the propogate mask. - */ - /* AW - event_mask &= ~(do_not_propagate_mask | OS.EnterWindowMask | OS.LeaveWindowMask); - do_not_propagate_mask = 0; + +int kEventWindowCollapsed (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; +} + +int kEventWindowDeactivated (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; +} + +int kEventWindowExpanded (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; +} + +int kEventWindowHidden (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; +} + +int kEventWindowShown (int nextHandler, int theEvent, int userData) { + return OS.eventNotHandledErr; +} + +int keyboardProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + switch (eventKind) { + case OS.kEventRawKeyDown: return kEventRawKeyDown (nextHandler, theEvent, userData); + case OS.kEventRawKeyModifiersChanged: return kEventRawKeyModifiersChanged (nextHandler, theEvent, userData); + case OS.kEventRawKeyRepeat: return kEventRawKeyRepeat (nextHandler, theEvent, userData); + case OS.kEventRawKeyUp: return kEventRawKeyUp (nextHandler, theEvent, userData); } - XSetWindowAttributes attributes = new XSetWindowAttributes (); - attributes.event_mask = event_mask; - attributes.do_not_propagate_mask = do_not_propagate_mask; - OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWDontPropagate | OS.CWEventMask, attributes); - int [] argList = {OS.XmNtraversalOn, enabled ? 1 : 0}; - OS.XtSetValues (widgetHandle, argList, argList.length / 2); - */ -} -final void redrawHandle (int x, int y, int width, int height, int widgetHandle, boolean all) { - /* AW - int display = OS.XtDisplay (widgetHandle); - if (display == 0) return; - int window = OS.XtWindow (widgetHandle); - if (window == 0) return; - int [] argList = {OS.XmNborderWidth, 0, OS.XmNborderColor, 0}; - OS.XtGetValues (widgetHandle, argList, argList.length / 2); - if (argList [1] != 0) { - */ - /* Force the border to repaint by setting the color */ - /* - OS.XtSetValues (widgetHandle, argList, argList.length / 2); + return OS.eventNotHandledErr; +} + +int menuProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + switch (eventKind) { + case OS.kEventMenuOpening: return kEventMenuOpening (nextHandler, theEvent, userData); + case OS.kEventMenuClosed: return kEventMenuClosed (nextHandler, theEvent, userData); } - OS.XClearArea (display, window, x, y, width, height, true); - */ - - if (false) { - int rgn= OS.NewRgn(); - OS.RectRgn(rgn, new MacRect(x, y, width, height).getData()); - OS.HIViewSetNeedsDisplayInRegion(widgetHandle, rgn, true); - OS.DisposeRgn(rgn); - } else { - MacRect br= new MacRect(); - OS.GetControlBounds(widgetHandle, br.getData()); - if (!br.isEmpty()) { - x+= br.getX(); - y+= br.getY(); - if (width == 0) - width= br.getWidth(); - else - width+= 1; // AW strange workaround for Caret - if (height == 0) - height= br.getHeight(); - - int rgn= OS.NewRgn(); - OS.RectRgn(rgn, new MacRect(x, y, width, height).getData()); - - int region= OS.NewRgn(); - if (MacUtil.getVisibleRegion(widgetHandle, region, all) == OS.kNoErr) { - - OS.SectRgn(region, rgn, region); - - OS.InvalWindowRgn(OS.GetControlOwner(widgetHandle), region); - } - - OS.DisposeRgn(rgn); - OS.DisposeRgn(region); - } + return OS.eventNotHandledErr; +} + +int mouseProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + switch (eventKind) { + case OS.kEventMouseDown: return kEventMouseDown (nextHandler, theEvent, userData); + case OS.kEventMouseUp: return kEventMouseUp (nextHandler, theEvent, userData); + case OS.kEventMouseDragged: return kEventMouseDragged (nextHandler, theEvent, userData); +// case OS.kEventMouseEntered: return kEventMouseEntered (nextHandler, theEvent, userData); +// case OS.kEventMouseExited: return kEventMouseExited (nextHandler, theEvent, userData); + case OS.kEventMouseMoved: return kEventMouseMoved (nextHandler, theEvent, userData); + case OS.kEventMouseWheelMoved: return kEventMouseWheelMoved (nextHandler, theEvent, userData); } + return OS.eventNotHandledErr; +} + +public void notifyListeners (int eventType, Event event) { + checkWidget(); + if (event == null) error (SWT.ERROR_NULL_ARGUMENT); + if (eventTable == null) return; + event.type = eventType; + event.widget = this; + eventTable.sendEvent (event); +} + +void postEvent (int eventType) { + sendEvent (eventType, null, false); +} + +void postEvent (int eventType, Event event) { + sendEvent (eventType, event, false); } + +void redrawWidget (int control) { + if (!OS.IsControlVisible (control)) return; + Rect rect = new Rect (); + OS.GetControlBounds (control, rect); + int window = OS.GetControlOwner (control); + OS.InvalWindowRect (window, rect); +} + void register () { - if (handle == 0) return; - WidgetTable.put (handle, this); } + void releaseChild () { /* Do nothing */ } + void releaseHandle () { - handle = 0; state |= DISPOSED; } + +void releaseResources () { + releaseWidget (); + releaseHandle (); +} + void releaseWidget () { sendEvent (SWT.Dispose); deregister (); @@ -723,163 +643,124 @@ void releaseWidget () { keys = null; values = null; } -/** - * Removes the listener from the collection of listeners who will - * be notifed when an event of the given type occurs. - * - * @param eventType the type of event to listen for - * @param listener the listener which should no longer be notified when the event occurs - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see Listener - * @see #addListener - */ + public void removeListener (int eventType, Listener handler) { checkWidget(); if (handler == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (eventType, handler); } -/** - * Removes the listener from the collection of listeners who will - * be notifed when an event of the given type occurs. - * <p> - * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT - * public API. It is marked public only so that it can be shared - * within the packages provided by SWT. It should never be - * referenced from application code. - * </p> - * - * @param eventType the type of event to listen for - * @param listener the listener which should no longer be notified when the event occurs - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see Listener - * @see #addListener - */ + protected void removeListener (int eventType, SWTEventListener handler) { checkWidget(); if (handler == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (eventType, handler); } -/** - * Removes the listener from the collection of listeners who will - * be notifed when the widget is disposed. - * - * @param listener the listener which should no longer be notified when the receiver is disposed - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see DisposeListener - * @see #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 sendEvent (int eventType) { - if (eventTable == null) return; - sendEvent (eventType, new Event ()); + +void sendEvent (Event event) { + Display display = event.display; + if (!display.filterEvent (event)) { + if (eventTable != null) eventTable.sendEvent (event); + } } -/* -final void setInputState (Event event, MacEvent mEvent) { - event.stateMask= mEvent.getStateMask(); -} -*/ -void setKeyState (Event event, MacEvent mEvent) { - int kc= Display.translateKey(mEvent.getKeyCode()); - if (kc != 0) { - event.keyCode = kc; - } else { - //event.keyCode = 0; - event.character = (char) mEvent.getMacCharCodes(); - } - // AW setInputState (event, mEvent); - event.stateMask= mEvent.getStateMask(); + +void sendEvent (int eventType) { + sendEvent (eventType, null, true); } + void sendEvent (int eventType, Event event) { - if (eventTable == null) return; + sendEvent (eventType, event, true); +} + +void sendEvent (int eventType, Event event, boolean send) { Display display = getDisplay (); + if (eventTable == null && !display.filters (eventType)) { + return; + } + if (event == null) event = new Event (); event.type = eventType; event.display = display; event.widget = this; if (event.time == 0) { - event.time = (int)(OS.GetLastUserEventTime() * 1000.0); + event.time = display.getLastEventTime (); + } + if (send) { + sendEvent (event); + } else { + display.postEvent (event); } - eventTable.sendEvent (event); } -/** - * Sets the application defined widget data associated - * with the receiver to be the argument. The <em>widget - * data</em> is a single, unnamed field that is stored - * with every widget. - * <p> - * Applications may put arbitrary objects in this field. If - * the object stored in the widget data needs to be notified - * when the widget is disposed of, it is the application's - * responsibility to hook the Dispose event on the widget and - * do so. - * </p> - * - * @param data the widget data - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li> - * </ul> - */ + +int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) { + Rect inset = getInset (); + Rect oldBounds = new Rect (); + OS.GetControlBounds (control, oldBounds); + oldBounds.left -= inset.left; + oldBounds.top -= inset.top; + oldBounds.right += inset.right; + oldBounds.bottom += inset.bottom; + boolean visible = OS.IsControlVisible (control); + int window = OS.GetControlOwner (control); + if (visible) OS.InvalWindowRect (window, oldBounds); + x += inset.left; + y += inset.top; + width -= (inset.left + inset.right); + height -= (inset.top + inset.bottom); + if (move) { + int [] theRoot = new int [1]; + OS.GetRootControl (window, theRoot); + int [] parentHandle = new int [1]; + OS.GetSuperControl (control, parentHandle); + if (parentHandle [0] != theRoot [0]) { + Rect rect = new Rect (); + OS.GetControlBounds (parentHandle [0], rect); + x += rect.left; + y += rect.top; + } + } else { + x = oldBounds.left; + y = oldBounds.top; + } + if (!resize) { + width = oldBounds.right - oldBounds.left; + height = oldBounds.bottom - oldBounds.top; + } + width = Math.max (0, width); + height = Math.max (0, height); + boolean sameOrigin = x == oldBounds.left && y == oldBounds.top; + boolean sameExtent = width == (oldBounds.right - oldBounds.left) && height == (oldBounds.bottom - oldBounds.top); + Rect newBounds = new Rect (); + newBounds.left = (short) x; + newBounds.top = (short) y; + newBounds.right = (short) (x + width); + newBounds.bottom = (short) (y + height); + OS.SetControlBounds (control, newBounds); + if (visible) OS.InvalWindowRect (window, newBounds); + int result = 0; + if (move && !sameOrigin) { + if (events) sendEvent (SWT.Move); + result |= MOVED; + } + if (resize && !sameExtent) { + if (events) sendEvent (SWT.Move); + result |= RESIZED; + } + return result; +} + public void setData (Object data) { checkWidget(); this.data = data; } -/** - * Sets the application defined property of the receiver - * with the specified name to the given value. - * <p> - * Applications may associate arbitrary objects with the - * receiver in this fashion. If the objects stored in the - * properties need to be notified when the widget is disposed - * of, it is the application's responsibility to hook the - * Dispose event on the widget and do so. - * </p> - * - * @param key the name of the property - * @param value the new value for the property - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the key is null</li> - * </ul> - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - * - * @see #getData - */ public void setData (String key, Object value) { checkWidget(); if (key == null) error (SWT.ERROR_NULL_ARGUMENT); @@ -928,12 +809,120 @@ public void setData (String key, Object value) { values = newValues; } -/** - * Returns a string containing a concise, human-readable - * description of the receiver. - * - * @return a string representation of the receiver - */ +void setInputState (Event event, int theEvent) { + short [] button = new short [1]; + OS.GetEventParameter (theEvent, OS.kEventParamMouseButton, OS.typeMouseButton, null, 2, null, button); + int [] chord = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord); + int [] modifiers = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers); + setInputState (event, button [0], chord [0], modifiers [0]); +} + +void setInputState (Event event, short button, int chord, int modifiers) { + switch (button) { + case 1: event.button = 1; break; + case 2: event.button = 3; break; + case 3: event.button = 2; break; + } + if ((chord & 0x01) != 0) event.stateMask |= SWT.BUTTON1; + if ((chord & 0x02) != 0) event.stateMask |= SWT.BUTTON3; + if ((chord & 0x04) != 0) event.stateMask |= SWT.BUTTON2; + if ((modifiers & OS.optionKey) != 0) event.stateMask |= SWT.ALT; + if ((modifiers & OS.shiftKey) != 0) event.stateMask |= SWT.SHIFT; + if ((modifiers & OS.controlKey) != 0) event.stateMask |= SWT.CONTROL; + if ((modifiers & OS.cmdKey) != 0) event.stateMask |= SWT.COMMAND; + switch (event.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 != 0 || event.character != 0) return; + Display display = getDisplay (); + int lastModifiers = display.lastModifiers; + if ((modifiers & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) { + event.stateMask &= ~SWT.SHIFT; + event.keyCode = SWT.SHIFT; + return; + } + if ((modifiers & OS.controlKey) != 0 && (lastModifiers & OS.controlKey) == 0) { + event.stateMask &= ~SWT.CONTROL; + event.keyCode = SWT.CONTROL; + return; + } + if ((modifiers & OS.cmdKey) != 0 && (lastModifiers & OS.cmdKey) == 0) { + event.stateMask &= ~SWT.COMMAND; + event.keyCode = SWT.COMMAND; + return; + } + if ((modifiers & OS.optionKey) != 0 && (lastModifiers & OS.optionKey) == 0) { + event.stateMask &= ~SWT.ALT; + event.keyCode = SWT.ALT; + return; + } + break; + } + case SWT.KeyUp: { + if (event.keyCode != 0 || event.character != 0) return; + Display display = getDisplay (); + int lastModifiers = display.lastModifiers; + if ((modifiers & OS.shiftKey) == 0 && (lastModifiers & OS.shiftKey) != 0) { + event.stateMask |= SWT.SHIFT; + event.keyCode = SWT.SHIFT; + return; + } + if ((modifiers & OS.controlKey) == 0 && (lastModifiers & OS.controlKey) != 0) { + event.stateMask |= SWT.CONTROL; + event.keyCode = SWT.CONTROL; + return; + } + if ((modifiers & OS.cmdKey) == 0 && (lastModifiers & OS.cmdKey) != 0) { + event.stateMask |= SWT.COMMAND; + event.keyCode = SWT.COMMAND; + return; + } + if ((modifiers & OS.optionKey) != 0 && (lastModifiers & OS.optionKey) == 0) { + event.stateMask |= SWT.ALT; + event.keyCode = SWT.ALT; + return; + } + break; + } + } +} + +void setKeyState (Event event, int theEvent) { + int [] keyCode = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode); + event.keyCode = Display.translateKey (keyCode [0]); + switch (event.keyCode) { + case 0: + case SWT.BS: + case SWT.CR: + case SWT.DEL: + case SWT.ESC: + case SWT.TAB: { + byte [] charCode = new byte [1]; + OS.GetEventParameter (theEvent, OS.kEventParamKeyMacCharCodes, OS.typeChar, null, charCode.length, null, charCode); + event.character = (char) charCode [0]; + break; + } + case SWT.LF: + event.character = '\n'; + break; + } + setInputState (event, theEvent); +} + public String toString () { String string = "*Disposed*"; if (!isDisposed ()) { @@ -942,7 +931,25 @@ public String toString () { } return getName () + " {" + string + "}"; } -int topHandle () { - return handle; + +int trackingProc (int browser, int itemID, int property, int theRect, int startPt, int modifiers) { + /* Return one to indicate that the data browser should process the click */ + return 1; } + +int windowProc (int nextHandler, int theEvent, int userData) { + int eventKind = OS.GetEventKind (theEvent); + switch (eventKind) { + case OS.kEventWindowActivated: return kEventWindowActivated (nextHandler, theEvent, userData); + case OS.kEventWindowBoundsChanged: return kEventWindowBoundsChanged (nextHandler, theEvent, userData); + case OS.kEventWindowClose: return kEventWindowClose (nextHandler, theEvent, userData); + case OS.kEventWindowCollapsed: return kEventWindowCollapsed (nextHandler, theEvent, userData); + case OS.kEventWindowDeactivated: return kEventWindowDeactivated (nextHandler, theEvent, userData); + case OS.kEventWindowExpanded: return kEventWindowExpanded (nextHandler, theEvent, userData); + case OS.kEventWindowHidden: return kEventWindowHidden (nextHandler, theEvent, userData); + case OS.kEventWindowShown: return kEventWindowShown (nextHandler, theEvent, userData); + } + return OS.eventNotHandledErr; +} + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java index 20f514e91b..3b3e2664b1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java @@ -1,5 +1,7 @@ package org.eclipse.swt.widgets; +import org.eclipse.swt.internal.carbon.*; + /* * Copyright (c) 2000, 2002 IBM Corp. All rights reserved. * This file is made available under the terms of the Common Public License v1.0 @@ -7,23 +9,27 @@ package org.eclipse.swt.widgets; * http://www.eclipse.org/legal/cpl-v10.html */ -import org.eclipse.swt.internal.carbon.OS; - public class WidgetTable { static int FreeSlot = 0; static int GrowSize = 1024; static int [] IndexTable = new int [GrowSize]; static Widget [] WidgetTable = new Widget [GrowSize]; + static final int SWT0 = ('s'<<24) + ('w'<<16) + ('t'<<8) + '0'; + static int [] Property = new int [1]; 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; - int index = getUserData(handle) - 1; + Property [0] = 0; + OS.GetControlProperty (handle, SWT0, SWT0, 4, null, Property); + int index = Property [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) { @@ -39,40 +45,47 @@ public synchronized static void put (int handle, Widget widget) { IndexTable = newIndexTable; WidgetTable = newWidgetTable; } - setUserData(handle, FreeSlot + 1); + Property [0] = FreeSlot + 1; + OS.SetControlProperty (handle, SWT0, SWT0, 4, Property); int oldSlot = FreeSlot; FreeSlot = IndexTable [oldSlot]; IndexTable [oldSlot] = -2; WidgetTable [oldSlot] = widget; } + public static synchronized Widget remove (int handle) { if (handle == 0) return null; Widget widget = null; - int index= getUserData(handle) - 1; + Property [0] = 0; + OS.GetControlProperty (handle, SWT0, SWT0, 4, null, Property); + int index = Property [0] - 1; if (0 <= index && index < WidgetTable.length) { widget = WidgetTable [index]; WidgetTable [index] = null; IndexTable [index] = FreeSlot; FreeSlot = index; - setUserData(handle, 0); + OS.RemoveControlProperty (handle, SWT0, SWT0); + } return widget; } -public static synchronized Shell [] shells () { - int size= 0; - for (int i= 0; i < WidgetTable.length; i++) - if (WidgetTable[i] instanceof Shell) - size++; +public static synchronized Shell [] shells () { + int count = 0; + for (int i= 0; i < WidgetTable.length; i++) { + if (WidgetTable[i] instanceof Shell) count++; + } int index= 0; - Shell[] result= new Shell[size]; + Shell [] result = new Shell [count]; for (int i= 0; i < WidgetTable.length; i++) { - Widget widget= WidgetTable[i]; - if (widget instanceof Shell) + Widget widget = WidgetTable [i]; + if (widget != null && widget instanceof Shell) { result [index++]= (Shell) widget; + } } return result; } + public static synchronized int size () { int length = 0; for (int i=0; i<WidgetTable.length; i++) { @@ -80,38 +93,4 @@ public static synchronized int size () { } return length; } -///////////////////////////////////////////////// -// Mac stuff -///////////////////////////////////////////////// - - private static int getUserData(int handle) { - if (OS.IsValidControlHandle(handle)) - return OS.GetControlReference(handle); - if (OS.IsValidMenu(handle)) { - int[] refCon= new int[1]; - OS.GetMenuItemRefCon(handle, (short)0, refCon); - //System.out.println("refCon: " + refCon[0]); - return refCon[0]; - } - if (OS.IsValidWindowPtr(handle)) - return OS.GetWRefCon(handle); - //System.out.println("WidgetTable.getUserData: unknown handle type"); - return -1; - } - - private static void setUserData(int handle, int data) { - if (OS.IsValidControlHandle(handle)) { - OS.SetControlReference(handle, data); - return; - } - if (OS.IsValidMenu(handle)) { - OS.SetMenuItemRefCon(handle, (short)0, data); - return; - } - if (OS.IsValidWindowPtr(handle)) { - OS.SetWRefCon(handle, data); - return; - } - System.out.println("WidgetTable.setUserData: unknown handle type: " + handle); - } } |