MAC_2_1_1_from_head
diff --git a/bundles/org.eclipse.swt/.classpath_carbon b/bundles/org.eclipse.swt/.classpath_carbon
index 8a75b8e..9cc5682 100644
--- a/bundles/org.eclipse.swt/.classpath_carbon
+++ b/bundles/org.eclipse.swt/.classpath_carbon
@@ -6,7 +6,6 @@
<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/carbon2"/>
<classpathentry kind="src" path="Eclipse SWT PI/carbon"/>
<classpathentry kind="src" path="Eclipse SWT PI/common_j2se"/>
<classpathentry kind="src" path="Eclipse SWT Accessibility/common"/>
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 d819eda..bc791c9 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
@@ -57,7 +57,7 @@
* // 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++){
+ * for (int i = 0, length = myTypes.length; i < length; i++){
* byte[] buffer = myTypes[i].fileName.getBytes();
* writeOut.writeInt(buffer.length);
* writeOut.write(buffer);
@@ -115,23 +115,22 @@
* }
*/
public abstract class ByteArrayTransfer extends Transfer {
-
+
public TransferData[] getSupportedTypes() {
- int[] types= getTypeIds();
- TransferData[] data= new TransferData[types.length];
- for (int i= 0; i < types.length; i++) {
- data[i]= new TransferData();
- data[i].type= types[i];
+ int[] types = getTypeIds();
+ TransferData[] data = new TransferData[types.length];
+ for (int i = 0; i < types.length; i++) {
+ data[i] = new TransferData();
+ data[i].type = types[i];
}
return data;
}
public boolean isSupportedType(TransferData transferData){
if (transferData == null) return false;
- int[] types= getTypeIds();
- for (int i= 0; i < types.length; i++) {
- if (transferData.type == types[i])
- return true;
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ if (transferData.type == types[i]) return true;
}
return false;
}
@@ -148,14 +147,13 @@
* 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 = -1;
- return;
- }
+ transferData.result = -1;
+ if (object == null || !(object instanceof byte[]) || !isSupportedType(transferData)) return;
byte[] orig = (byte[])object;
- byte[] buffer= new byte[orig.length];
+ byte[] buffer = new byte[orig.length];
System.arraycopy(orig, 0, buffer, 0, orig.length);
- transferData.data = buffer;
+ transferData.data = new byte[1][];
+ transferData.data[0] = buffer;
transferData.result = 0;
}
@@ -172,8 +170,9 @@
* conversion was successful; otherwise null
*/
protected Object nativeToJava(TransferData transferData) {
- if (!isSupportedType(transferData)) return null;
- return transferData.data;
+ if (!isSupportedType(transferData) || transferData.data == null) return null;
+ if (transferData.data.length == 0 || transferData.data[0].length == 0) return null;
+ return transferData.data[0];
}
}
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 986e2c2..773408d 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
@@ -128,26 +128,26 @@
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];
- OS.GetCurrentScrap(scrapHandle);
- int scrap= scrapHandle[0];
-
- // Does Clipboard have data in required format?
+
+ int[] scrap = new int[1];
+ if (OS.GetCurrentScrap(scrap) != OS.noErr) return null;
int[] typeIds = transfer.getTypeIds();
- for (int i= 0; i < typeIds.length; i++) {
+ int[] size = new int[1];
+ // get data from system clipboard
+ for (int i=0; i<typeIds.length; i++) {
int type = typeIds[i];
- int[] size = new int[1];
- if (OS.GetScrapFlavorSize(scrap, type, size) == OS.noErr) {
- if (size[0] > 0) {
+ size[0] = 0;
+ if (OS.GetScrapFlavorSize(scrap[0], type, size) == OS.noErr && size[0] > 0) {
+ byte[] buffer = new byte[size[0]];
+ if (OS.GetScrapFlavorData(scrap[0], type, size, buffer) == OS.noErr) {
TransferData tdata = new TransferData();
tdata.type = type;
- tdata.data = new byte[size[0]];
- OS.GetScrapFlavorData(scrap, type, size, tdata.data);
+ tdata.data = new byte[1][];
+ tdata.data[0] = buffer;
return transfer.nativeToJava(tdata);
}
}
- }
+ }
return null; // No data available for this transfer
}
@@ -193,21 +193,27 @@
if (data == null || dataTypes == null || data.length != dataTypes.length) {
DND.error(SWT.ERROR_INVALID_ARGUMENT);
}
-
- OS.ClearCurrentScrap();
- int[] scrapHandle = new int[1];
- OS.GetCurrentScrap(scrapHandle);
- int scrap = scrapHandle[0];
+ if (OS.ClearCurrentScrap() != OS.noErr) {
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ }
+ int[] scrap = new int[1];
+ if (OS.GetCurrentScrap(scrap) != OS.noErr) {
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ }
// copy data directly over to System clipboard (not deferred)
- for (int i= 0; i < dataTypes.length; i++) {
- int[] ids = dataTypes[i].getTypeIds();
- for (int j= 0; j < ids.length; j++) {
+ for (int i=0; i<dataTypes.length; i++) {
+ int[] typeIds = dataTypes[i].getTypeIds();
+ for (int j=0; j<typeIds.length; j++) {
TransferData transferData = new TransferData();
- transferData.type = ids[j];
- dataTypes[i].javaToNative(data[i], transferData);
- if (transferData.result != OS.noErr)
+ transferData.type = typeIds[j];
+ dataTypes[i].javaToNative(data[i], transferData);
+ 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){
+ }
+ //Drag and Drop can handle multiple items in one transfer but the
+ //Clipboard can not.
+ byte[] datum = transferData.data[0];
+ if (OS.PutScrapFlavor(scrap[0], transferData.type, 0, datum.length, datum) != OS.noErr){
DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
}
}
@@ -228,25 +234,51 @@
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];
- OS.GetCurrentScrap(scrapHandle);
- 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];
+ int[] types = _getAvailableTypes();
+ String[] names = new String[types.length];
+ for (int i = 0; i < types.length; i++) {
+ int type = types[i];
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();
+ names[i] = sb.toString();
}
- return result;
+ return names;
+}
+
+/**
+ *
+ * @return array of TransferData
+ *
+ * @since 3.0
+ */
+//3.0 API
+//public TransferData[] getAvailableTypes() {
+// if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+// if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED);
+// int[] types = _getAvailableTypes();
+// TransferData[] result = new TransferData[types.length];
+// for (int i = 0; i < types.length; i++) {
+// result[i] = new TransferData();
+// result[i].type = types[i];
+// }
+// return result;
+//}
+
+private int[] _getAvailableTypes() {
+ int[] types = new int[0];
+ int[] scrap = new int[1];
+ if (OS.GetCurrentScrap(scrap) != OS.noErr) return types;
+ int[] count = new int[1];
+ if (OS.GetScrapFlavorCount(scrap[0], count) != OS.noErr || count[0] == 0) return types;
+ int[] info = new int[count[0] * 2];
+ if (OS.GetScrapFlavorInfoList(scrap[0], count, info) != OS.noErr) return types;
+ types = new int[count[0]];
+ for (int i= 0; i < count [0]; i++) {
+ types[i] = info[i*2];
+ }
+ return types;
}
}
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 a3a1cb2..49f4c0a 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
@@ -13,6 +13,9 @@
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.carbon.OS;
+import org.eclipse.swt.internal.carbon.EventRecord;
+import org.eclipse.swt.internal.carbon.Point;
/**
*
@@ -127,10 +130,11 @@
public DragSource(Control control, int style) {
super (control, checkStyle(style));
this.control = control;
- if (control.getData(DRAGSOURCEID) != null)
+ if (control.getData(DRAGSOURCEID) != null) {
DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+ }
control.setData(DRAGSOURCEID, this);
-
+
controlListener = new Listener () {
public void handleEvent (Event event) {
if (event.type == SWT.Dispose) {
@@ -140,7 +144,7 @@
}
if (event.type == SWT.DragDetect) {
if (!DragSource.this.isDisposed()) {
- //DragSource.this.drag(event);
+ DragSource.this.drag(event);
}
}
}
@@ -155,6 +159,11 @@
});
}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when a drag and drop operation is in progress, by sending
@@ -192,11 +201,6 @@
addListener (DND.DragEnd, typedListener);
}
-static int checkStyle (int style) {
- if (style == SWT.NONE) return DND.DROP_MOVE;
- return style;
-}
-
protected void checkSubclass () {
String name = getClass().getName ();
String validName = DragSource.class.getName();
@@ -205,6 +209,113 @@
}
}
+private void drag(Event dragEvent) {
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = dragEvent.time;
+ event.doit = true;
+ try {
+ notifyListeners(DND.DragStart, event);
+ } catch (Throwable e) {
+ return;
+ }
+ if (!event.doit || transferAgents == null || transferAgents.length == 0) return;
+
+ int[] theDrag = new int[1];
+ if (OS.NewDrag(theDrag) != OS.noErr) {
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.doit = false;
+ event.detail = DND.DROP_NONE;
+ try {
+ notifyListeners(DND.DragEnd, event);
+ } catch (Throwable e) {}
+ return;
+ }
+
+ Point pt = new Point();
+ OS.GetGlobalMouse (pt);
+
+ EventRecord theEvent = new EventRecord();
+ theEvent.message = OS.kEventMouseMoved;
+ theEvent.modifiers = (short)OS.GetCurrentEventKeyModifiers();
+ theEvent.what = OS.osEvt;
+ theEvent.where_h = (short)pt.h;
+ theEvent.where_v = (short)pt.v;
+
+ // Immediately get data for transfer. On other platforms, we wait
+ // until the data is requested, but on the mac, particularly in the case of files,
+ // we need to know how many items are being transferred when registering.
+ // The only way to know this is to get the data.
+ int index = 0;
+ for (int i = 0; i < transferAgents.length; i++) {
+ int[] types = transferAgents[i].getTypeIds();
+ for (int j = 0; j < types.length; j++) {
+ TransferData transferData = new TransferData();
+ transferData.type = types[j];
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.dataType = transferData;
+ try {
+ notifyListeners(DND.DragSetData, event);
+ } catch (Throwable e) {
+ continue;
+ }
+ if (event.data == null) continue;
+ transferAgents[i].javaToNative(event.data, transferData);
+ if (transferData.result != OS.noErr || transferData.data == null) continue;
+ for (int k = 0; k < transferData.data.length; k++) {
+ byte[] data = transferData.data[k];
+ OS.AddDragItemFlavor(theDrag[0], index++, types[j], data, data.length, 0);
+ }
+ }
+ }
+
+ if (index == 0) {
+ OS.DisposeDrag(theDrag[0]);
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.doit = false;
+ event.detail = DND.DROP_NONE;
+ try {
+ notifyListeners(DND.DragEnd, event);
+ } catch (Throwable e) {}
+ return;
+ }
+
+ int theRegion = OS.NewRgn();
+ OS.SetRectRgn(theRegion, (short)(pt.h-10), (short)(pt.v-10), (short)(pt.h+10), (short)(pt.v+10));
+
+ int operations = opToOsOp(getStyle());
+ //set operations twice - local and not local
+ OS.SetDragAllowableActions(theDrag[0], operations, true);
+ OS.SetDragAllowableActions(theDrag[0], operations, false);
+
+ int result = OS.TrackDrag(theDrag[0], theEvent, theRegion);
+
+ int operation = DND.DROP_NONE;
+ if (result == OS.noErr) {
+ int[] outAction = new int[1];
+ OS.GetDragDropAction(theDrag[0], outAction);
+ operation = osOpToOp(outAction[0]);
+ }
+
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.doit = result == OS.noErr;
+ event.detail = operation;
+ try {
+ notifyListeners(DND.DragEnd, event);
+ } catch (Throwable e) {}
+
+ OS.DisposeRgn(theRegion);
+ OS.DisposeDrag(theDrag[0]);
+}
+
/**
* Returns the Control which is registered for this DragSource. This is the control that the
* user clicks in to initiate dragging.
@@ -214,10 +325,7 @@
public Control getControl () {
return control;
}
-public Display getDisplay () {
- 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.
*
@@ -240,6 +348,37 @@
transferAgents = null;
}
+private int opToOsOp(int operation) {
+ int osOperation = 0;
+ if ((operation & DND.DROP_COPY) != 0){
+ osOperation |= OS.kDragActionCopy;
+ }
+ if ((operation & DND.DROP_LINK) != 0) {
+ osOperation |= OS.kDragActionAlias;
+ }
+ if ((operation & DND.DROP_MOVE) != 0) {
+ osOperation |= OS.kDragActionDelete;
+ }
+ return osOperation;
+}
+
+private int osOpToOp(int osOperation){
+ int operation = 0;
+ if ((osOperation & OS.kDragActionCopy) != 0){
+ operation |= DND.DROP_COPY;
+ }
+ if ((osOperation & OS.kDragActionAlias) != 0) {
+ operation |= DND.DROP_LINK;
+ }
+ if ((osOperation & OS.kDragActionDelete) != 0) {
+ operation |= DND.DROP_MOVE;
+ }
+ if (osOperation == OS.kDragActionAll) {
+ operation = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ }
+ return operation;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when a drag and drop operation is in progress.
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 31e5630..d82ca86 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
@@ -13,6 +13,8 @@
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.carbon.*;
/**
*
@@ -67,13 +69,40 @@
*/
public class DropTarget extends Widget {
- // info for registering as a droptarget
private Control control;
private Listener controlListener;
private Transfer[] transferAgents = new Transfer[0];
-// private DragUnderEffect effect;
+ private DragUnderEffect effect;
+ // Track application selections
+ private TransferData selectedDataType;
+ private int selectedOperation;
+
+ // workaround - There is no event for "operation changed" so track operation based on key state
+ private int keyOperation = -1;
+
+ // workaround - Simulate events when mouse is not moving
+ private long dragOverStart;
+ private Runnable dragOverHeartbeat;
+ private DNDEvent dragOverEvent;
+
+ // workaround - OS events are relative to the application, not the control.
+ // Track which control is the current target to determine when drag and
+ // drop enters or leaves a widget.
+ private static DropTarget CurrentDropTarget = null;
+
private static final String DROPTARGETID = "DropTarget"; //$NON-NLS-1$
+ private static final int DRAGOVER_HYSTERESIS = 50;
+
+ private static Callback DragTrackingHandler;
+ private static Callback DragReceiveHandler;
+
+ static {
+ DragTrackingHandler = new Callback(DropTarget.class, "DragTrackingHandler", 4); //$NON-NLS-1$
+ DragReceiveHandler = new Callback(DropTarget.class, "DragReceiveHandler", 3); //$NON-NLS-1$
+ OS.InstallTrackingHandler(DragTrackingHandler.getAddress(), 0, null);
+ OS.InstallReceiveHandler(DragReceiveHandler.getAddress(), 0, null);
+ }
/**
* Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
@@ -105,8 +134,12 @@
public DropTarget(Control control, int style) {
super(control, checkStyle(style));
this.control = control;
- if (control.getData(DROPTARGETID) != null)
+ if (DragTrackingHandler == null || DragTrackingHandler == null) {
DND.error(DND.ERROR_CANNOT_INIT_DROP);
+ }
+ if (control.getData(DROPTARGETID) != null) {
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+ }
control.setData(DROPTARGETID, this);
controlListener = new Listener () {
@@ -123,16 +156,120 @@
onDispose();
}
});
+
+ // Drag under effect
+ if (control instanceof Tree) {
+ effect = new TreeDragUnderEffect((Tree)control);
+ } else if (control instanceof Table) {
+ effect = new TableDragUnderEffect((Table)control);
+ } else {
+ effect = new NoDragUnderEffect(control);
+ }
-// if (control instanceof Tree) {
-// effect = new TreeDragUnderEffect((Tree)control);
-// } else if (control instanceof Table) {
-// effect = new TableDragUnderEffect((Table)control);
-// } else {
-// effect = new NoDragUnderEffect(control);
-// }
+ dragOverHeartbeat = new Runnable() {
+ public void run() {
+ if (DropTarget.this.control.isDisposed() || dragOverStart == 0) return;
+ long time = System.currentTimeMillis();
+ int delay = DRAGOVER_HYSTERESIS;
+ if (time < dragOverStart) {
+ delay = (int)(dragOverStart - time);
+ } else {
+ int allowedOperations = dragOverEvent.operations;
+ TransferData[] allowedTypes = dragOverEvent.dataTypes;
+ //pass a copy of data types in to listeners in case application modifies it
+ TransferData[] dataTypes = new TransferData[allowedTypes.length];
+ System.arraycopy(allowedTypes, 0, dataTypes, 0, dataTypes.length);
+
+ DNDEvent event = new DNDEvent();
+ event.widget = dragOverEvent.widget;
+ event.x = dragOverEvent.x;
+ event.y = dragOverEvent.y;
+ event.time = (int)time;
+ event.feedback = DND.FEEDBACK_SELECT;
+ event.dataTypes = dataTypes;
+ event.dataType = selectedDataType;
+ event.operations = dragOverEvent.operations;
+ event.detail = selectedOperation;
+
+ try {
+ notifyListeners(DND.DragOver, event);
+ } catch (Throwable e) {
+ event.dataType = null;
+ event.detail = DND.DROP_NONE;
+ }
+
+ effect.show(event.feedback, event.x, event.y);
+
+ selectedDataType = null;
+ if (event.dataType != null) {
+ for (int i = 0; i < allowedTypes.length; i++) {
+ if (allowedTypes[i].type == event.dataType.type) {
+ selectedDataType = event.dataType;
+ break;
+ }
+ }
+ }
+
+ selectedOperation = DND.DROP_NONE;
+ if (selectedDataType != null && (event.detail & allowedOperations) != 0) {
+ selectedOperation = event.detail;
+ }
+ }
+ DropTarget.this.control.getDisplay().timerExec(delay, dragOverHeartbeat);
+ }
+ };
}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
+private static int DragReceiveHandler(int theWindow, int handlerRefCon, int theDrag) {
+ DropTarget target = FindDropTarget(theWindow, theDrag);
+ if (target == null) return OS.noErr;
+ return target.dragReceiveHandler(theWindow, handlerRefCon, theDrag);
+}
+
+private static int DragTrackingHandler(int message, int theWindow, int handlerRefCon, int theDrag) {
+ if (message == OS.kDragTrackingLeaveHandler || message == OS.kDragTrackingEnterHandler) {
+ CurrentDropTarget = null;
+ return OS.noErr;
+ }
+ DropTarget target = FindDropTarget(theWindow, theDrag);
+ if (CurrentDropTarget != null) {
+ if (target == null || CurrentDropTarget.control.handle != target.control.handle) {
+ CurrentDropTarget.dragTrackingHandler(OS.kDragTrackingLeaveWindow, theWindow, handlerRefCon, theDrag);
+ CurrentDropTarget = target;
+ message = OS.kDragTrackingEnterWindow;
+ }
+ } else {
+ CurrentDropTarget = target;
+ message = OS.kDragTrackingEnterWindow;
+ }
+ if (target == null) return OS.noErr;
+ return target.dragTrackingHandler(message, theWindow, handlerRefCon, theDrag);
+}
+
+private static DropTarget FindDropTarget(int theWindow, int theDrag) {
+ Display display = Display.findDisplay(Thread.currentThread());
+ if (display == null || display.isDisposed()) return null;
+ Point mouse = new Point();
+ OS.GetDragMouse(theDrag, mouse, null);
+ int[] theRoot = new int[1];
+ OS.GetRootControl(theWindow, theRoot);
+ int[] theControl = new int[1];
+ Rect rect = new Rect();
+ OS.GetWindowBounds (theWindow, (short) OS.kWindowContentRgn, rect);
+ CGPoint inPoint = new CGPoint();
+ inPoint.x = mouse.h - rect.left;
+ inPoint.y = mouse.v - rect.top;
+ OS.HIViewGetSubviewHit(theRoot[0], inPoint, true, theControl);
+ if (!OS.IsControlEnabled(theControl[0])) return null;
+ Widget widget = display.findWidget(theControl[0]);
+ if (widget == null) return null;
+ return (DropTarget)widget.getData(DROPTARGETID);
+}
/**
* Adds the listener to the collection of listeners who will
* be notified when a drag and drop operation is in progress, by sending
@@ -176,11 +313,6 @@
addListener (DND.DropAccept, typedListener);
}
-static int checkStyle (int style) {
- if (style == SWT.NONE) return DND.DROP_MOVE;
- return style;
-}
-
protected void checkSubclass () {
String name = getClass().getName ();
String validName = DropTarget.class.getName();
@@ -189,6 +321,215 @@
}
}
+private int dragReceiveHandler(int theWindow, int handlerRefCon, int theDrag) {
+ updateDragOverHover(0, null);
+ effect.show(DND.FEEDBACK_NONE, 0, 0);
+
+ if (keyOperation == -1) return OS.dragNotAcceptedErr;
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.detail = DND.DROP_NONE;
+ try {
+ notifyListeners(DND.DragLeave, event);
+ } catch (Throwable e) {}
+
+ event = new DNDEvent();
+ if (!setEventData(theDrag, event)) {
+ return OS.dragNotAcceptedErr;
+ }
+ keyOperation = -1;
+
+ int allowedOperations = event.operations;
+ TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+ System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, event.dataTypes.length);
+
+ event.dataType = selectedDataType;
+ event.detail = selectedOperation;
+ try {
+ notifyListeners(DND.DropAccept, event);
+ } catch (Throwable e) {
+ event.detail = DND.DROP_NONE;
+ event.dataType = null;
+ }
+
+ selectedDataType = null;
+ if (event.dataType != null) {
+ for (int i = 0; i < allowedDataTypes.length; i++) {
+ if (allowedDataTypes[i].type == event.dataType.type) {
+ selectedDataType = allowedDataTypes[i];
+ break;
+ }
+ }
+ }
+
+ selectedOperation = DND.DROP_NONE;
+ if (selectedDataType != null && (event.detail & allowedOperations) != 0) {
+ selectedOperation = event.detail;
+ }
+
+ if (selectedOperation == DND.DROP_NONE) {
+ // this was not a successful drop
+ return OS.dragNotAcceptedErr;
+ }
+
+ // ask drag source for dropped data
+ byte[][] data = data = new byte[0][];
+ // locate all the items with data of the desired type
+ short[] numItems = new short[1];
+ OS.CountDragItems(theDrag, numItems);
+ for (short i = 0; i < numItems[0]; i++) {
+ int[] theItemRef = new int[1];
+ OS.GetDragItemReferenceNumber(theDrag, (short) (i+1), theItemRef);
+ int[] size = new int[1];
+ OS.GetFlavorDataSize(theDrag, theItemRef[0], selectedDataType.type, size);
+ if (size[0] > 0) {
+ byte[] buffer = new byte[size[0]];
+ OS.GetFlavorData(theDrag, theItemRef[0], selectedDataType.type, buffer, size, 0);
+ byte[][] newData = new byte[data.length + 1][];
+ System.arraycopy(data, 0, newData, 0, data.length);
+ newData[data.length] = buffer;
+ data = newData;
+ }
+ }
+ // Get Data in a Java format
+ Object object = null;
+ for (int i = 0; i < transferAgents.length; i++) {
+ Transfer transfer = transferAgents[i];
+ if (transfer.isSupportedType(selectedDataType)) {
+ selectedDataType.data = data;
+ object = transfer.nativeToJava(selectedDataType);
+ break;
+ }
+ }
+
+ if (object == null) {
+ selectedOperation = DND.DROP_NONE;
+ }
+
+ event.dataType = selectedDataType;
+ event.detail = selectedOperation;
+ event.data = object;
+ try {
+ notifyListeners(DND.Drop, event);
+ selectedOperation = DND.DROP_NONE;
+ if ((allowedOperations & event.detail) == event.detail) {
+ selectedOperation = event.detail;
+ }
+ } catch (Throwable e) {
+ selectedOperation = DND.DROP_NONE;
+ }
+
+ //notify source of action taken
+ int action = opToOsOp(selectedOperation);
+ OS.SetDragDropAction(theDrag, action);
+ return (selectedOperation == DND.DROP_NONE) ? OS.dragNotAcceptedErr : OS.noErr;
+}
+
+private int dragTrackingHandler(int message, int theWindow, int handlerRefCon, int theDrag) {
+
+ if (message == OS.kDragTrackingLeaveWindow) {
+ updateDragOverHover(0, null);
+ effect.show(DND.FEEDBACK_NONE, 0, 0);
+ OS.SetThemeCursor(OS.kThemeArrowCursor);
+ if (keyOperation == -1) return OS.dragNotAcceptedErr;
+ keyOperation = -1;
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = (int)System.currentTimeMillis();
+ event.detail = DND.DROP_NONE;
+ try {
+ notifyListeners(DND.DragLeave, event);
+ } catch (Throwable e) {}
+ return OS.noErr;
+ }
+
+ int oldKeyOperation = keyOperation;
+
+ if (message == OS.kDragTrackingEnterWindow) {
+ selectedDataType = null;
+ selectedOperation = 0;
+ }
+
+ DNDEvent event = new DNDEvent();
+ if (!setEventData(theDrag, event)) {
+ keyOperation = -1;
+ OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+ return OS.dragNotAcceptedErr;
+ }
+
+ int allowedOperations = event.operations;
+ TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+ System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, allowedDataTypes.length);
+
+ switch (message) {
+ case OS.kDragTrackingEnterWindow:
+ event.type = DND.DragEnter;
+ break;
+ case OS.kDragTrackingInWindow:
+ if (keyOperation == oldKeyOperation) {
+ event.type = DND.DragOver;
+ event.dataType = selectedDataType;
+ event.detail = selectedOperation;
+ }else {
+ event.type = DND.DragOperationChanged;
+ event.dataType = selectedDataType;
+ }
+ break;
+ }
+
+ updateDragOverHover(DRAGOVER_HYSTERESIS, event);
+
+ try {
+ notifyListeners(event.type, event);
+ } catch (Throwable e) {
+ OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+ return OS.dragNotAcceptedErr;
+ }
+
+ if (event.detail == DND.DROP_DEFAULT) {
+ event.detail = (allowedOperations & DND.DROP_MOVE) != 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+ }
+
+ selectedDataType = null;
+ if (event.dataType != null) {
+ for (int i = 0; i < allowedDataTypes.length; i++) {
+ if (allowedDataTypes[i].type == event.dataType.type) {
+ selectedDataType = allowedDataTypes[i];
+ break;
+ }
+ }
+ }
+
+ selectedOperation = DND.DROP_NONE;
+ if (selectedDataType != null && (allowedOperations & event.detail) != 0) {
+ selectedOperation = event.detail;
+ }
+
+ effect.show(event.feedback, event.x, event.y);
+
+ switch (selectedOperation) {
+ case DND.DROP_COPY:
+ OS.SetThemeCursor(OS.kThemeCopyArrowCursor);
+ break;
+ case DND.DROP_LINK:
+ OS.SetThemeCursor(OS.kThemeAliasArrowCursor);
+ break;
+ case DND.DROP_MOVE:
+ OS.SetThemeCursor(OS.kThemeArrowCursor);
+ break;
+ default:
+ OS.SetThemeCursor(OS.kThemeNotAllowedCursor);
+ }
+
+ if (message == OS.kDragTrackingEnterWindow) {
+ dragOverHeartbeat.run();
+ }
+ return OS.noErr;
+}
+
/**
* Returns the Control which is registered for this DropTarget. This is the control over which the
* user positions the cursor to drop the data.
@@ -199,9 +540,15 @@
return control;
}
-public Display getDisplay () {
- if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
- return control.getDisplay ();
+private int getOperationFromKeyState(int theDrag) {
+ short[] modifiers = new short[1];
+ OS.GetDragModifiers(theDrag, modifiers, null, null);
+ boolean option = (modifiers[0] & OS.optionKey) == OS.optionKey;
+ boolean command = (modifiers[0] & OS.cmdKey) == OS.cmdKey;
+ if (option && command) return DND.DROP_LINK;
+ if (option) return DND.DROP_COPY;
+ if (command) return DND.DROP_MOVE;
+ return DND.DROP_DEFAULT;
}
/**
@@ -224,6 +571,37 @@
control = null;
}
+private int opToOsOp(int operation) {
+ int osOperation = 0;
+ if ((operation & DND.DROP_COPY) != 0){
+ osOperation |= OS.kDragActionCopy;
+ }
+ if ((operation & DND.DROP_LINK) != 0) {
+ osOperation |= OS.kDragActionAlias;
+ }
+ if ((operation & DND.DROP_MOVE) != 0) {
+ osOperation |= OS.kDragActionDelete;
+ }
+ return osOperation;
+}
+
+private int osOpToOp(int osOperation){
+ int operation = 0;
+ if ((osOperation & OS.kDragActionCopy) != 0){
+ operation |= DND.DROP_COPY;
+ }
+ if ((osOperation & OS.kDragActionAlias) != 0) {
+ operation |= DND.DROP_LINK;
+ }
+ if ((osOperation & OS.kDragActionDelete) != 0) {
+ operation |= DND.DROP_MOVE;
+ }
+ if (osOperation == OS.kDragActionAll) {
+ operation = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ }
+ return operation;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when a drag and drop operation is in progress.
@@ -251,6 +629,100 @@
removeListener (DND.DropAccept, listener);
}
+private boolean setEventData(int theDrag, DNDEvent event) {
+ if (theDrag == 0) return false;
+
+ // get allowed operations
+ int style = getStyle();
+ int[] outActions = new int[1];
+ OS.GetDragAllowableActions(theDrag, outActions);
+ int operations = osOpToOp(outActions[0]) & style;
+ if (operations == DND.DROP_NONE) return false;
+
+ //get current operation
+ int operation = getOperationFromKeyState(theDrag);
+ keyOperation = operation;
+ if (operation == DND.DROP_DEFAULT) {
+ if ((style & DND.DROP_DEFAULT) == 0) {
+ operation = (operations & DND.DROP_MOVE) != 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+ }
+ } else {
+ if ((operation & operations) == 0) operation = DND.DROP_NONE;
+ }
+
+ // get allowed transfer types
+ short[] numItems = new short[1];
+ OS.CountDragItems(theDrag, numItems);
+ int[] flavors = new int[10];
+ int index = -1;
+ //Get a unique list of flavors
+ for (short i = 0; i < numItems[0]; i++) {
+ int[] theItemRef = new int[1];
+ OS.GetDragItemReferenceNumber(theDrag, (short) (i+1), theItemRef);
+ short[] numFlavors = new short[1];
+ OS.CountDragItemFlavors(theDrag, theItemRef[0], numFlavors);
+ int[] theType = new int[1];
+ for (int j = 0; j < numFlavors.length; j++) {
+ theType[0] = 0;
+ if (OS.GetFlavorType(theDrag, theItemRef[0], (short) (j+1), theType) == OS.noErr) {
+ boolean unique = true;
+ for (int k = 0; k < flavors.length; k++) {
+ if (flavors[k] == theType[0]) {
+ unique = false;
+ break;
+ }
+ }
+ if (unique) {
+ if (index == flavors.length - 1) {
+ int[] temp = new int[flavors.length + 10];
+ System.arraycopy(flavors, 0, temp, 0, flavors.length);
+ flavors = temp;
+ }
+ flavors[++index] = theType[0];
+ }
+ }
+ }
+ }
+ if (index == -1) return false;
+
+ TransferData[] dataTypes = new TransferData[index+1];
+ index = -1;
+ for (int i = 0; i < dataTypes.length; i++) {
+ if (flavors[i] != 0) {
+ TransferData data = new TransferData();
+ data.type = flavors[i];
+ for (int j = 0; j < transferAgents.length; j++) {
+ if (transferAgents[j].isSupportedType(data)) {
+ dataTypes[++index] = data;
+ break;
+ }
+ }
+ }
+ }
+ if (index == -1) return false;
+
+ if (index < dataTypes.length - 1) {
+ TransferData[] temp = new TransferData[index + 1];
+ System.arraycopy(dataTypes, 0, temp, 0, index + 1);
+ dataTypes = temp;
+ }
+
+ Point mouse = new Point();
+ OS.GetDragMouse(theDrag, mouse, null);
+
+ event.widget = this;
+ event.x = mouse.h;
+ event.y = mouse.v;
+ event.time = (int)System.currentTimeMillis();
+ event.feedback = DND.FEEDBACK_SELECT;
+ event.dataTypes = dataTypes;
+ event.dataType = dataTypes[0];
+ event.operations = operations;
+ event.detail = operation;
+
+ return true;
+}
+
/**
* Specifies the data types that can be transferred to this DropTarget. If data is
* being dragged that does not match one of these types, the drop target will be notified of
@@ -269,4 +741,20 @@
this.transferAgents = transferAgents;
}
+private void updateDragOverHover(long delay, DNDEvent event) {
+ if (delay == 0) {
+ dragOverStart = 0;
+ dragOverEvent = null;
+ return;
+ }
+ dragOverStart = System.currentTimeMillis() + delay;
+ if (dragOverEvent == null) dragOverEvent = new DNDEvent();
+ dragOverEvent.x = event.x;
+ dragOverEvent.y = event.y;
+ dragOverEvent.dataTypes = event.dataTypes;
+ dragOverEvent.operations = event.operations;
+ dragOverEvent.dataType = event.dataType;
+ dragOverEvent.detail = event.detail;
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/FileTransfer.java
index d790ed9..b538b80 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/FileTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/FileTransfer.java
@@ -10,8 +10,8 @@
*******************************************************************************/
package org.eclipse.swt.dnd;
-
-import org.eclipse.swt.internal.Converter;
+import java.io.*;
+import org.eclipse.swt.internal.carbon.*;
/**
* The class <code>FileTransfer</code> provides a platform specific mechanism
@@ -35,10 +35,16 @@
public class FileTransfer extends ByteArrayTransfer {
private static FileTransfer _instance = new FileTransfer();
- private static final String TYPENAME = "text/uri-list";
- private static final int TYPEID = registerType(TYPENAME);
+ //the text/uri-list is used only for transfers within the same application
+ private static final String URILIST = "text/uri-list";
+ private static final String HFS = "hfs ";
+ private static final int URILISTID = registerType(URILIST);
+ private static final int HFSID = registerType(HFS);
+ private static final String URILIST_PREFIX = "file:";
+ private static final String URILIST_SEPARATOR = "\r";
private FileTransfer() {}
+
/**
* Returns the singleton instance of the FileTransfer class.
*
@@ -47,6 +53,7 @@
public static FileTransfer getInstance () {
return _instance;
}
+
/**
* This implementation of <code>javaToNative</code> converts a list of file names
* represented by a java <code>String[]</code> to a platform specific representation.
@@ -60,18 +67,62 @@
* 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;
- // build a byte array from data
+ transferData.result = -1;
+ if (object == null || !(object instanceof String[]) || !isSupportedType(transferData)) return;
String[] files = (String[])object;
-
- // create a string separated by "new lines" to represent list of files
- String nativeFormat = "";
- for (int i = 0, length = files.length; i < length; i++){
- nativeFormat += "file:"+files[i]+"\r";
+ if (files.length == 0) return;
+
+ if (transferData.type == URILISTID) {
+ // create a string separated by "new lines" to represent list of files
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0, length = files.length; i < length; i++){
+ sb.append(URILIST_PREFIX);
+ sb.append(files[i]);
+ sb.append(URILIST_SEPARATOR);
+ }
+ String str = sb.toString();
+ char[] chars = new char[str.length()];
+ str.getChars (0, chars.length, chars, 0);
+ byte[] buffer = new byte[chars.length * 2];
+ OS.memcpy(buffer, chars, buffer.length);
+ transferData.data = new byte[1][];
+ transferData.data[0] = buffer;
+ transferData.result = 0;
}
- byte[] buffer = Converter.wcsToMbcs(null, nativeFormat, true);
- // pass byte array on to super to convert to native
- super.javaToNative(buffer, transferData);
+ if (transferData.type == HFSID) {
+ byte[][] data = new byte[files.length][];
+ for (int i = 0; i < data.length; i++) {
+ File file = new File(files[i]);
+ boolean isDirectory = file.isDirectory();
+ String fileName = files[i];
+ char [] chars = new char [fileName.length ()];
+ fileName.getChars (0, chars.length, chars, 0);
+ int cfstring = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, chars, chars.length);
+ if (cfstring == 0) return;
+ try {
+ int url = OS.CFURLCreateWithFileSystemPath(OS.kCFAllocatorDefault, cfstring, OS.kCFURLPOSIXPathStyle, isDirectory);
+ if (url == 0) return;
+ try {
+ byte[] fsRef = new byte[80];
+ if (!OS.CFURLGetFSRef(url, fsRef)) return;
+ byte[] fsSpec = new byte[70];
+ if (OS.FSGetCatalogInfo(fsRef, 0, null, null, fsSpec, null) != OS.noErr) return;
+ byte[] hfsflavor = new byte[10 + fsSpec.length];
+ byte[] finfo = new byte[16];
+ OS.FSpGetFInfo(fsSpec, finfo);
+ System.arraycopy(finfo, 0, hfsflavor, 0, 10);
+ System.arraycopy(fsSpec, 0, hfsflavor, 10, fsSpec.length);
+ data[i] = hfsflavor;
+ } finally {
+ OS.CFRelease(url);
+ }
+ } finally {
+ OS.CFRelease(cfstring);
+ }
+ }
+ transferData.data = data;
+ transferData.result = 0;
+ }
}
/**
* This implementation of <code>nativeToJava</code> converts a platform specific
@@ -85,36 +136,73 @@
* conversion was successful; otherwise null
*/
public Object nativeToJava(TransferData transferData) {
-
- byte[] data = (byte[])super.nativeToJava(transferData);
- if (data == null) return null;
- char[] unicode = Converter.mbcsToWcs(null, data);
- String string = new String(unicode);
- // parse data and convert string to array of files
- int start = string.indexOf("file:");
- if (start == -1) return null;
- start += 5;
- String[] fileNames = new String[0];
- while (start < string.length()) {
- int end = string.indexOf("\r", start);
- if (end == -1) end = string.length() - 1;
- String fileName = string.substring(start, end);
-
- String[] newFileNames = new String[fileNames.length + 1];
- System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
- newFileNames[fileNames.length] = fileName;
- fileNames = newFileNames;
-
- start = string.indexOf("file:", end);
- if (start == -1) break;
- start += 5;
+ if (!isSupportedType(transferData) || transferData.data == null) return null;
+ if (transferData.data.length == 0) return null;
+
+ if (transferData.type == URILISTID) {
+ byte[] data = transferData.data[0];
+ if (data.length == 0) return null;
+ char[] chars = new char[(data.length + 1) / 2];
+ OS.memcpy(chars, data, data.length);
+ String str = new String(chars);
+ int start = str.indexOf(URILIST_PREFIX);
+ if (start == -1) return null;
+ start += URILIST_PREFIX.length();
+ String[] fileNames = new String[0];
+ while (start < str.length()) {
+ int end = str.indexOf(URILIST_SEPARATOR, start);
+ if (end == -1) end = str.length() - 1;
+ String fileName = str.substring(start, end);
+ String[] newFileNames = new String[fileNames.length + 1];
+ System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+ newFileNames[fileNames.length] = fileName;
+ fileNames = newFileNames;
+ start = str.indexOf(URILIST_PREFIX, end);
+ if (start == -1) break;
+ start += URILIST_PREFIX.length();
+ }
+ return fileNames;
}
- return fileNames;
+ if (transferData.type == HFSID) {
+ int count = transferData.data.length;
+ String[] fileNames = new String[count];
+ for (int i=0; i<count; i++) {
+ byte[] data = transferData.data[i];
+ byte[] fsspec = new byte[data.length - 10];
+ System.arraycopy(data, 10, fsspec, 0, fsspec.length);
+ byte[] fsRef = new byte[80];
+ if (OS.FSpMakeFSRef(fsspec, fsRef) != OS.noErr) return null;
+ int url = OS.CFURLCreateFromFSRef(OS.kCFAllocatorDefault, fsRef);
+ if (url == 0) return null;
+ try {
+ int path = OS.CFURLCopyFileSystemPath(url, OS.kCFURLPOSIXPathStyle);
+ if (path == 0) return null;
+ try {
+ int length = OS.CFStringGetLength(path);
+ if (length == 0) return null;
+ char[] buffer= new char[length];
+ CFRange range = new CFRange();
+ range.length = length;
+ OS.CFStringGetCharacters(path, range, buffer);
+ fileNames[i] = new String(buffer);
+ } finally {
+ OS.CFRelease(path);
+ }
+ } finally {
+ OS.CFRelease(url);
+ }
+ }
+ return fileNames;
+ }
+ return null;
}
-protected String[] getTypeNames(){
- return new String[] { TYPENAME };
-}
+
protected int[] getTypeIds(){
- return new int[] { TYPEID };
+ return new int[] {URILISTID, HFSID};
}
+
+protected String[] getTypeNames(){
+ return new String[] {URILIST, HFS};
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/RTFTransfer.java
index 13289cd..d77cacb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/RTFTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/RTFTransfer.java
@@ -9,10 +9,10 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.carbon.OS;
+import org.eclipse.swt.internal.carbon.CFRange;
-
- import org.eclipse.swt.internal.Converter;
-
/**
* The class <code>RTFTransfer</code> provides a platform specific mechanism
* for converting text in RTF format represented as a java <code>String</code>
@@ -29,11 +29,10 @@
public class RTFTransfer extends ByteArrayTransfer {
private static RTFTransfer _instance = new RTFTransfer();
- private static final String TYPENAME1 = "RTF";
- private static final int TYPEID1 = ('R'<<24) + ('T'<<16) + ('F'<<8) + ' ';
+ private static final String RTF = "RTF ";
+ private static final int RTFID = registerType(RTF);
-private RTFTransfer() {
-}
+private RTFTransfer() {}
/**
* Returns the singleton instance of the RTFTransfer class.
@@ -54,9 +53,31 @@
* 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;
- byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
- super.javaToNative(buffer, transferData);
+ transferData.result = -1;
+ if (object == null || !(object instanceof String) || !isSupportedType(transferData)) return;
+ String string = (String)object;
+ int count = string.length();
+ if (count == 0) return;
+ char[] chars = new char[count];
+ string.getChars(0, count, chars, 0);
+ int cfstring = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, count);
+ if (cfstring == 0) return;
+ try {
+ CFRange range = new CFRange();
+ range.length = chars.length;
+ int encoding = OS.CFStringGetSystemEncoding();
+ int[] size = new int[1];
+ int numChars = OS.CFStringGetBytes(cfstring, range, encoding, (byte)'?', true, null, 0, size);
+ if (numChars == 0 || size[0] == 0) return;
+ byte[] buffer = new byte[size[0]];
+ numChars = OS.CFStringGetBytes(cfstring, range, encoding, (byte)'?', true, buffer, size [0], size);
+ if (numChars == 0) return;
+ transferData.data = new byte[1][];
+ transferData.data[0] = buffer;
+ transferData.result = 0;
+ } finally {
+ OS.CFRelease(cfstring);
+ }
}
/**
@@ -70,21 +91,31 @@
* conversion was successful; otherwise null
*/
public Object nativeToJava(TransferData transferData){
- // get byte array from super
- byte[] buffer = (byte[])super.nativeToJava(transferData);
- if (buffer == null) return null;
- // convert byte array to a string
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- String string = new String (unicode);
- int end = string.indexOf('\0');
- return (end == -1) ? string : string.substring(0, end);
-}
-
-protected String[] getTypeNames() {
- return new String[]{ TYPENAME1 };
+ if (!isSupportedType(transferData) || transferData.data == null) return null;
+ if (transferData.data.length == 0 || transferData.data[0].length == 0) return null;
+ byte[] buffer = transferData.data[0];
+ int encoding = OS.CFStringGetSystemEncoding();
+ int cfstring = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
+ if (cfstring == 0) return null;
+ try {
+ int length = OS.CFStringGetLength(cfstring);
+ if (length == 0) return null;
+ char[] chars = new char[length];
+ CFRange range = new CFRange();
+ range.length = length;
+ OS.CFStringGetCharacters(cfstring, range, chars);
+ return new String(chars);
+ } finally {
+ OS.CFRelease(cfstring);
+ }
}
protected int[] getTypeIds() {
- return new int[] { TYPEID1 };
+ return new int[] {RTFID};
}
+
+protected String[] getTypeNames() {
+ return new String[] {RTF};
}
+
+}
\ 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 17c679b..f3d70ba 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
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.dnd;
-
-import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.carbon.CFRange;
import org.eclipse.swt.internal.carbon.OS;
/**
@@ -30,11 +29,13 @@
public class TextTransfer extends ByteArrayTransfer {
private static TextTransfer _instance = new TextTransfer();
- private static final String TYPENAME1 = "TEXT";
- private static final int TYPEID1 = OS.kScrapFlavorTypeText;
+ private static final String TEXT = "TEXT";
+ private static final String UTEXT = "utxt";
+ private static final int TEXTID = OS.kScrapFlavorTypeText;
+ private static final int UTEXTID = OS.kScrapFlavorTypeUnicode;
-private TextTransfer() {
-}
+private TextTransfer() {}
+
/**
* Returns the singleton instance of the TextTransfer class.
*
@@ -53,13 +54,46 @@
* @param transferData an empty <code>TransferData</code> object; this
* 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)) {
- transferData.result = -1;
- return;
- }
- byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
- super.javaToNative(buffer, transferData);
+public void javaToNative (Object object, TransferData transferData) {
+ transferData.result = -1;
+ if (object == null || !(object instanceof String) || !isSupportedType(transferData)) return;
+ String string = (String)object;
+ if (string.length() == 0) return;
+
+ char[] chars = new char[string.length()];
+ string.getChars (0, chars.length, chars, 0);
+ switch (transferData.type) {
+ case TEXTID: {
+ int cfstring = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, chars.length);
+ if (cfstring == 0) return;
+ byte[] buffer = null;
+ try {
+ CFRange range = new CFRange();
+ range.length = chars.length;
+ int encoding = OS.CFStringGetSystemEncoding();
+ int[] size = new int[1];
+ int numChars = OS.CFStringGetBytes(cfstring, range, encoding, (byte)'?', true, null, 0, size);
+ if (numChars == 0) return;
+ buffer = new byte[size[0]];
+ numChars = OS.CFStringGetBytes(cfstring, range, encoding, (byte)'?', true, buffer, size [0], size);
+ if (numChars == 0) return;
+ } finally {
+ OS.CFRelease(cfstring);
+ }
+ transferData.data = new byte[1][];
+ transferData.data[0] = buffer;
+ transferData.result = OS.noErr;
+ break;
+ }
+ case UTEXTID: {
+ byte[] buffer = new byte[chars.length * 2];
+ OS.memcpy(buffer, chars, buffer.length);
+ transferData.data = new byte[1][];
+ transferData.data[0] = buffer;
+ transferData.result = OS.noErr;
+ break;
+ }
+ }
}
/**
@@ -73,21 +107,41 @@
* conversion was successful; otherwise null
*/
public Object nativeToJava(TransferData transferData){
- // get byte array from super
- byte[] buffer = (byte[])super.nativeToJava(transferData);
- if (buffer == null) return null;
- // convert byte array to a string
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- String string = new String (unicode);
- int end = string.indexOf('\0');
- return (end == -1) ? string : string.substring(0, end);
-}
-
-protected String[] getTypeNames() {
- return new String[] { TYPENAME1 };
+ if (!isSupportedType(transferData) || transferData.data == null) return null;
+ if (transferData.data.length == 0 || transferData.data[0].length == 0) return null;
+ byte[] buffer = transferData.data[0];
+ switch (transferData.type) {
+ case TEXTID: {
+ int encoding = OS.CFStringGetSystemEncoding();
+ int cfstring = OS.CFStringCreateWithBytes(OS.kCFAllocatorDefault, buffer, buffer.length, encoding, true);
+ if (cfstring == 0) return null;
+ try {
+ int length = OS.CFStringGetLength(cfstring);
+ if (length == 0) return null;
+ char[] chars = new char[length];
+ CFRange range = new CFRange();
+ range.length = length;
+ OS.CFStringGetCharacters(cfstring, range, chars);
+ return new String(chars);
+ } finally {
+ OS.CFRelease(cfstring);
+ }
+ }
+ case UTEXTID: {
+ char[] chars = new char[(buffer.length + 1) / 2];
+ OS.memcpy(chars, buffer, buffer.length);
+ return new String(chars);
+ }
+ }
+ return null;
}
protected int[] getTypeIds() {
- return new int[] { TYPEID1 };
+ return new int[] {UTEXTID, TEXTID};
}
+
+protected String[] getTypeNames() {
+ return new String[] {UTEXT, TEXT};
}
+
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Transfer.java
index a684667..93fd3c2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Transfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/carbon/org/eclipse/swt/dnd/Transfer.java
@@ -35,6 +35,7 @@
* @return a list of the data types that can be converted using this transfer agent
*/
abstract public TransferData[] getSupportedTypes();
+
/**
* Returns true if the <code>TransferData</code> data type can be converted
* using this transfer agent.
@@ -48,15 +49,6 @@
abstract public boolean isSupportedType(TransferData transferData);
/**
- * Returns the platform specfic names of the data types that can be converted
- * using this transfer agent.
- *
- * @return the platform specfic names of the data types that can be converted
- * using this transfer agent.
- */
-abstract protected String[] getTypeNames();
-
-/**
* Returns the platform specfic ids of the data types that can be converted using
* this transfer agent.
*
@@ -66,6 +58,15 @@
abstract protected int[] getTypeIds();
/**
+ * Returns the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ *
+ * @return the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ */
+abstract protected String[] getTypeNames();
+
+/**
* Converts a java representation of data to a platform specific representation of
* the data.
*
@@ -118,11 +119,17 @@
*
* @param formatName the name of a data type
*
- * @return the unique identifier associated with htis data type
+ * @return the unique identifier associated with this data type
*/
public static int registerType(String formatName) {
- // System.out.println("Transfer.registerType: " + formatName);
- // AW: FIXME: hashCode may not be not unique!
- return formatName.hashCode();
+ int length = formatName.length();
+ // TODO - hashcode may not be unique - need another way
+ if (length > 4) return formatName.hashCode();
+ int type = 0;
+ if (length > 0) type |= (formatName.charAt(0) & 0xff) << 24;
+ if (length > 1) type |= (formatName.charAt(1) & 0xff) << 16;
+ if (length > 2) type |= (formatName.charAt(2) & 0xff) << 8;
+ if (length > 3) type |= formatName.charAt(3) & 0xff;
+ return type;
}
}
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 afe0b3d..7a095c4 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
@@ -34,9 +34,10 @@
/**
* The data being transferred.
+ * The data field may contain multiple values.
* (Warning: This field is platform dependent)
*/
- public byte[] data;
+ public byte[][] data;
/**
* The result field contains the result of converting a java data type
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
index 47e87af..e117e40 100644
--- 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
@@ -19,7 +19,7 @@
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
+CFLAGS = -c -DSWT_VERSION=$(SWT_VERSION) $(DEBUG) -DCARBON -I /System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Headers
LFLAGS = -bundle -framework JavaVM -framework Carbon
SWT_OBJS = swt.o structs.o callback.o
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
index 4fbeab9..34e2a7e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.c
@@ -1718,3 +1718,45 @@
(*env)->SetIntField(env, lpObject, TXNLongRectFc.right, (jint)lpStruct->right);
}
#endif /* NO_TXNLongRect */
+
+#ifndef NO_TXNBackground
+typedef struct TXNBackground_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID bgType, bg_red, bg_green, bg_blue;
+} TXNBackground_FID_CACHE;
+
+TXNBackground_FID_CACHE TXNBackgroundFc;
+
+void cacheTXNBackgroundFids(JNIEnv *env, jobject lpObject)
+{
+ if (TXNBackgroundFc.cached) return;
+ TXNBackgroundFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ TXNBackgroundFc.bgType = (*env)->GetFieldID(env, TXNBackgroundFc.clazz, "bgType", "I");
+ TXNBackgroundFc.bg_red = (*env)->GetFieldID(env, TXNBackgroundFc.clazz, "bg_red", "S");
+ TXNBackgroundFc.bg_green = (*env)->GetFieldID(env, TXNBackgroundFc.clazz, "bg_green", "S");
+ TXNBackgroundFc.bg_blue = (*env)->GetFieldID(env, TXNBackgroundFc.clazz, "bg_blue", "S");
+ TXNBackgroundFc.cached = 1;
+}
+
+TXNBackground *getTXNBackgroundFields(JNIEnv *env, jobject lpObject, TXNBackground *lpStruct)
+{
+ if (!TXNBackgroundFc.cached) cacheTXNBackgroundFids(env, lpObject);
+ lpStruct->bgType = (*env)->GetIntField(env, lpObject, TXNBackgroundFc.bgType);
+ lpStruct->bg.color.red = (*env)->GetShortField(env, lpObject, TXNBackgroundFc.bg_red);
+ lpStruct->bg.color.green = (*env)->GetShortField(env, lpObject, TXNBackgroundFc.bg_green);
+ lpStruct->bg.color.blue = (*env)->GetShortField(env, lpObject, TXNBackgroundFc.bg_blue);
+ return lpStruct;
+}
+
+void setTXNBackgroundFields(JNIEnv *env, jobject lpObject, TXNBackground *lpStruct)
+{
+ if (!TXNBackgroundFc.cached) cacheTXNBackgroundFids(env, lpObject);
+ (*env)->SetIntField(env, lpObject, TXNBackgroundFc.bgType, (jint)lpStruct->bgType);
+ (*env)->SetShortField(env, lpObject, TXNBackgroundFc.bg_red, (jshort)lpStruct->bg.color.red);
+ (*env)->SetShortField(env, lpObject, TXNBackgroundFc.bg_green, (jshort)lpStruct->bg.color.green);
+ (*env)->SetShortField(env, lpObject, TXNBackgroundFc.bg_blue, (jshort)lpStruct->bg.color.blue);
+}
+#endif /* NO_TXNBackground */
+
+
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
index bee51e1..afb4ccb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/structs.h
@@ -270,3 +270,12 @@
#define getTXNLongRectFields(a,b,c) NULL
#define setTXNLongRectFields(a,b,c)
#endif /* NO_TXNLongRect */
+
+#ifndef NO_TXNBackground
+TXNBackground *getTXNBackgroundFields(JNIEnv *env, jobject lpObject, TXNBackground *lpStruct);
+void setTXNBackgroundFields(JNIEnv *env, jobject lpObject, TXNBackground *lpStruct);
+#else
+#define getTXNBackgroundFields(a,b,c) NULL
+#define setTXNBackgroundFields(a,b,c)
+#endif /* NO_TXNBackground */
+
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 58c919d..b055417 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
@@ -120,6 +120,22 @@
}
#endif /* NO_AEProcessAppleEvent */
+#ifndef NO_AddDragItemFlavor
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_AddDragItemFlavor
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4, jint arg5)
+{
+ jbyte *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("AddDragItemFlavor\n")
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ rc = (jint)AddDragItemFlavor((DragRef)arg0, (DragItemRef)arg1, (FlavorType)arg2, (const void *)lparg3, (Size)arg4, (FlavorFlags)arg5);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ return rc;
+}
+#endif
+
#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)
@@ -596,6 +612,32 @@
}
#endif /* NO_CFURLCreateFromFSRef */
+#ifndef NO_CFURLCreateWithFileSystemPath
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFURLCreateWithFileSystemPath
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3)
+{
+ DEBUG_CALL("CFURLCreateWithFileSystemPath\n")
+
+ return (jint)CFURLCreateWithFileSystemPath((CFAllocatorRef)arg0, (CFStringRef)arg1, (CFURLPathStyle)arg2, arg3);
+}
+#endif
+
+#ifndef NO_CFURLGetFSRef
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_CFURLGetFSRef
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+ jbyte *lparg1=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("CFURLGetFSRef\n")
+
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jboolean)CFURLGetFSRef((CFURLRef)arg0, (struct FSRef *)lparg1);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif
+
#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)
@@ -680,6 +722,20 @@
}
#endif /* NO_CGContextBeginPath */
+#ifndef NO_CGContextClearRect
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextClearRect
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ CGRect _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("CGContextClearRect\n")
+
+ if (arg1) lparg1 = getCGRectFields(env, arg1, &_arg1);
+ CGContextClearRect((CGContextRef)arg0, *lparg1);
+ if (arg1) setCGRectFields(env, arg1, lparg1);
+}
+#endif
+
#ifndef NO_CGContextClip
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGContextClip
(JNIEnv *env, jclass that, jint arg0)
@@ -1206,6 +1262,22 @@
}
#endif /* NO_CGImageRelease */
+#ifndef NO_CGWarpMouseCursorPosition
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CGWarpMouseCursorPosition
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ CGPoint _arg0, *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("CGWarpMouseCursorPosition\n")
+
+ if (arg0) lparg0 = getCGPointFields(env, arg0, &_arg0);
+ rc = (jint)CGWarpMouseCursorPosition(*lparg0);
+ if (arg0) setCGPointFields(env, arg0, lparg0);
+ return rc;
+}
+#endif
+
#ifndef NO_CallNextEventHandler
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CallNextEventHandler
(JNIEnv *env, jclass that, jint arg0, jint arg1)
@@ -1397,6 +1469,38 @@
}
#endif /* NO_CopyRgn */
+#ifndef NO_CountDragItems
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CountDragItems
+ (JNIEnv *env, jclass that, jint arg0, jshortArray arg1)
+{
+ jshort *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("CountDragItems\n")
+
+ if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL);
+ rc = (jint)CountDragItems((DragRef)arg0, (UInt16 *)lparg1);
+ if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_CountDragItems */
+
+#ifndef NO_CountDragItemFlavors
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CountDragItemFlavors
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jshortArray arg2)
+{
+ jshort *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("CountDragItemFlavors\n")
+
+ if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL);
+ rc = (jint)CountDragItemFlavors((DragRef)arg0, (DragItemRef)arg1, (UInt16 *)lparg2);
+ if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_CountDragItemFlavors */
+
#ifndef NO_CountMenuItems
JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_CountMenuItems
(JNIEnv *env, jclass that, jint arg0)
@@ -1975,6 +2079,16 @@
}
#endif /* NO_DisposeControl */
+#ifndef NO_DisposeDrag
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeDrag
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("DisposeDrag\n")
+
+ return (jint)DisposeDrag((DragRef)arg0);
+}
+#endif
+
#ifndef NO_DisposeGWorld
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_DisposeGWorld
(JNIEnv *env, jclass that, jint arg0)
@@ -2479,6 +2593,74 @@
}
#endif
+#ifndef NO_FSpMakeFSRef
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FSpMakeFSRef
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("FSpMakeFSRef\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)FSpMakeFSRef((const FSSpec *)lparg0, (FSRef *)lparg1);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif
+
+#ifndef NO_FSGetCatalogInfo
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FSGetCatalogInfo
+ (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jbyteArray arg5)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg2=NULL;
+ jbyte *lparg3=NULL;
+ jbyte *lparg4=NULL;
+ jbyte *lparg5=NULL;
+ jint rc;
+
+ DEBUG_CALL("FSGetCatalogInfo\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg2) lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ if (arg4) lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL);
+ if (arg5) lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL);
+ rc = (jint)FSGetCatalogInfo((FSRef *)lparg0, (FSCatalogInfoBitmap)arg1, (FSCatalogInfo *)lparg2, (HFSUniStr255 *)lparg3, (FSSpec *)lparg4, (FSRef *)lparg5);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ if (arg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+ if (arg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+ return rc;
+}
+#endif
+
+#ifndef NO_FSpGetFInfo
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_FSpGetFInfo
+ (JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1)
+{
+ jbyte *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("FSpGetFInfo\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ rc = (jint)FSpGetFInfo((FSSpec *)lparg0, (FInfo *)lparg1);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif
+
+
+
#ifndef NO_FindWindow
JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_FindWindow
(JNIEnv *env, jclass that, jobject arg0, jintArray arg1)
@@ -2689,6 +2871,25 @@
}
#endif /* NO_GetControlBounds */
+#ifndef NO_GetControlData__ISIILorg_eclipse_swt_internal_carbon_ControlFontStyleRec_2_3I
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetControlData__ISIILorg_eclipse_swt_internal_carbon_ControlFontStyleRec_2_3I
+ (JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jint arg3, jobject arg4, jintArray arg5)
+{
+ ControlFontStyleRec _arg4, *lparg4=NULL;
+ jint *lparg5=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetControlData__ISIILorg_eclipse_swt_internal_carbon_ControlFontStyleRec_2_3I\n")
+
+ if (arg4) lparg4 = getControlFontStyleRecFields(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) setControlFontStyleRecFields(env, arg4, lparg4);
+ if (arg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+ return rc;
+}
+#endif
+
#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)
@@ -3207,6 +3408,105 @@
}
#endif
+#ifndef NO_GetDeviceList
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDeviceList
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetDeviceList\n")
+
+ return (jint)GetDeviceList();
+}
+#endif
+
+#ifndef NO_GetDragAllowableActions
+JNIEXPORT jint JNICALL OS_NATIVE(GetDragAllowableActions)
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+ jint *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetDragAllowableActions\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ rc = (jint)GetDragAllowableActions((DragRef)arg0, (DragActions *)lparg1);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif
+
+#ifndef NO_GetDragItemReferenceNumber
+JNIEXPORT jint JNICALL OS_NATIVE(GetDragItemReferenceNumber)
+ (JNIEnv *env, jclass that, jint arg0, jshort arg1, jintArray arg2)
+{
+ jint *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetDragItemReferenceNumber\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jint)GetDragItemReferenceNumber((DragRef)arg0, arg1, (DragItemRef *)lparg2);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif
+
+#ifndef NO_GetDragDropAction
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDragDropAction
+ (JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+ jint *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetDragDropAction\n")
+
+ if (arg1) lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL);
+ rc = (jint)GetDragDropAction((DragRef)arg0, (DragActions *)lparg1);
+ if (arg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ return rc;
+}
+#endif /* NO_GetDragDropAction */
+
+#ifndef NO_GetDragModifiers
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDragModifiers
+ (JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jshortArray arg2, jshortArray arg3)
+{
+ jshort *lparg1=NULL;
+ jshort *lparg2=NULL;
+ jshort *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetDragModifiers\n")
+
+ if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL);
+ if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL);
+ if (arg3) lparg3 = (*env)->GetShortArrayElements(env, arg3, NULL);
+ rc = (jint)GetDragModifiers((DragRef)arg0, (SInt16 *)lparg1, (SInt16 *)lparg2, (SInt16 *)lparg3);
+ if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0);
+ if (arg2) (*env)->ReleaseShortArrayElements(env, arg1, lparg2, 0);
+ if (arg3) (*env)->ReleaseShortArrayElements(env, arg1, lparg3, 0);
+ return rc;
+}
+#endif /* NO_GetDragModifiers */
+
+#ifndef NO_GetDragMouse
+JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetDragMouse
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jobject arg2)
+{
+ Point _arg1, *lparg1=NULL;
+ Point _arg2, *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetDragMouse\n")
+
+ if (arg1) lparg1 = getPointFields(env, arg1, &_arg1);
+ if (arg2) lparg2 = getPointFields(env, arg2, &_arg2);
+ rc = (jint)GetDragMouse((DragRef)arg0, (Point *)lparg1, (Point *)lparg2);
+ if (arg1) setPointFields(env, arg1, lparg1);
+ if (arg2) setPointFields(env, arg2, lparg2);
+ return rc;
+}
+#endif /* NO_GetDragMouse */
+
#ifndef NO_GetEventClass
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetEventClass
(JNIEnv *env, jclass that, jint arg0)
@@ -3445,6 +3745,66 @@
}
#endif /* NO_GetEventTime */
+#ifndef NO_GetFlavorData
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetFlavorData
+ (JNIEnv *env, jclass that, jint arg0, int arg1, jint arg2, jbyteArray arg3, jintArray arg4, jint arg5)
+{
+ jbyte *lparg3=NULL;
+ jint *lparg4=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetFlavorData\n")
+
+ if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
+ if (arg4) lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL);
+
+ rc = (jint)GetFlavorData((DragRef)arg0, (DragItemRef)arg1, (FlavorType)arg2, (void *)lparg3, (Size *)lparg4, arg5);
+
+ if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+ if (arg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+
+ return rc;
+}
+#endif /* NO_GetFlavorData */
+
+#ifndef NO_GetFlavorDataSize
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetFlavorDataSize
+ (JNIEnv *env, jclass that, jint arg0, int arg1, jint arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetFlavorDataSize\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+
+ rc = (jint)GetFlavorDataSize((DragRef)arg0, (DragItemRef)arg1, (FlavorType)arg2, (Size *)lparg3);
+
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+
+ return rc;
+}
+#endif /* NO_GetFlavorDataSize */
+
+#ifndef NO_GetFlavorType
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetFlavorType
+ (JNIEnv *env, jclass that, jint arg0, int arg1, jshort arg2, jintArray arg3)
+{
+ jint *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetFlavorType\n")
+
+ if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
+
+ rc = (jint)GetFlavorType((DragRef)arg0, (DragItemRef)arg1, arg2, (FlavorType *)lparg3);
+
+ if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+
+ return rc;
+}
+#endif /* NO_GetFlavorType */
+
#ifndef NO_GetFontInfo
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetFontInfo
(JNIEnv *env, jclass that, jshortArray arg0)
@@ -3561,6 +3921,20 @@
}
#endif /* NO_GetIndexedSubControl */
+#ifndef NO_GetItemMark
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetItemMark
+ (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshortArray arg2)
+{
+ jshort *lparg2=NULL;
+
+ DEBUG_CALL("GetItemMark\n")
+
+ if (arg2) lparg2 = (*env)->GetShortArrayElements(env, arg2, NULL);
+ GetItemMark((MenuRef)arg0, arg1, lparg2);
+ if (arg2) (*env)->ReleaseShortArrayElements(env, arg2, lparg2, 0);
+}
+#endif
+
#ifndef NO_GetKeyboardFocus
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetKeyboardFocus
(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
@@ -3750,6 +4124,16 @@
}
#endif /* NO_GetMouse */
+#ifndef NO_GetNextDevice
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetNextDevice
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ DEBUG_CALL("GetNextDevice\n")
+
+ return (jint)GetNextDevice((GDHandle)arg0);
+}
+#endif
+
#ifndef NO_GetPixBounds
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetPixBounds
(JNIEnv *env, jclass that, jint arg0, jobject arg1)
@@ -4073,6 +4457,16 @@
}
#endif /* NO_GetUserFocusEventTarget */
+#ifndef NO_GetUserFocusWindow
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetUserFocusWindow
+ (JNIEnv *env, jclass that)
+{
+ DEBUG_CALL("GetUserFocusWindow\n")
+
+ return (jint)GetUserFocusWindow();
+}
+#endif
+
#ifndef NO_GetWRefCon
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetWRefCon
(JNIEnv *env, jclass that, jint arg0)
@@ -4854,6 +5248,38 @@
}
#endif /* NO_InstallEventLoopTimer */
+#ifndef NO_InstallReceiveHandler
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InstallReceiveHandler
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+ jint *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("InstallReceiveHandler\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jint)InstallReceiveHandler((DragReceiveHandlerUPP)arg0, (WindowRef)arg1, (void *)lparg2);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_InstallReceiveHandler */
+
+#ifndef NO_InstallTrackingHandler
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_InstallTrackingHandler
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+ jint *lparg2=NULL;
+ jint rc;
+
+ DEBUG_CALL("InstallTrackingHandler\n")
+
+ if (arg2) lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL);
+ rc = (jint)InstallTrackingHandler((DragTrackingHandlerUPP)arg0, (WindowRef)arg1, (void *)lparg2);
+ if (arg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ return rc;
+}
+#endif /* NO_InstallTrackingHandler */
+
#ifndef NO_InvalWindowRect
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_InvalWindowRect
(JNIEnv *env, jclass that, jint arg0, jobject arg1)
@@ -5266,6 +5692,22 @@
}
#endif /* NO_NewControl */
+#ifndef NO_NewDrag
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_NewDrag
+ (JNIEnv *env, jclass that, jintArray arg0)
+{
+ jint *lparg0=NULL;
+ jint rc;
+
+ DEBUG_CALL("NewDrag\n")
+
+ if (arg0) lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL);
+ rc = (jint)NewDrag((DragRef *)lparg0);
+ if (arg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+ return rc;
+}
+#endif
+
#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)
@@ -5826,6 +6268,26 @@
}
#endif
+#ifndef NO_RemoveReceiveHandler
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveReceiveHandler
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("RemoveReceiveHandler\n")
+
+ return (jint)RemoveReceiveHandler((DragReceiveHandlerUPP)arg0, (WindowRef)arg1);
+}
+#endif /* NO_RemoveReceiveHandler */
+
+#ifndef NO_RemoveTrackingHandler
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RemoveTrackingHandler
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("RemoveTrackingHandler\n")
+
+ return (jint)RemoveTrackingHandler((DragTrackingHandlerUPP)arg0, (WindowRef)arg1);
+}
+#endif /* NO_RemoveTrackingHandler */
+
#ifndef NO_RetainEvent
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_RetainEvent
(JNIEnv *env, jclass that, jint arg0)
@@ -6455,6 +6917,36 @@
}
#endif /* NO_SetDataBrowserTarget */
+#ifndef NO_SetDragAllowableActions
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDragAllowableActions
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+ DEBUG_CALL("SetDragAllowableActions\n")
+
+ return (jint)SetDragAllowableActions((DragRef)arg0, (DragActions)arg1, (Boolean)arg2);
+}
+#endif
+
+#ifndef NO_SetDragDropAction
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDragDropAction
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ DEBUG_CALL("SetDragDropAction\n")
+
+ return (jint)SetDragDropAction((DragRef)arg0, (DragActions)arg1);
+}
+#endif /* NO_SetDragDropAction */
+
+#ifndef NO_SetDragInputProc
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetDragInputProc
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ DEBUG_CALL("SetDragInputProc\n")
+
+ return (jint)SetDragInputProc((DragRef)arg0, (DragInputUPP)arg1, (void *)arg2);
+}
+#endif
+
#ifndef NO_SetEventLoopTimerNextFireTime
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetEventLoopTimerNextFireTime
(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
@@ -6517,6 +7009,16 @@
}
#endif /* NO_SetGWorld */
+#ifndef NO_SetItemMark
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetItemMark
+ (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2)
+{
+ DEBUG_CALL("SetItemMark\n")
+
+ SetItemMark((MenuRef)arg0, arg1, arg2);
+}
+#endif
+
#ifndef NO_SetKeyboardFocus
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_SetKeyboardFocus
(JNIEnv *env, jclass that, jint arg0, jint arg1, jshort arg2)
@@ -7237,6 +7739,22 @@
}
#endif /* NO_TXNSelectAll */
+#ifndef NO_TXNSetBackground
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetBackground
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+ TXNBackground _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("TXNSetBackground\n")
+
+ if (arg1) lparg1 = getTXNBackgroundFields(env, arg1, &_arg1);
+ rc = (jint)TXNSetBackground((TXNObject)arg0, (const TXNBackground *)lparg1);
+ if (arg1) setTXNBackgroundFields(env, arg1, lparg1);
+ return rc;
+}
+#endif
+
#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)
@@ -7290,6 +7808,16 @@
}
#endif /* NO_TXNSetSelection */
+#ifndef NO_TXNSetTypeAttributes
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TXNSetTypeAttributes
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DEBUG_CALL("TXNSetTypeAttributes\n")
+
+ return (jint)TXNSetTypeAttributes((TXNObject)arg0, (ItemCount)arg1, (const TXNTypeAttributes *)arg2, (TXNOffset)arg3, (TXNOffset)arg4);
+}
+#endif
+
#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)
@@ -7391,6 +7919,22 @@
}
#endif /* NO_TextWidth */
+#ifndef NO_TrackDrag
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_TrackDrag
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ EventRecord _arg1, *lparg1=NULL;
+ jint rc;
+
+ DEBUG_CALL("TrackDrag\n")
+
+ if (arg1) lparg1 = getEventRecordFields(env, arg1, &_arg1);
+ rc = (jint)TrackDrag((DragRef)arg0, (const EventRecord *)lparg1, (RgnHandle)arg2);
+ if (arg1) setEventRecordFields(env, arg1, lparg1);
+ return rc;
+}
+#endif
+
#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)
@@ -7752,6 +8296,20 @@
}
#endif
+#ifndef NO_memcpy__ILorg_eclipse_swt_internal_carbon_RGBColor_2I
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__ILorg_eclipse_swt_internal_carbon_RGBColor_2I
+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+ RGBColor _arg1, *lparg1=NULL;
+
+ DEBUG_CALL("memcpy__ILorg_eclipse_swt_internal_carbon_RGBColor_2I\n")
+
+ if (arg1) lparg1 = getRGBColorFields(env, arg1, &_arg1);
+ memcpy((void *)arg0, (const void *)lparg1, (size_t)arg2);
+ if (arg1) setRGBColorFields(env, arg1, lparg1);
+}
+#endif
+
#ifndef NO_memcpy__ILjava_lang_String_2I
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy__ILjava_lang_String_2I
(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
@@ -7766,6 +8324,40 @@
}
#endif
+#ifndef NO_memcpy___3C_3BI
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy___3C_3BI
+ (JNIEnv *env, jclass that, jcharArray arg0, jbyteArray arg1, jint arg2)
+{
+ jchar *lparg0=NULL;
+ jbyte *lparg1=NULL;
+
+ DEBUG_CALL("memcpy___3C_3BI\n")
+
+ if (arg0) lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL);
+ memcpy((void *)lparg0, (const void *)lparg1, (size_t)arg2);
+ if (arg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+}
+#endif
+
+#ifndef NO_memcpy___3B_3CI
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_carbon_OS_memcpy___3B_3CI
+ (JNIEnv *env, jclass that, jbyteArray arg0, jcharArray arg1, jint arg2)
+{
+ jbyte *lparg0=NULL;
+ jchar *lparg1=NULL;
+
+ DEBUG_CALL("memcpy___3B_3CI\n")
+
+ if (arg0) lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL);
+ if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL);
+ memcpy((void *)lparg0, (const void *)lparg1, (size_t)arg2);
+ if (arg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0);
+}
+#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)
@@ -7786,6 +8378,22 @@
}
#endif
+#ifndef NO_WaitMouseMoved
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_carbon_OS_WaitMouseMoved
+ (JNIEnv *env, jclass that, jobject arg0)
+{
+ Point _arg0, *lparg0=NULL;
+ jboolean rc;
+
+ DEBUG_CALL("WaitMouseMoved\n")
+
+ if (arg0) lparg0 = getPointFields(env, arg0, &_arg0);
+ rc = (jboolean)WaitMouseMoved((Point)_arg0);
+ if (arg0) setPointFields(env, arg0, lparg0);
+ return rc;
+}
+#endif /* NO_WaitMouseMoved */
+
#ifndef NO_ZoomWindowIdeal
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_ZoomWindowIdeal
(JNIEnv *env, jclass that, jint arg0, jshort arg1, jobject arg2)
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 67b503e..43f97ce 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
@@ -23,10 +23,12 @@
/** Constants */
public static final int RGBDirect = 16;
public static final int bold = 1;
+ public static final int cantGetFlavorErr = -1854;
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 dragNotAcceptedErr = -1857;
public static final int errControlIsNotEmbedder = -30590;
public static final int errUnknownControl = -30584;
public static final int eventLoopTimedOutErr = -9875;
@@ -99,6 +101,7 @@
public static final int kControlEditTextTextTag = ('t'<<24) + ('e'<<16) + ('x'<<8) + 't';
public static final int kControlEntireControl = 0;
public static final int kControlFocusNoPart = 0;
+ public static final int kControlFontStyleTag = ('f'<<24) + ('o'<<16) + ('n'<<8) + 't';
public static final int kControlGetsFocusOnClick = 1 << 8;
public static final int kControlGroupBoxTextTitleProc = 160;
public static final int kControlHandlesTracking = 1 << 5;
@@ -144,6 +147,7 @@
public static final int kControlUseBackColorMask = 16;
public static final int kControlUseFontMask = 0x1;
public static final int kControlUseForeColorMask = 8;
+ public static final int kControlUseJustMask = 0x0040;
public static final int kControlUseSizeMask = 0x4;
public static final int kControlUseThemeFontIDMask = 0x80;
public static final int kControlUseFaceMask = 0x2;
@@ -161,6 +165,7 @@
public static final int kDataBrowserDefaultPropertyFlags = 0;
public static final int kDataBrowserDragSelect = 1 << 0;
public static final int kDataBrowserIconAndTextType = ('t'<<24) + ('i'<<16) + ('c'<<8) + 'n';
+ public static final int kDataBrowserItemAnyState = -1;
public static final int kDataBrowserItemIsActiveProperty = 1;
public static final int kDataBrowserItemIsContainerProperty = 4;
public static final int kDataBrowserItemIsEditableProperty = 3;
@@ -195,6 +200,19 @@
public static final int kDataBrowserTableViewFillHilite = 1;
public static final int kDataBrowserViewSpecificFlagsOffset = 16;
public static final int kDocumentWindowClass = 6;
+ public static final int kDragActionNothing = 0;
+ public static final int kDragActionCopy = 1;
+ public static final int kDragActionAlias = 1 << 1;
+ public static final int kDragActionGeneric = 1 << 2;
+ public static final int kDragActionPrivate = 1 << 3;
+ public static final int kDragActionMove = 1 << 4;
+ public static final int kDragActionDelete = 1 << 5;
+ public static final int kDragActionAll = 0xFFFFFFFF;
+ public static final int kDragTrackingEnterHandler = 1;
+ public static final int kDragTrackingEnterWindow = 2;
+ public static final int kDragTrackingInWindow = 3;
+ public static final int kDragTrackingLeaveWindow = 4;
+ public static final int kDragTrackingLeaveHandler = 5;
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';
@@ -261,6 +279,7 @@
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 kEventParamMenuCommand = ('m'<<24) + ('c'<<16) + ('m'<<8) + 'd';
+ public static final int kEventParamMenuItemIndex = ('i'<<24) + ('t'<<16) + ('e'<<8) + 'm';
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';
@@ -396,8 +415,10 @@
public static final int kNavUserActionChoose = 4;
public static final int kNavUserActionOpen = 2;
public static final int kNavUserActionSaveAs = 3;
+ public static final int kOverlayWindowClass = 14;
public static final int kQDUseCGTextMetrics = (1 << 2);
public static final int kQDUseCGTextRendering = (1 << 1);
+ public static final int kScrapFlavorTypeUnicode = ('u'<<24) + ('t'<<16) + ('x'<<8) + 't';
public static final int kScrapFlavorTypeText = ('T'<<24) + ('E'<<16) + ('X'<<8) + 'T';
public static final boolean kScrollBarsSyncAlwaysActive = true;
public static final boolean kScrollBarsSyncWithFocus = false;
@@ -405,13 +426,26 @@
public static final int kStdCFStringAlertVersionOne = 1;
public static final int kControlSliderDoesNotPoint = 2;
public static final int kTXNAlwaysWrapAtViewEdgeMask = 1 << 11;
+ public static final int kTXNBackgroundTypeRGB = 1;
+ public static final int kTXNDefaultFontSize = 0x000C0000;
+ public static final int kTXNDefaultFontStyle = 0;
+ public static final int kTXNDefaultFontName = 0;
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 kTXNDrawCaretWhenInactiveTag = ('d'<<24)+('c'<<16)+('r'<<8)+'t';
public static final int kTXNEndOffset = 2147483647;
+ public static final int kTXNIOPrivilegesTag = ('i'<<24) + ('o'<<16) + ('p'<<8) + 'v';
public static final int kTXNMarginsTag = ('m'<<24) + ('a'<<16) + ('r'<<8) + 'g';
public static final int kTXNMonostyledTextMask = 1 << 17;
+ public static final int kTXNQDFontFamilyIDAttribute = ('f'<<24) + ('o'<<16) + ('n'<<8) + 't';
+ public static final int kTXNQDFontSizeAttribute = ('s'<<24) + ('i'<<16) + ('z'<<8) + 'e';
+ public static final int kTXNQDFontStyleAttribute = ('f'<<24) + ('a'<<16) + ('c'<<8) + 'e';
+ public static final int kTXNQDFontColorAttribute = ('k'<<24) + ('l'<<16) + ('o'<<8) + 'r';
+ public static final int kTXNQDFontFamilyIDAttributeSize = 2;
+ public static final int kTXNQDFontSizeAttributeSize = 2;
+ public static final int kTXNQDFontStyleAttributeSize = 2;
+ public static final int kTXNQDFontColorAttributeSize = 6;
public static final int kTXNReadOnlyMask = 1 << 5;
public static final int kTXNSingleLineOnlyMask = 1 << 14;
public static final int kTXNStartOffset = 0;
@@ -423,6 +457,7 @@
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 kThemeAliasArrowCursor = 2;
public static final int kThemeArrowButton = 4;
public static final int kThemeArrowCursor = 0;
public static final int kThemeBrushDialogBackgroundActive = 1;
@@ -436,6 +471,7 @@
public static final int kThemeButtonOn = 1;
public static final int kThemeButtonMixed = 2;
public static final int kThemeCheckBox = 1;
+ public static final int kThemeCopyArrowCursor = 1;
public static final int kThemeCrossCursor = 5;
public static final int kThemeCurrentPortFont = 200;
public static final int kThemeDisclosureButton = 6;
@@ -508,10 +544,15 @@
public static final int noErr = 0;
public static final int normal = 0;
public static final int optionKey = 1 << 11;
+ public static final int osEvt = 15;
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 teFlushDefault = 0;
+ public static final int teCenter = 1;
+ public static final int teFlushRight = -1;
+ public static final int teFlushLeft = -2;
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';
@@ -521,6 +562,7 @@
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 typeMenuCommand = ('m'<<24) + ('c'<<16) + ('m'<<8) + 'd';
+ public static final int typeMenuItemIndex = ('m'<<24) + ('i'<<16) + ('d'<<8) + 'x';
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 typeMouseWheelAxis = ('m'<<24) + ('w'<<16) + ('a'<<8) + 'x';
@@ -564,7 +606,8 @@
public static final native int ATSUTextInserted(int iTextLayout, int iInsertionLocation, int iInsertionLength);
public static final native int ATSUTextDeleted(int iTextLayout, int iInsertionLocation, int iInsertionLength);
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 AddDataBrowserListViewColumn(int browser, DataBrowserListViewColumnDesc columnDesc, int position);
+public static final native int AddDragItemFlavor(int theDrag, int theItemRef, int theType, byte[] dataPtr, int dataSize, int theFlags);
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);
@@ -581,6 +624,8 @@
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 int CFURLCreateWithFileSystemPath (int allocator, int filePath, int pathStyle, boolean isDirectory);
+public static final native boolean CFURLGetFSRef(int url, 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);
@@ -592,6 +637,7 @@
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 CGContextClearRect (int ctx, CGRect rect);
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);
@@ -636,6 +682,7 @@
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 CGWarpMouseCursorPosition (CGPoint newCursorPosition);
public static final native int CallNextEventHandler(int nextHandler, int eventRefHandle);
public static final native short CharWidth(short c);
public static final native int ClearCurrentScrap();
@@ -651,6 +698,8 @@
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 int CountDragItems(int theDrag, short[] numItems);
+public static final native int CountDragItemFlavors(int theDrag, int theItemRef, short[] numFlavors);
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);
@@ -686,6 +735,7 @@
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 int DisposeDrag(int theDrag);
public static final native void DisposeGWorld(int offscreenGWorld);
public static final native void DisposeHandle(int handle);
public static final native void DisposeMenu(int mHandle);
@@ -726,6 +776,9 @@
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 int FSpGetFInfo(byte[] spec, byte[] fndrInfo);
+public static final native int FSpMakeFSRef(byte[] source, byte[] newRef);
+public static final native int FSGetCatalogInfo(byte[] ref, int whichInfo, byte[] catalogInfo, byte[] outName, byte[] fsSpec, byte[] parentRef);
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);
@@ -743,6 +796,7 @@
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, ControlFontStyleRec inBuffer, int[] outActualSize);
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);
@@ -779,6 +833,12 @@
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 GetDeviceList();
+public static final native int GetDragAllowableActions(int theDrag, int[] outActions);
+public static final native int GetDragDropAction(int theDrag, int[] outAction);
+public static final native int GetDragItemReferenceNumber(int theDrag, short index, int[] theItemRef);
+public static final native int GetDragModifiers(int theDrag, short[] modifiers, short[] mouseDownModifiers, short[] mouseUpModifiers);
+public static final native int GetDragMouse(int theDrag, Point mouse, Point globalPinnedMouse);
public static final native int GetEventClass(int eHandle);
public static final native int GetEventDispatcherTarget();
public static final native int GetEventKind(int eHandle);
@@ -792,6 +852,9 @@
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 int GetFlavorData(int theDrag, int theItemRef, int theType, byte[] dataPtr, int[] dataSize, int dataOffset);
+public static final native int GetFlavorDataSize(int theDrag, int theItemRef, int theType, int[] dataSize);
+public static final native int GetFlavorType(int theDrag,int theItemRef, short index, int[] theType);
public static final native void GetFontInfo(short[] info);
public static final native int GetGDevice();
public static final native void GetGWorld(int[] portHandle, int[] gdHandle);
@@ -800,6 +863,7 @@
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 void GetItemMark (int theMenu, short item, short[] markChar);
public static final native int GetKeyboardFocus(int wHandle, int[] cHandle);
public static final native double GetLastUserEventTime();
public static final native int GetMainDevice();
@@ -814,6 +878,7 @@
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 int GetNextDevice(int curDevice);
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);
@@ -836,6 +901,7 @@
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 GetUserFocusWindow();
public static final native int GetWRefCon(int wHandle);
public static final native int GetWindowActivationScope(int inWindow, int[] outScope);
public static final native void GetWindowBounds(int wHandle, short windowRegion, Rect bounds);
@@ -897,6 +963,8 @@
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 int InstallReceiveHandler(int receiveHandler,int theWindow, int[] handlerRefCon);
+public static final native int InstallTrackingHandler(int trackingHandler,int theWindow, int[] handlerRefCon);
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);
@@ -932,6 +1000,7 @@
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 NewDrag(int[] theDrag);
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);
@@ -976,6 +1045,8 @@
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 RemoveReceiveHandler(int receiveHandler,int theWindow);
+public static final native int RemoveTrackingHandler(int trackingHandler,int theWindow);
public static final native int RepositionWindow(int window, int parentWindow, int method);
public static final native int RetainEvent(int inEvent);
public static final native int RetainMenu(int mHandle);
@@ -1029,11 +1100,15 @@
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 SetDragAllowableActions(int theDrag, int inActions, boolean isLocal);
+public static final native int SetDragDropAction(int theDrag, int inAction);
+public static final native int SetDragInputProc(int theDrag, int inputProc, int dragInputRefCon);
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 void SetItemMark(int theMenu, short item, short markChar);
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);
@@ -1097,9 +1172,11 @@
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 TXNSetBackground(int iTXNObject, TXNBackground iBackgroundInfo);
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 TXNSetTypeAttributes(int iTXNObject, int iAttrCount, int iAttributes, int iStartOffset, int iEndOffset);
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);
@@ -1108,12 +1185,14 @@
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 TrackDrag(int theDrag, EventRecord theEvent, int theRegion);
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 boolean WaitMouseMoved(Point initialGlobalMouse);
public static final native int X2Fix(double x);
public static final native int ZoomWindowIdeal(int inWindow, short inPartCode, Point ioIdealSize);
public static final native void memcpy(ATSTrapezoid dest, int src, int n);
@@ -1133,8 +1212,11 @@
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(int dest, RGBColor 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 memcpy(int dest, String src, int n);
+public static final native void memcpy(char[] dest, byte[] src, int size);
+public static final native void memcpy(byte[] dest, char[] src, int size);
public static final native void memset(int dest, int value, int size);
}
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 aa61d53..0d73b20 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
@@ -236,29 +236,194 @@
hotspotY >= source.height || hotspotY < 0) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
+
+ /* Find the first non transparent pixel if cursor bigger than 16x16. */
+ int width = source.width;
+ int height = source.height;
+ int minX = 0, minY = 0;
+ if (width > 16 || height > 16) {
+ minX = width;
+ minY = height;
+ int maxX = 0, maxY = 0;
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ if (!(source.getPixel(x, y) == 1 && mask.getPixel(x, y) == 0)) {
+ minX = Math.min(minX, x);
+ minY = Math.min(minY, y);
+ maxX = Math.max(maxX, x);
+ maxY = Math.max(maxY, y);
+ }
+ }
+ }
+ width = maxX - minX + 1;
+ height = maxY - minY + 1;
+
+ /* Stretch cursor if still bigger than 16x16. */
+ if (width > 16 || height > 16) {
+ int newWidth = Math.min(width, 16);
+ int newHeight = Math.min(height, 16);
+ ImageData newSource =
+ new ImageData(newWidth, newHeight, source.depth, source.palette,
+ 1, null, 0, null, null, -1, -1, source.type,
+ source.x, source.y, source.disposalMethod, source.delayTime);
+ ImageData newMask = new ImageData(newWidth, newHeight, mask.depth,
+ mask.palette, 1, null, 0, null, null, -1, -1, mask.type,
+ mask.x, mask.y, mask.disposalMethod, mask.delayTime);
+ ImageData.blit(ImageData.BLIT_SRC,
+ source.data, source.depth, source.bytesPerLine, source.getByteOrder(), minX, minY, width, height, null, null, null,
+ ImageData.ALPHA_OPAQUE, null, 0, minX, minY,
+ newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newWidth, newHeight, null, null, null,
+ false, false);
+ ImageData.blit(ImageData.BLIT_SRC,
+ mask.data, mask.depth, mask.bytesPerLine, mask.getByteOrder(), minX, minY, width, height, null, null, null,
+ ImageData.ALPHA_OPAQUE, null, 0, minX, minY,
+ newMask.data, newMask.depth, newMask.bytesPerLine, newMask.getByteOrder(), 0, 0, newWidth, newHeight, null, null, null,
+ false, false);
+ width = newWidth;
+ height = newHeight;
+ minX = minY = 0;
+ source = newSource;
+ mask = newMask;
+ }
+ }
+
/* 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++) {
+ 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;
+ for (int x = 0; x < width; x++) {
+ int bit = 1 << (width - 1 - x);
+ if (source.getPixel(minX + x, minY + y) == 0) {
+ m |= bit;
+ if (mask.getPixel(minX + x, minY + y) == 0) d |= bit;
+ } else if (mask.getPixel(minX + x, minY + y) != 0) {
+ d |= bit;
+ }
}
srcData[y] = d;
maskData[y] = m;
}
- cursor.hotSpot_h = (short)Math.min(16, hotspotX);
- cursor.hotSpot_v = (short)Math.min(16, hotspotY);
+ cursor.hotSpot_h = (short)Math.max(0, Math.min(15, hotspotY - minX));
+ cursor.hotSpot_v = (short)Math.max(0, Math.min(15, hotspotY - minY));
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);
}
+//3.0 API
+//public Cursor(Device device, ImageData source, 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 (hotspotX >= source.width || hotspotX < 0 ||
+// hotspotY >= source.height || hotspotY < 0) {
+// SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+// }
+// ImageData mask = source.getTransparencyMask();
+//
+// /* Ensure depth is equal to 1 */
+// if (source.depth > 1) {
+// /* Create a destination image with no data */
+// ImageData newSource = new ImageData(
+// source.width, source.height, 1, ImageData.bwPalette(),
+// 1, null, 0, null, null, -1, -1, source.type,
+// source.x, source.y, source.disposalMethod, source.delayTime);
+//
+// /* Convert the source to a black and white image of depth 1 */
+// PaletteData palette = source.palette;
+// if (palette.isDirect) ImageData.blit(ImageData.BLIT_SRC,
+// source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, 0, 0, 0,
+// ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+// newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, 0, 0, 0,
+// false, false);
+// else ImageData.blit(ImageData.BLIT_SRC,
+// source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, null, null, null,
+// ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+// newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, null, null, null,
+// false, false);
+// source = newSource;
+// }
+//
+// /* Find the first non transparent pixel if cursor bigger than 16x16. */
+// int width = source.width;
+// int height = source.height;
+// int minX = 0, minY = 0;
+// if (width > 16 || height > 16) {
+// minX = width;
+// minY = height;
+// int maxX = 0, maxY = 0;
+// for (int y = 0; y < height; y++) {
+// for (int x = 0; x < width; x++) {
+// if (!(source.getPixel(x, y) == 1 && mask.getPixel(x, y) == 0)) {
+// minX = Math.min(minX, x);
+// minY = Math.min(minY, y);
+// maxX = Math.max(maxX, x);
+// maxY = Math.max(maxY, y);
+// }
+// }
+// }
+// width = maxX - minX + 1;
+// height = maxY - minY + 1;
+//
+// /* Stretch cursor if still bigger than 16x16. */
+// if (width > 16 || height > 16) {
+// int newWidth = Math.min(width, 16);
+// int newHeight = Math.min(height, 16);
+// ImageData newSource =
+// new ImageData(newWidth, newHeight, source.depth, source.palette,
+// 1, null, 0, null, null, -1, -1, source.type,
+// source.x, source.y, source.disposalMethod, source.delayTime);
+// ImageData newMask = new ImageData(newWidth, newHeight, mask.depth,
+// mask.palette, 1, null, 0, null, null, -1, -1, mask.type,
+// mask.x, mask.y, mask.disposalMethod, mask.delayTime);
+// ImageData.blit(ImageData.BLIT_SRC,
+// source.data, source.depth, source.bytesPerLine, source.getByteOrder(), minX, minY, width, height, null, null, null,
+// ImageData.ALPHA_OPAQUE, null, 0, minX, minY,
+// newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newWidth, newHeight, null, null, null,
+// false, false);
+// ImageData.blit(ImageData.BLIT_SRC,
+// mask.data, mask.depth, mask.bytesPerLine, mask.getByteOrder(), minX, minY, width, height, null, null, null,
+// ImageData.ALPHA_OPAQUE, null, 0, minX, minY,
+// newMask.data, newMask.depth, newMask.bytesPerLine, newMask.getByteOrder(), 0, 0, newWidth, newHeight, null, null, null,
+// false, false);
+// width = newWidth;
+// height = newHeight;
+// minX = minY = 0;
+// source = newSource;
+// mask = newMask;
+// }
+// }
+//
+// /* Create the cursor */
+// org.eclipse.swt.internal.carbon.Cursor cursor = new org.eclipse.swt.internal.carbon.Cursor();
+// 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 << (width - 1 - x);
+// if (source.getPixel(x + minX, y + minY) == 0) {
+// if (mask.getPixel(x + minX, y + minY) != 0) {
+// d |= bit;
+// m |= bit;
+// }
+// } else {
+// if (mask.getPixel(x + minX, y + minY) != 0) m |= bit;
+// }
+// }
+// srcData[y] = d;
+// maskData[y] = m;
+// }
+// cursor.hotSpot_h = (short)Math.max(0, Math.min(15, hotspotY - minX));
+// cursor.hotSpot_v = (short)Math.max(0, Math.min(15, hotspotY - minY));
+// 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);
+//}
+
/**
* Disposes of the operating system resources associated with
* the cursor. Applications must dispose of all cursors which
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 25af005..b37d46a 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
@@ -207,10 +207,8 @@
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);
+ OS.memcpy(device, ptr[0], GDevice.sizeof);
+ return new Rectangle(device.left, device.top, device.right - device.left, device.bottom - device.top);
}
/**
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 428e8f1..1b40926 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
@@ -188,6 +188,47 @@
}
/**
+ * Returns the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms where there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ *
+ * @return the <code>String</code> representing a Locale object
+ * @since 3.0
+ */
+//3.0 API
+//public String getLocale () {
+// StringBuffer buffer = new StringBuffer ();
+// char sep = '_';
+// if (lang != null) {
+// buffer.append (lang);
+// buffer.append (sep);
+// }
+// if (country != null) {
+// buffer.append (country);
+// buffer.append (sep);
+// }
+// if (variant != null) {
+// buffer.append (variant);
+// }
+//
+// String result = buffer.toString ();
+// int length = result.length ();
+// if (result.charAt (length - 1) == sep) {
+// result = result.substring (0, length - 1);
+// }
+// return result;
+//}
+
+/**
* Returns the name of the receiver.
* On platforms that support font foundries, the return value will
* be the foundry followed by a dash ("-") followed by the face name.
@@ -254,7 +295,7 @@
* character set of the specified locale.
* </p>
* <p>
- * On platforms which there are multiple character sets for a
+ * On platforms where there are multiple character sets for a
* given language/country locale, the variant portion of the
* locale will determine the character set.
* </p>
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 6ec5f89..4eaa190 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
@@ -63,12 +63,27 @@
* </ul>
*/
public GC(Drawable drawable) {
+ this(drawable, 0);
+}
+
+//3.0 API
+GC(Drawable drawable, int style) {
if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
GCData data = new GCData();
+ data.style = checkStyle(style);
int gdkGC = drawable.internal_new_GC(data);
+ Device device = data.device;
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ data.device = device;
init(drawable, data, gdkGC);
}
+static int checkStyle (int style) {
+ if ((style & SWT.LEFT_TO_RIGHT) != 0) style &= ~SWT.RIGHT_TO_LEFT;
+ return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
+}
+
/**
* Invokes platform specific functionality to allocate a new graphics context.
* <p>
@@ -132,6 +147,7 @@
*/
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 (data.updateClip) setCGClipping();
if (width <= 0 || height <= 0) return;
int deltaX = destX - srcX, deltaY = destY - srcY;
if (deltaX == 0 && deltaY == 0) return;
@@ -312,6 +328,7 @@
*/
public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
if (width < 0) {
x = x + width;
width = -width;
@@ -330,6 +347,7 @@
OS.CGContextAddArc(handle, 0, 0, 1, -startAngle * (float)Math.PI / 180, -endAngle * (float)Math.PI / 180, true);
OS.CGContextRestoreGState(handle);
OS.CGContextStrokePath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -351,8 +369,10 @@
*/
public void drawFocus(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
//NOT DONE
// drawRectangle (x, y, width - 1, height - 1);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -425,7 +445,8 @@
}
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;
+ if (data.updateClip) setCGClipping();
+ int imageHandle = srcImage.handle;
int imgWidth = OS.CGImageGetWidth(imageHandle);
int imgHeight = OS.CGImageGetHeight(imageHandle);
if (simple) {
@@ -457,14 +478,17 @@
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);
+ if (provider != 0) {
+ int subImage = OS.CGImageCreate(srcWidth, srcHeight, bpc, bpp, bpr, colorspace, alphaInfo, provider, null, false, 0);
+ OS.CGDataProviderRelease(provider);
+ if (subImage != 0) {
+ OS.CGContextDrawImage(handle, rect, subImage);
+ OS.CGImageRelease(subImage);
+ }
+ }
}
OS.CGContextRestoreGState(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -482,6 +506,7 @@
*/
public void drawLine(int x1, int y1, int x2, int y2) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
/*
* Feature in Quartz. Drawing a one-pixel line produces no output. The
* fix is to fill a one-pixel rectangle instead.
@@ -495,12 +520,13 @@
OS.CGContextSetFillColor(handle, data.foreground);
OS.CGContextFillRect(handle, rect);
OS.CGContextSetFillColor(handle, data.background);
- return;
+ } else {
+ OS.CGContextBeginPath(handle);
+ OS.CGContextMoveToPoint(handle, x1+0.5f, y1+0.5f);
+ OS.CGContextAddLineToPoint(handle, x2+0.5f, y2+0.5f);
+ OS.CGContextStrokePath(handle);
}
- OS.CGContextBeginPath(handle);
- OS.CGContextMoveToPoint(handle, x1+0.5f, y1+0.5f);
- OS.CGContextAddLineToPoint(handle, x2+0.5f, y2+0.5f);
- OS.CGContextStrokePath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -526,6 +552,7 @@
*/
public void drawOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
if (width < 0) {
x = x + width;
width = -width;
@@ -542,6 +569,7 @@
OS.CGContextAddArc(handle, 0, 0, 1, 0, (float)(2 *Math.PI), true);
OS.CGContextRestoreGState(handle);
OS.CGContextStrokePath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -564,6 +592,7 @@
public void drawPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (data.updateClip) setCGClipping();
float[] points = new float[pointArray.length];
for (int i=0; i<points.length; i++) {
points[i] = pointArray[i];
@@ -572,6 +601,7 @@
OS.CGContextAddLines(handle, points, points.length / 2);
OS.CGContextClosePath(handle);
OS.CGContextStrokePath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -594,6 +624,7 @@
public void drawPolyline(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (data.updateClip) setCGClipping();
float[] points = new float[pointArray.length];
for (int i=0; i<points.length; i++) {
points[i] = pointArray[i];
@@ -601,6 +632,7 @@
OS.CGContextBeginPath(handle);
OS.CGContextAddLines(handle, points, points.length / 2);
OS.CGContextStrokePath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -620,6 +652,7 @@
*/
public void drawRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
if (width < 0) {
x = x + width;
width = -width;
@@ -634,6 +667,7 @@
rect.width = width;
rect.height = height;
OS.CGContextStrokeRect(handle, rect);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -678,6 +712,7 @@
*/
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 (data.updateClip) setCGClipping();
if (arcWidth == 0 || arcHeight == 0) {
drawRectangle(x, y, width, height);
return;
@@ -696,6 +731,7 @@
OS.CGContextClosePath(handle);
OS.CGContextRestoreGState(handle);
OS.CGContextStrokePath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -743,6 +779,7 @@
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);
+ if (data.updateClip) setCGClipping();
int length = string.length();
if (length == 0) return;
OS.CGContextSaveGState(handle);
@@ -768,6 +805,7 @@
OS.CGContextShowTextAtPoint(handle, x, -(y + data.fontAscent), buffer, buffer.length);
}
OS.CGContextRestoreGState(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -912,6 +950,7 @@
*/
public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
if (width < 0) {
x = x + width;
width = -width;
@@ -932,6 +971,7 @@
OS.CGContextClosePath(handle);
OS.CGContextRestoreGState(handle);
OS.CGContextFillPath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -1007,6 +1047,7 @@
*/
public void fillOval(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
if (width < 0) {
x = x + width;
width = -width;
@@ -1024,6 +1065,7 @@
OS.CGContextClosePath(handle);
OS.CGContextRestoreGState(handle);
OS.CGContextFillPath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -1048,6 +1090,7 @@
public void fillPolygon(int[] pointArray) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (data.updateClip) setCGClipping();
float[] points = new float[pointArray.length];
for (int i=0; i<points.length; i++) {
points[i] = pointArray[i];
@@ -1056,6 +1099,7 @@
OS.CGContextAddLines(handle, points, points.length / 2);
OS.CGContextClosePath(handle);
OS.CGContextFillPath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -1075,6 +1119,7 @@
*/
public void fillRectangle(int x, int y, int width, int height) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
if (width < 0) {
x = x + width;
width = -width;
@@ -1089,6 +1134,7 @@
rect.width = width;
rect.height = height;
OS.CGContextFillRect(handle, rect);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -1131,6 +1177,7 @@
*/
public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (data.updateClip) setCGClipping();
if (arcWidth == 0 || arcHeight == 0) {
fillRectangle(x, y, width, height);
return;
@@ -1149,6 +1196,7 @@
OS.CGContextClosePath(handle);
OS.CGContextRestoreGState(handle);
OS.CGContextFillPath(handle);
+ if (data.control != 0 && data.paintEvent == 0) OS.CGContextSynchronize(handle);
}
/**
@@ -1370,6 +1418,12 @@
return data.lineWidth;
}
+//3.0 API
+//public int getStyle () {
+// if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+// return data.style;
+//}
+
/**
* Returns <code>true</code> if this GC is drawing in the mode
* where the resulting color in the destination is the
@@ -1499,7 +1553,7 @@
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));
- setCGClipping();
+ data.updateClip = true;
}
/**
@@ -1526,7 +1580,7 @@
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));
}
- setCGClipping();
+ data.updateClip = true;
}
/**
@@ -1553,10 +1607,11 @@
if (data.clipRgn == 0) data.clipRgn = OS.NewRgn();
OS.CopyRgn(region.handle, data.clipRgn);
}
- setCGClipping();
+ data.updateClip = true;
}
void setCGClipping () {
+ data.updateClip = false;
if (data.control == 0) {
OS.CGContextScaleCTM(handle, 1, -1);
if (data.clipRgn != 0) {
@@ -1575,13 +1630,12 @@
int window = OS.GetControlOwner(data.control);
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);
+ Rect portRect = data.portRect;
+ Rect rect = data.controlRect;
+ OS.CGContextTranslateCTM(handle, -rect.left, (portRect.bottom - portRect.top) - rect.top);
OS.CGContextScaleCTM(handle, 1, -1);
+ OS.GetPortBounds(port, portRect);
+ OS.GetControlBounds(data.control, rect);
if (data.clipRgn != 0) {
int rgn = OS.NewRgn();
OS.CopyRgn(data.clipRgn, rgn);
@@ -1593,7 +1647,7 @@
OS.ClipCGContextToRegion(handle, portRect, data.visibleRgn);
}
OS.CGContextScaleCTM(handle, 1, -1);
- OS.CGContextTranslateCTM(handle, rect.left, -portHeight + rect.top);
+ OS.CGContextTranslateCTM(handle, rect.left, -(portRect.bottom - portRect.top) + rect.top);
}
/**
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 59ecb34..17558f1 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
@@ -12,6 +12,7 @@
import org.eclipse.swt.*;
+import org.eclipse.swt.internal.carbon.Rect;
/**
* Instances of this class are descriptions of GCs in terms
@@ -25,6 +26,7 @@
*/
public final class GCData {
public Device device;
+ public int style;
public Image image;
public float[] foreground;
public float[] background;
@@ -42,8 +44,12 @@
public String string;
public int stringPtr;
+ public int window;
public int paintEvent;
public int visibleRgn;
public int control;
public int port;
+ public Rect portRect;
+ public Rect controlRect;
+ public boolean updateClip;
}
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 b0422c3..004cc2a 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
@@ -832,6 +832,10 @@
OS.CGContextTranslateCTM(context, 0, -height);
OS.CGContextSetShouldSmoothFonts(context, false);
if (data != null) {
+ int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ if ((data.style & mask) == 0) {
+ data.style |= SWT.LEFT_TO_RIGHT;
+ }
data.device = device;
data.background = device.COLOR_WHITE.handle;
data.foreground = device.COLOR_BLACK.handle;
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 562c125..b5d4792 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
@@ -14,7 +14,6 @@
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.*;
@@ -136,6 +135,10 @@
return style;
}
+void click () {
+ postEvent (SWT.Selection);
+}
+
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
// NEEDS WORK - empty string
@@ -151,33 +154,28 @@
int width = 0, height = 0;
if (isImage && image != null) {
- Rectangle bounds = image.getBounds();
+ Rectangle bounds = image.getBounds ();
width = bounds.width;
height = bounds.height;
} else {
int [] ptr = new int [1];
- OS.CopyControlTitleAsCFString(handle, ptr);
+ OS.CopyControlTitleAsCFString (handle, ptr);
if (ptr [0] != 0) {
+ org.eclipse.swt.internal.carbon.Point ioBounds = new org.eclipse.swt.internal.carbon.Point ();
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;
+ OS.GetThemeTextDimensions (ptr [0], (short)OS.kThemePushButtonFont, OS.kThemeStateActive, false, ioBounds, null);
} 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;
+ int [] currentPort = new int [1];
+ OS.GetPort (currentPort);
+ OS.SetPortWindowPort (OS.GetControlOwner (handle));
+ OS.TextFont (font.id);
+ OS.TextFace (font.style);
+ OS.TextSize (font.size);
+ OS.GetThemeTextDimensions (ptr [0], (short) OS.kThemeCurrentPortFont, OS.kThemeStateActive, false, ioBounds, null);
+ OS.SetPort (currentPort [0]);
}
+ width = ioBounds.h;
+ height = ioBounds.v;
OS.CFRelease (ptr [0]);
} else {
width = DEFAULT_WIDTH;
@@ -190,7 +188,7 @@
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);
+ height = Math.max (outMetric [0], height);
} else {
if ((style & SWT.FLAT) != 0 || (style & SWT.TOGGLE) != 0) {
width += 10;
@@ -412,7 +410,6 @@
Rect getInset () {
if ((style & SWT.PUSH) == 0) return super.getInset();
- Display display = getDisplay ();
return display.buttonInset;
}
@@ -581,6 +578,9 @@
public void setImage (Image image) {
checkWidget();
if ((style & SWT.ARROW) != 0) return;
+ if (image != null && image.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
if (cIcon != 0) {
destroyCIcon(cIcon);
cIcon = 0;
@@ -697,4 +697,8 @@
redraw ();
}
+int traversalCode (int key, int theEvent) {
+ return super.traversalCode (key, theEvent) | SWT.TRAVERSE_MNEMONIC;
+}
+
}
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 cfe5a27..67fde4a 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
@@ -83,7 +83,6 @@
void createWidget () {
super.createWidget ();
- Display display = parent.getDisplay ();
blinkRate = display.getCaretBlinkTime ();
isVisible = true;
if (parent.getCaret () == null) {
@@ -109,7 +108,7 @@
OS.GetPort (currentPort);
OS.SetPort (port);
int oldClip = OS.NewRgn ();
- int visibleRgn = getVisibleRegion (parentHandle, true);
+ int visibleRgn = parent.getVisibleRegion (parentHandle, true);
OS.GetClip (oldClip);
OS.SetClip (visibleRgn);
Rect rect = new Rect ();
@@ -150,12 +149,6 @@
return new Rectangle (x, y, width, height);
}
-public Display getDisplay () {
- Composite parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
/**
* Returns the font that the receiver will use to paint textual information.
*
@@ -285,12 +278,10 @@
}
boolean isFocusCaret () {
- Display display = getDisplay ();
return this == display.currentCaret;
}
void killFocus () {
- Display display = getDisplay ();
if (display.currentCaret != this) return;
display.setCurrentCaret (null);
if (isVisible) hideCaret ();
@@ -303,7 +294,6 @@
void releaseWidget () {
super.releaseWidget ();
- Display display = getDisplay ();
if (display.currentCaret == this) {
hideCaret ();
display.setCurrentCaret (null);
@@ -359,7 +349,6 @@
}
void setFocus () {
- Display display = getDisplay ();
if (display.currentCaret == this) return;
display.setCurrentCaret (this);
if (isVisible) showCaret ();
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 db80f4c..d633ecb 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
@@ -435,9 +435,6 @@
* 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>
@@ -778,7 +775,6 @@
void hookEvents () {
super.hookEvents ();
if ((style & SWT.READ_ONLY) != 0) {
- Display display = getDisplay ();
int commandProc = display.commandProc;
int [] mask = new int [] {
OS.kEventClassCommand, OS.kEventProcessCommand,
@@ -840,7 +836,6 @@
}
Rect getInset () {
- Display display = getDisplay ();
return display.comboInset;
}
@@ -876,33 +871,6 @@
return OS.eventNotHandledErr;
}
-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.
- */
- 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
- Display display = getDisplay ();
- display.ignoreFocus = true;
- int window = OS.GetControlOwner (handle);
- OS.SetKeyboardFocus(window, handle, (short)OS.kControlFocusNoPart);
- int result = OS.CallNextEventHandler (nextHandler, theEvent);
- OS.SetKeyboardFocus(window, handle, (short)OS.kHIComboBoxEditTextPart);
- display.ignoreFocus = false;
- return result;
- }
- }
- return super.kEventRawKeyDown (nextHandler, theEvent, userData);
-}
-
/**
* Pastes text from clipboard.
* <p>
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 751f784..6447634 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
@@ -42,6 +42,7 @@
public class Composite extends Scrollable {
Layout layout;
Control[] tabList;
+ int scrolledVisibleRgn, siblingsVisibleRgn;
Composite () {
/* Do nothing */
@@ -200,9 +201,9 @@
void drawBackground (int control) {
if (control == scrolledHandle) {
if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) {
- drawFocus (control, hasFocus (), hasBorder (), inset ());
+ drawFocus (control, hasFocus (), hasBorder (), getParentBackground (), inset ());
} else {
- drawBackground (control, null);
+ drawBackground (control, getParentBackground ());
}
} else {
if ((state & CANVAS) != 0) {
@@ -301,6 +302,29 @@
return tabList;
}
+int getVisibleRegion (int control, boolean clipChildren) {
+ if (!clipChildren && control == handle) {
+ if (siblingsVisibleRgn == 0) {
+ siblingsVisibleRgn = OS.NewRgn ();
+ calculateVisibleRegion (control, siblingsVisibleRgn, clipChildren);
+ }
+ int result = OS.NewRgn ();
+ OS.CopyRgn (siblingsVisibleRgn, result);
+ return result;
+ }
+ if (control == scrolledHandle) {
+ if (!clipChildren) return super.getVisibleRegion (control, clipChildren);
+ if (scrolledVisibleRgn == 0) {
+ scrolledVisibleRgn = OS.NewRgn ();
+ calculateVisibleRegion (control, scrolledVisibleRgn, clipChildren);
+ }
+ int result = OS.NewRgn ();
+ OS.CopyRgn (scrolledVisibleRgn, result);
+ return result;
+ }
+ return super.getVisibleRegion (control, clipChildren);
+}
+
int kEventControlClick (int nextHandler, int theEvent, int userData) {
int result = super.kEventControlClick (nextHandler, theEvent, userData);
if (result == OS.noErr) return result;
@@ -332,16 +356,16 @@
if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) {
short [] part = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part);
- drawFocusClipped (scrolledHandle, part [0] != 0, hasBorder (), inset ());
+ drawFocusClipped (scrolledHandle, part [0] != 0, hasBorder (), getParentBackground (), inset ());
}
}
return OS.noErr;
}
return result;
}
-int kEventRawKeyDown (int nextHandler, int theEvent, int userData) {
- int result = super.kEventRawKeyDown (nextHandler, theEvent, userData);
- //TEMPORARY CODE - need to revisit when traversal fully implemented
+
+int kEventRawKey (int nextHandler, int theEvent, int userData) {
+ int result = super.kEventRawKey (nextHandler, theEvent, userData);
if ((state & CANVAS) != 0) {
int [] keyCode = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode);
@@ -357,10 +381,20 @@
}
return result;
}
+
boolean hooksKeys () {
return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
}
+void invalidateChildrenVisibleRegion (int control) {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ child.resetVisibleRegion (control);
+ child.invalidateChildrenVisibleRegion (control);
+ }
+}
+
/**
* 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.
@@ -426,10 +460,25 @@
void releaseWidget () {
releaseChildren ();
super.releaseWidget ();
+ if (scrolledVisibleRgn != 0) OS.DisposeRgn (scrolledVisibleRgn);
+ if (siblingsVisibleRgn != 0) OS.DisposeRgn (siblingsVisibleRgn);
+ siblingsVisibleRgn = scrolledVisibleRgn = 0;
layout = null;
tabList = null;
}
+void resetVisibleRegion (int control) {
+ if (scrolledVisibleRgn != 0) {
+ OS.DisposeRgn (scrolledVisibleRgn);
+ scrolledVisibleRgn = 0;
+ }
+ if (siblingsVisibleRgn != 0) {
+ OS.DisposeRgn (siblingsVisibleRgn);
+ siblingsVisibleRgn = 0;
+ }
+ super.resetVisibleRegion (control);
+}
+
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);
@@ -462,6 +511,33 @@
this.layout = layout;
}
+boolean setTabItemFocus () {
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus) {
+ if (!isShowing ()) return false;
+ if (forceFocus ()) return true;
+ }
+ }
+ return super.setTabItemFocus ();
+}
+
+boolean setTabGroupFocus () {
+ if (isTabItem ()) return setTabItemFocus ();
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus && setTabItemFocus ()) return true;
+ }
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabItem () && child.setTabItemFocus ()) return true;
+ }
+ return false;
+}
+
/**
* Sets the tabbing order for the specified controls to
* match the order that they occur in the argument list.
@@ -508,4 +584,12 @@
if (scrolledHandle != 0) OS.HIViewAddSubview (scrolledHandle, handle);
}
+int traversalCode (int key, int theEvent) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return 0;
+ if (hooksKeys ()) return 0;
+ }
+ return super.traversalCode (key, theEvent);
+}
+
}
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 9a2f7ca..96ff54d 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
@@ -51,11 +51,12 @@
Composite parent;
String toolTipText;
Object layoutData;
- int drawCount;
+ int drawCount, visibleRgn;
Menu menu;
float [] foreground, background;
Font font;
Cursor cursor;
+ GCData gcs[];
Accessible accessible;
Control () {
@@ -346,6 +347,7 @@
return OS.noErr;
}
case OS.kControlMsgSetUpBackground: {
+ float [] background = this.background != null ? this.background : getParentBackground ();
if (background != null) {
OS.RGBBackColor (toRGBColor (background));
} else {
@@ -470,7 +472,6 @@
}
Color defaultBackground () {
- Display display = getDisplay ();
return display.getSystemColor (SWT.COLOR_WHITE);
}
@@ -482,11 +483,10 @@
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]);
+ return Font.carbon_new (display, font [0], id, style [0], size [0]);
}
Color defaultForeground () {
- Display display = getDisplay ();
return display.getSystemColor (SWT.COLOR_BLACK);
}
@@ -499,7 +499,8 @@
WidgetTable.remove (handle);
}
-void destroyWidget (Display display) {
+void destroyWidget () {
+ Display display = this.display;
int theControl = topHandle ();
releaseHandle ();
if (theControl != 0) {
@@ -581,6 +582,9 @@
if (!isEnabled () || !isVisible ()/* || !isActive ()*/) return false;
if (isFocusControl ()) return true;
shell.bringToTop ();
+ int [] features = new int [1];
+ OS.GetControlFeatures (handle, features);
+ if ((features [0] & OS.kControlSupportsFocus) == 0) return false;
int window = OS.GetControlOwner (handle);
return OS.SetKeyboardFocus (window, handle, (short)OS.kControlFocusNextPart) == OS.noErr;
}
@@ -624,7 +628,7 @@
checkWidget();
//NOT DONE - get default colors
if (background == null) return defaultBackground ();
- return Color.carbon_new (getDisplay (), background);
+ return Color.carbon_new (display, background);
}
/**
@@ -659,22 +663,6 @@
return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
-/**
- * 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>
- */
-public Display getDisplay () {
- Composite parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
int getDrawCount (int control) {
if (!isTrimHandle (control) && drawCount > 0) return drawCount;
return parent.getDrawCount (control);
@@ -729,7 +717,7 @@
checkWidget();
//NOT DONE - get default colors
if (foreground == null) return defaultForeground ();
- return Color.carbon_new (getDisplay (), foreground);
+ return Color.carbon_new (display, foreground);
}
/**
@@ -801,6 +789,10 @@
return parent;
}
+float [] getParentBackground () {
+ return parent.background;
+}
+
Control [] getPath () {
int count = 0;
Shell shell = getShell ();
@@ -895,12 +887,22 @@
return (state & HIDDEN) == 0;
}
+int getVisibleRegion (int control, boolean clipChildren) {
+ if (!clipChildren) return super.getVisibleRegion (control, clipChildren);
+ if (visibleRgn == 0) {
+ visibleRgn = OS.NewRgn ();
+ calculateVisibleRegion (control, visibleRgn, clipChildren);
+ }
+ int result = OS.NewRgn ();
+ OS.CopyRgn (visibleRgn, result);
+ return result;
+}
+
boolean hasFocus () {
- return this == getDisplay ().getFocusControl ();
+ return this == display.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};
@@ -974,7 +976,6 @@
void hookEvents () {
super.hookEvents ();
- Display display = getDisplay ();
int controlProc = display.controlProc;
int [] mask = new int [] {
OS.kEventClassControl, OS.kEventControlActivate,
@@ -1012,7 +1013,6 @@
*/
public int internal_new_GC (GCData data) {
checkWidget();
- int visibleRgn = 0;
int port = data != null ? data.port : 0;
if (port == 0) {
int window = OS.GetControlOwner (handle);
@@ -1021,34 +1021,50 @@
int [] buffer = new int [1];
OS.CreateCGContextForPort (port, buffer);
int context = buffer [0];
- if (context != 0) {
- Rect rect = new Rect ();
- OS.GetControlBounds (handle, rect);
- Rect portRect = new Rect ();
- OS.GetPortBounds (port, portRect);
- if (data != null && data.paintEvent != 0) {
- visibleRgn = data.visibleRgn;
- } else {
- if (getDrawCount (handle) > 0) {
- visibleRgn = OS.NewRgn ();
- } else {
- visibleRgn = getVisibleRegion (handle, true);
- }
- }
- OS.ClipCGContextToRegion (context, portRect, visibleRgn);
- int portHeight = portRect.bottom - portRect.top;
- OS.CGContextScaleCTM (context, 1, -1);
- OS.CGContextTranslateCTM (context, rect.left, -portHeight + rect.top);
- }
if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ int visibleRgn = 0;
+ if (data != null && data.paintEvent != 0) {
+ visibleRgn = data.visibleRgn;
+ } else {
+ if (getDrawCount (handle) > 0) {
+ visibleRgn = OS.NewRgn ();
+ } else {
+ visibleRgn = getVisibleRegion (handle, true);
+ }
+ }
+ Rect rect = new Rect ();
+ Rect portRect = new Rect ();
+ OS.GetControlBounds (handle, rect);
+ OS.GetPortBounds (port, portRect);
+ OS.ClipCGContextToRegion (context, portRect, visibleRgn);
+ int portHeight = portRect.bottom - portRect.top;
+ OS.CGContextScaleCTM (context, 1, -1);
+ OS.CGContextTranslateCTM (context, rect.left, -portHeight + rect.top);
if (data != null) {
- Display display = getDisplay ();
+ int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ if ((data.style & mask) == 0) {
+ data.style |= style & (mask | SWT.MIRRORED);
+ }
data.device = display;
- data.foreground = foreground != null ? foreground : new float [] {0, 0, 0, 1};
data.background = background != null ? background : new float [] {1, 1, 1, 1};
+ data.foreground = foreground != null ? foreground : new float [] {0, 0, 0, 1};
data.font = font != null ? font : defaultFont ();
data.visibleRgn = visibleRgn;
data.control = handle;
+ data.portRect = portRect;
+ data.controlRect = rect;
+
+ if (data.paintEvent == 0) {
+ if (gcs == null) gcs = new GCData [4];
+ int index = 0;
+ while (index < gcs.length && gcs [index] != null) index++;
+ if (index == gcs.length) {
+ GCData [] newGCs = new GCData [gcs.length + 4];
+ System.arraycopy (gcs, 0, newGCs, 0, gcs.length);
+ gcs = newGCs;
+ }
+ gcs [index] = data;
+ }
}
return context;
}
@@ -1068,10 +1084,21 @@
*/
public void internal_dispose_GC (int context, GCData data) {
checkWidget ();
- if (data != null && data.paintEvent == 0) {
- if (data.visibleRgn != 0) {
- OS.DisposeRgn (data.visibleRgn);
- data.visibleRgn = 0;
+ if (data != null) {
+ if (data.paintEvent == 0) {
+ if (data.visibleRgn != 0) {
+ OS.DisposeRgn (data.visibleRgn);
+ data.visibleRgn = 0;
+ }
+
+ int index = 0;
+ while (index < gcs.length && gcs [index] != data) index++;
+ if (index < gcs.length) {
+ gcs [index] = null;
+ index = 0;
+ while (index < gcs.length && gcs [index] == null) index++;
+ if (index == gcs.length) gcs = null;
+ }
}
}
@@ -1080,11 +1107,25 @@
* instead of CGContextFlush to improve performance.
*/
// OS.CGContextFlush (context);
- OS.CGContextSynchronize(context);
-
+ OS.CGContextSynchronize (context);
OS.CGContextRelease (context);
}
+void invalidateChildrenVisibleRegion (int control) {
+}
+
+void invalidateVisibleRegion (int control) {
+ int index = 0;
+ Control[] siblings = parent._getChildren ();
+ while (index < siblings.length && siblings [index] != this) index++;
+ for (int i=index; i<siblings.length; i++) {
+ Control sibling = siblings [i];
+ sibling.resetVisibleRegion (control);
+ sibling.invalidateChildrenVisibleRegion (control);
+ }
+ parent.resetVisibleRegion (control);
+}
+
/**
* Returns <code>true</code> if the receiver is enabled and all
* of the receiver's ancestors are enabled, and <code>false</code>
@@ -1107,7 +1148,6 @@
boolean isEnabledModal () {
//NOT DONE - fails for multiple APP MODAL shells
- Display display = getDisplay ();
Shell [] shells = display.getShells ();
for (int i = 0; i < shells.length; i++) {
Shell modal = shells [i];
@@ -1133,7 +1173,6 @@
}
boolean isFocusAncestor () {
- Display display = getDisplay ();
Control control = display.getFocusControl ();
while (control != null && control != this) {
control = control.parent;
@@ -1173,12 +1212,44 @@
return false;
}
+boolean isShowing () {
+ /*
+ * This is not complete. Need to check if the
+ * widget is obscurred by a parent or sibling.
+ */
+ if (!isVisible ()) return false;
+ Control control = this;
+ while (control != null) {
+ Point size = control.getSize ();
+ if (size.x == 0 || size.y == 0) {
+ return false;
+ }
+ control = control.parent;
+ }
+ return true;
+}
+
boolean isTabGroup () {
- return false;
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
+ int code = traversalCode (0, 0);
+ if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
+ return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
}
boolean isTabItem () {
- return false;
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
+ int code = traversalCode (0, 0);
+ return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
}
/**
@@ -1205,15 +1276,26 @@
}
int kEventControlContextualMenuClick (int nextHandler, int theEvent, int userData) {
- if (menu != null && !menu.isDisposed ()) {
- int sizeof = org.eclipse.swt.internal.carbon.Point.sizeof;
- org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point ();
- OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, 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);
+ int sizeof = org.eclipse.swt.internal.carbon.Point.sizeof;
+ org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point ();
+ OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, sizeof, null, pt);
+ Rect rect = new Rect ();
+ int window = OS.GetControlOwner (handle);
+ OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
+ int x = pt.h + rect.left;
+ int y = pt.v + rect.top;
+ Event event = new Event ();
+ event.x = x;
+ event.y = y;
+ //3.0 API
+// sendEvent (SWT.MenuDetect);
+ if (event.doit) {
+ if (menu != null && !menu.isDisposed ()) {
+ if (event.x != x || event.y != y) {
+ menu.setLocation (event.x, event.y);
+ }
+ menu.setVisible (true);
+ }
}
return OS.eventNotHandledErr;
}
@@ -1222,17 +1304,16 @@
if (!isEnabled ()) return OS.noErr;
Cursor cursor = null;
if (isEnabledModal ()) {
- if ((cursor = findCursor ()) != null) setCursor (cursor.handle);
+ if ((cursor = findCursor ()) != null) display.setCursor (cursor.handle);
}
return cursor != null ? OS.noErr : OS.eventNotHandledErr;
}
int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) {
- Display display = getDisplay ();
if (!display.ignoreFocus) {
short [] part = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part);
- sendFocusEvent (part [0] != 0);
+ sendFocusEvent (part [0] != 0, false);
}
return OS.eventNotHandledErr;
}
@@ -1248,10 +1329,7 @@
OS.GetEventParameter (theEvent, OS.kEventParamClickCount, OS.typeUInt32, null, 4, null, clickCount);
sendMouseEvent (SWT.MouseDown, theEvent);
if (clickCount [0] == 2) sendMouseEvent (SWT.MouseDoubleClick, theEvent);
- if ((state & GRAB) != 0) {
- Display display = getDisplay ();
- display.grabControl = this;
- }
+ if ((state & GRAB) != 0) display.grabControl = this;
/*
* It is possible that the shell may be
* disposed at this point. If this happens
@@ -1261,11 +1339,19 @@
if (!shell.isDisposed ()) {
shell.setActiveControl (this);
}
+ if (hooks (SWT.DragDetect)) {
+ org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point ();
+ int sizeof = org.eclipse.swt.internal.carbon.Point.sizeof;
+ OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, sizeof, null, pt);
+ display.dragMouseStart = pt;
+ display.dragging = false;
+ }
return OS.eventNotHandledErr;
}
int kEventMouseDragged (int nextHandler, int theEvent, int userData) {
if (isEnabledModal ()) sendMouseEvent (SWT.MouseMove, theEvent);
+ display.dragDetect (this);
return OS.eventNotHandledErr;
}
@@ -1279,9 +1365,10 @@
return OS.eventNotHandledErr;
}
-int kEventRawKeyDown (int nextHandler, int theEvent, int userData) {
+int kEventRawKey (int nextHandler, int theEvent, int userData) {
int [] keyCode = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode);
+ if (translateTraversal (keyCode [0], theEvent)) return OS.noErr;
if (keyCode [0] == 114) { /* Help */
Control control = this;
while (control != null) {
@@ -1296,10 +1383,13 @@
return OS.eventNotHandledErr;
}
+int kEventRawKeyDown (int nextHandler, int theEvent, int userData) {
+ return kEventRawKey (nextHandler, theEvent, userData);
+}
+
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 ();
int lastModifiers = display.lastModifiers;
int type = SWT.KeyUp;
if ((modifiers [0] & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) type = SWT.KeyDown;
@@ -1312,8 +1402,7 @@
}
int kEventRawKeyRepeat (int nextHandler, int theEvent, int userData) {
- if (!sendKeyEvent (SWT.KeyDown, theEvent)) return OS.noErr;
- return OS.eventNotHandledErr;
+ return kEventRawKey (nextHandler, theEvent, userData);
}
int kEventRawKeyUp (int nextHandler, int theEvent, int userData) {
@@ -1474,6 +1563,8 @@
if (menu != null && !menu.isDisposed ()) {
menu.dispose ();
}
+ if (visibleRgn != 0) OS.DisposeRgn (visibleRgn);
+ visibleRgn = 0;
menu = null;
parent = null;
layoutData = null;
@@ -1701,13 +1792,31 @@
if (eventTable == null) return;
eventTable.unhook (SWT.Traverse, listener);
}
-
-void sendFocusEvent (boolean focusIn) {
+
+void resetVisibleRegion (int control) {
+ if (visibleRgn != 0) {
+ OS.DisposeRgn (visibleRgn);
+ visibleRgn = 0;
+ }
+ if (gcs != null) {
+ int visibleRgn = getVisibleRegion (handle, true);
+ for (int i=0; i<gcs.length; i++) {
+ GCData data = gcs [i];
+ if (data != null) {
+ data.updateClip = true;
+ OS.CopyRgn (visibleRgn, data.visibleRgn);
+ }
+ }
+ OS.DisposeRgn (visibleRgn);
+ }
+}
+
+void sendFocusEvent (boolean focusIn, boolean post) {
Shell shell = getShell ();
- if (focusIn) {
- sendEvent (SWT.FocusIn);
+ if (post) {
+ postEvent (focusIn ? SWT.FocusIn : SWT.FocusOut);
} else {
- sendEvent (SWT.FocusOut);
+ sendEvent (focusIn ? SWT.FocusIn : SWT.FocusOut);
}
/*
@@ -1716,13 +1825,11 @@
* don't send the activate and deactivate
* events.
*/
- if (focusIn) {
- if (!shell.isDisposed ()) {
+ if (!shell.isDisposed ()) {
+ if (focusIn) {
shell.setActiveControl (this);
- }
- } else {
- if (!shell.isDisposed ()) {
- Display display = shell.getDisplay ();
+ } else {
+ Display display = shell.display;
Control control = display.getFocusControl ();
if (control == null || shell != control.getShell () ) {
shell.setActiveControl (null);
@@ -1799,10 +1906,24 @@
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
background = color != null ? color.handle : null;
- setFontStyle (font);
+ setBackground (background);
redrawWidget (handle, false);
}
+void setBackground (float [] color) {
+ ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
+ OS.GetControlData (handle, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
+ if (background != null) {
+ fontStyle.backColor_red = (short) (background [0] * 0xffff);
+ fontStyle.backColor_green = (short) (background [1] * 0xffff);
+ fontStyle.backColor_blue = (short) (background [2] * 0xffff);
+ fontStyle.flags |= OS.kControlUseBackColorMask;
+ } else {
+ fontStyle.flags &= ~OS.kControlUseBackColorMask;
+ }
+ OS.SetControlFontStyle (handle, fontStyle);
+}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
@@ -1939,25 +2060,6 @@
if (!cursorWasSet [0]) OS.SetThemeCursor (OS.kThemeArrowCursor);
}
-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);
- }
-}
-
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -2037,6 +2139,7 @@
void setFontStyle (Font font) {
ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
+ OS.GetControlData (handle, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
if (font != null) {
fontStyle.flags |= OS.kControlUseFontMask | OS.kControlUseSizeMask | OS.kControlUseFaceMask;
fontStyle.font = font.id;
@@ -2046,28 +2149,6 @@
fontStyle.flags |= OS.kControlUseThemeFontIDMask;
fontStyle.font = (short) defaultThemeFont ();
}
- if (background != null) {
- int red = (short) (background [0] * 255);
- int green = (short) (background [1] * 255);
- int blue = (short) (background [2] * 255);
- fontStyle.backColor_red = (short) (red << 8 | red);
- fontStyle.backColor_green = (short) (green << 8 | green);
- fontStyle.backColor_blue = (short) (blue << 8 | blue);
- fontStyle.flags |= OS.kControlUseBackColorMask;
- } else {
- fontStyle.flags &= ~OS.kControlUseBackColorMask;
- }
- if (foreground != null) {
- int red = (short) (foreground [0] * 255);
- int green = (short) (foreground [1] * 255);
- int blue = (short) (foreground [2] * 255);
- fontStyle.foreColor_red = (short) (red << 8 | red);
- fontStyle.foreColor_green = (short) (green << 8 | green);
- fontStyle.foreColor_blue = (short) (blue << 8 | blue);
- fontStyle.flags |= OS.kControlUseForeColorMask;
- } else {
- fontStyle.flags &= ~OS.kControlUseForeColorMask;
- }
OS.SetControlFontStyle (handle, fontStyle);
}
@@ -2092,10 +2173,24 @@
if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
foreground = color != null ? color.handle : null;
- setFontStyle (font);
+ setForeground (foreground);
redrawWidget (handle, false);
}
+void setForeground (float [] color) {
+ ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
+ OS.GetControlData (handle, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
+ if (foreground != null) {
+ fontStyle.foreColor_red = (short) (foreground [0] * 0xffff);
+ fontStyle.foreColor_green = (short) (foreground [1] * 0xffff);
+ fontStyle.foreColor_blue = (short) (foreground [2] * 0xffff);
+ fontStyle.flags |= OS.kControlUseForeColorMask;
+ } else {
+ fontStyle.flags &= ~OS.kControlUseForeColorMask;
+ }
+ OS.SetControlFontStyle (handle, fontStyle);
+}
+
/**
* Sets the layout data associated with the receiver to the argument.
*
@@ -2228,9 +2323,13 @@
checkWidget();
if (redraw) {
if (--drawCount == 0) {
+ invalidateVisibleRegion (handle);
redrawWidget (handle, true);
}
} else {
+ if (drawCount == 0) {
+ invalidateVisibleRegion (handle);
+ }
drawCount++;
}
}
@@ -2285,11 +2384,12 @@
}
boolean setTabGroupFocus () {
- return false;
+ return setTabItemFocus ();
}
boolean setTabItemFocus () {
- return false;
+ if (!isShowing ()) return false;
+ return setFocus ();
}
/**
@@ -2380,25 +2480,8 @@
}
void setZOrder (Control control, boolean above) {
- int inOp = above ? OS.kHIViewZOrderBelow : OS.kHIViewZOrderAbove;
- int inOther = control == null ? 0 : control.topHandle ();
- int oldRgn = 0;
- int topHandle = topHandle ();
- boolean drawing = isDrawing (topHandle);
- if (drawing) oldRgn = getVisibleRegion (topHandle, false);
- OS.HIViewSetZOrder (topHandle, inOp, inOther);
- if (drawing) {
- int newRgn = getVisibleRegion (topHandle, false);
- if (above) {
- OS.DiffRgn (newRgn, oldRgn, newRgn);
- } else {
- OS.DiffRgn (oldRgn, newRgn, newRgn);
- }
- int window = OS.GetControlOwner (topHandle);
- OS.InvalWindowRgn (window, newRgn);
- OS.DisposeRgn (oldRgn);
- OS.DisposeRgn (newRgn);
- }
+ int otherControl = control == null ? 0 : control.topHandle ();
+ setZOrder (topHandle (), otherControl, above);
}
void sort (int [] items) {
@@ -2519,6 +2602,102 @@
return handle;
}
+boolean translateTraversal (int key, int theEvent) {
+ int detail = SWT.TRAVERSE_NONE;
+ int code = traversalCode (key, theEvent);
+ boolean all = false;
+ switch (key) {
+ case 53: /* Esc */ {
+ all = true;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ }
+ case 36: /* Return */ {
+ all = true;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ }
+ case 48: /* Tab */ {
+ int [] modifiers = new int [1];
+ OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+ boolean next = (modifiers [0] & OS.shiftKey) == 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.
+ */
+ switch (modifiers [0]) {
+ case OS.controlKey:
+ case OS.shiftKey:
+ code |= SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT;
+ }
+ detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+ break;
+ }
+ case 126: /* Up arrow */
+ case 123: /* Left arrow */
+ case 125: /* Down arrow */
+ case 124: /* Right arrow */ {
+ boolean next = key == 125 /* Down arrow */ || key == 124 /* Right arrow */;
+ detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ }
+ case 116: /* Page up */
+ case 121: /* Page down */ {
+ all = true;
+ int [] modifiers = new int [1];
+ OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+ if ((modifiers [0] & OS.controlKey) == 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 /* Page down */ ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
+ break;
+ }
+ default:
+ return false;
+ }
+ Event event = new Event ();
+ event.doit = (code & detail) != 0;
+ event.detail = detail;
+ setKeyState (event, theEvent);
+ Shell shell = getShell ();
+ Control control = this;
+ do {
+ if (control.traverse (event)) return true;
+ if (!event.doit && control.hooks (SWT.Traverse)) {
+ return false;
+ }
+ if (control == shell) return false;
+ control = control.parent;
+ } while (all && control != null);
+ return false;
+}
+
+int traversalCode (int key, int theEvent) {
+ int [] features = new int [1];
+ OS.GetControlFeatures (handle, features);
+ if ((features [0] & (OS.kControlSupportsEmbedding | OS.kControlSupportsFocus)) == 0) {
+ return 0;
+ }
+ int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
+ Shell shell = getShell ();
+ if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
+ return code;
+}
+
boolean traverseMnemonic (char key) {
return false;
}
@@ -2571,10 +2750,54 @@
}
boolean traverseGroup (boolean next) {
- return false;
+ Control root = computeTabRoot ();
+ Control group = computeTabGroup ();
+ Control [] list = root.computeTabList ();
+ int length = list.length;
+ int index = 0;
+ while (index < length) {
+ if (list [index] == group) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ if (index == length) return false;
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset + length) % length)) != start) {
+ Control control = list [index];
+ if (!control.isDisposed () && control.setTabGroupFocus ()) {
+ if (!isDisposed () && !isFocusControl ()) return true;
+ }
+ }
+ if (group.isDisposed ()) return false;
+ return group.setTabGroupFocus ();
}
boolean traverseItem (boolean next) {
+ Control [] children = parent._getChildren ();
+ int length = children.length;
+ int index = 0;
+ while (index < length) {
+ if (children [index] == this) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = (index + offset + length) % length) != start) {
+ Control child = children [index];
+ if (!child.isDisposed () && child.isTabItem ()) {
+ if (child.setTabItemFocus ()) return true;
+ }
+ }
return false;
}
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 4a21c6d..fa06262 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
@@ -300,7 +300,6 @@
void releaseWidget () {
if (menuBar != null) menuBar.dispose ();
menuBar = null;
- Display display = getDisplay ();
Menu [] menus = display.getMenus (this);
if (menus != null) {
do {
@@ -332,7 +331,7 @@
void saveFocus () {
int window = OS.GetControlOwner (handle);
- Control control = getDisplay ().getFocusControl (window);
+ Control control = display.getFocusControl (window);
if (control != null) savedFocus = control;
}
@@ -504,10 +503,10 @@
* 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
+ * @param string the new text
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <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>
@@ -520,4 +519,15 @@
text = string;
}
+boolean traverseItem (boolean next) {
+ return false;
+}
+
+boolean traverseReturn () {
+ if (defaultButton == null || defaultButton.isDisposed ()) return false;
+ if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
+ defaultButton.click ();
+ return true;
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
index 3ddd296..9ef44f6 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
@@ -16,6 +16,7 @@
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.GDevice;
import org.eclipse.swt.internal.carbon.HICommand;
import org.eclipse.swt.internal.carbon.Rect;
import org.eclipse.swt.internal.carbon.RGBColor;
@@ -99,20 +100,17 @@
* @see #dispose
*/
public class Display extends Device {
-
- //TEMPORARY
- int textHighlightThickness = 4;
/* Windows and Events */
static final int WAKE_CLASS = 0;
static final int WAKE_KIND = 0;
Event [] eventQueue;
Callback actionCallback, appleEventCallback, commandCallback, controlCallback;
- Callback drawItemCallback, itemDataCallback, itemNotificationCallback, helpCallback;
- Callback hitTestCallback, keyboardCallback, menuCallback, mouseHoverCallback;
+ Callback drawItemCallback, itemDataCallback, itemNotificationCallback, itemCompareCallback;
+ Callback hitTestCallback, keyboardCallback, menuCallback, mouseHoverCallback, helpCallback;
Callback mouseCallback, trackingCallback, windowCallback, colorCallback;
int actionProc, appleEventProc, commandProc, controlProc;
- int drawItemProc, itemDataProc, itemNotificationProc, helpProc;
+ int drawItemProc, itemDataProc, itemNotificationProc, itemCompareProc, helpProc;
int hitTestProc, keyboardProc, menuProc, mouseHoverProc;
int mouseProc, trackingProc, windowProc, colorProc;
EventTable eventTable, filterTable;
@@ -130,6 +128,7 @@
Runnable [] timerList;
Callback timerCallback;
int timerProc;
+ boolean allowTimers = true;
/* Current caret */
Caret currentCaret;
@@ -148,11 +147,12 @@
/* Mouse Enter/Exit/Hover */
Control currentControl;
int mouseHoverID;
+ org.eclipse.swt.internal.carbon.Point dragMouseStart = null;
+ boolean dragging = false;
/* Menus */
Menu menuBar;
Menu [] menus, popups;
- MenuItem [] items;
static final int ID_TEMPORARY = 1000;
static final int ID_START = 1001;
@@ -399,22 +399,6 @@
menus = newMenus;
}
-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;
-}
-
void addPopup (Menu menu) {
if (popups == null) popups = new Menu [4];
int length = popups.length;
@@ -469,8 +453,6 @@
}
int caretProc (int id, int clientData) {
- //TEMPORARY CODE
-// if (!allowTimers) return 0;
if (currentCaret == null) return 0;
if (currentCaret.blinkCaret ()) {
int blinkRate = currentCaret.blinkRate;
@@ -502,6 +484,20 @@
if (!Display.isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
}
+int createOverlayWindow () {
+ 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.SetRect (rect, (short) device.left, (short) device.top, (short) device.right, (short) device.bottom);
+ int [] outWindow = new int [1];
+ OS.CreateNewWindow (OS.kOverlayWindowClass, 0, rect, outWindow);
+ if (outWindow [0] == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ return outWindow [0];
+}
+
/**
* Constructs a new instance of this class.
* <p>
@@ -576,7 +572,7 @@
if (menu.closed && menu.modified) {
item = menu.lastTarget;
} else {
- item = findMenuItem (command.commandID);
+ item = menu.getItem (command.menu_menuItemIndex - 1);
}
if (item != null) {
return item.kEventProcessCommand (nextHandler, theEvent, userData);
@@ -747,6 +743,16 @@
disposeList = newDisposeList;
}
+void dragDetect (Control control) {
+ if (!dragging && control.hooks (SWT.DragDetect)) {
+ if (OS.WaitMouseMoved (dragMouseStart)) {
+ dragging = true;
+ //control.postEvent (SWT.DragDetect);
+ control.sendEvent (SWT.DragDetect);
+ }
+ }
+}
+
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);
@@ -774,13 +780,6 @@
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;
-}
-
/**
* Given the operating system handle for a widget, returns
* the instance of the <code>Widget</code> subclass which
@@ -832,8 +831,9 @@
*/
public Shell getActiveShell () {
checkDevice ();
- int theWindow = OS.ActiveNonFloatingWindow ();
+ int theWindow = OS.FrontWindow ();
if (theWindow == 0) return null;
+ if (!OS.IsWindowActive (theWindow)) return null;
int [] theControl = new int [1];
OS.GetRootControl (theWindow, theControl);
Widget widget = WidgetTable.get (theControl [0]);
@@ -841,6 +841,22 @@
return null;
}
+
+//3.0 API
+//public Rectangle getBounds () {
+// checkDevice ();
+// int gdevice = OS.GetDeviceList();
+// if (gdevice == 0 || OS.GetNextDevice (gdevice) == 0) {
+// return super.getBounds ();
+// }
+// Monitor [] monitors = getMonitors ();
+// Rectangle rect = monitors [0].getBounds ();
+// for (int i=1; i<monitors.length; i++) {
+// rect = rect.union (monitors [i].getBounds ());
+// }
+// return rect;
+//}
+
/**
* Returns the display which the currently running thread is
* the user-interface thread for, or null if the currently
@@ -856,6 +872,21 @@
return OS.GetCaretTime () * 1000 / 60;
}
+//3.0 API
+//public Rectangle getClientArea () {
+// checkDevice ();
+// int gdevice = OS.GetDeviceList();
+// if (gdevice == 0 || OS.GetNextDevice (gdevice) == 0) {
+// return super.getClientArea ();
+// }
+// Monitor [] monitors = getMonitors ();
+// Rectangle rect = monitors [0].getBounds ();
+// for (int i=1; i<monitors.length; i++) {
+// rect = rect.union (monitors [i].getBounds ());
+// }
+// return rect;
+//}
+
/**
* Returns the control which the on-screen pointer is currently
* over top of, or null if it is not currently over one of the
@@ -1052,7 +1083,7 @@
*/
public Control getFocusControl () {
checkDevice ();
- int theWindow = OS.ActiveNonFloatingWindow ();
+ int theWindow = OS.GetUserFocusWindow ();
if (theWindow == 0) return null;
return getFocusControl (theWindow);
}
@@ -1120,6 +1151,82 @@
}
/**
+ * Returns an array of monitors attached to the device.
+ *
+ * @return the array of monitors
+ *
+ * @since 3.0
+ */
+//3.0 API
+//public Monitor [] getMonitors () {
+// checkDevice ();
+// int count = 0;
+// Monitor [] monitors = new Monitor [1];
+// Rect rect = new Rect ();
+// GDevice device = new GDevice ();
+// int gdevice = OS.GetDeviceList ();
+// while (gdevice != 0) {
+// if (count >= monitors.length) {
+// Monitor [] newMonitors = new Monitor [monitors.length + 4];
+// System.arraycopy (monitors, 0, newMonitors, 0, monitors.length);
+// monitors = newMonitors;
+// }
+// Monitor monitor = new Monitor ();
+// monitor.handle = gdevice;
+// int [] ptr = new int [1];
+// OS.memcpy (ptr, gdevice, 4);
+// OS.memcpy (device, ptr [0], GDevice.sizeof);
+// monitor.x = device.left;
+// monitor.y = device.top;
+// monitor.width = device.right - device.left;
+// monitor.height = device.bottom - device.top;
+// OS.GetAvailableWindowPositioningBounds (gdevice, rect);
+// monitor.clientX = rect.left;
+// monitor.clientY = rect.top;
+// monitor.clientWidth = rect.right - rect.left;
+// monitor.clientHeight = rect.bottom - rect.top;
+// monitors [count++] = monitor;
+// gdevice = OS.GetNextDevice (gdevice);
+// }
+// if (count < monitors.length) {
+// Monitor [] newMonitors = new Monitor [count];
+// System.arraycopy (monitors, 0, newMonitors, 0, count);
+// monitors = newMonitors;
+// }
+// return monitors;
+//}
+
+/**
+ * Returns the primary monitor for that device.
+ *
+ * @return the primary monitor
+ *
+ * @since 3.0
+ */
+//3.0 API
+//public Monitor getPrimaryMonitor () {
+// checkDevice ();
+// int gdevice = OS.GetMainDevice ();
+// Monitor monitor = new Monitor ();
+// monitor.handle = gdevice;
+// int [] ptr = new int [1];
+// OS.memcpy (ptr, gdevice, 4);
+// GDevice device = new GDevice ();
+// OS.memcpy (device, ptr [0], GDevice.sizeof);
+// monitor.x = device.left;
+// monitor.y = device.top;
+// monitor.width = device.right - device.left;
+// monitor.height = device.bottom - device.top;
+// Rect rect = new Rect ();
+// OS.GetAvailableWindowPositioningBounds (gdevice, rect);
+// monitor.clientX = rect.left;
+// monitor.clientY = rect.top;
+// monitor.clientWidth = rect.right - rect.left;
+// monitor.clientHeight = rect.bottom - rect.top;
+// return monitor;
+//}
+
+/**
* Returns an array containing all shells which have not been
* disposed and have the receiver as their display.
*
@@ -1142,7 +1249,7 @@
Shell [] shells = WidgetTable.shells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
- if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ if (!shell.isDisposed () && this == shell.display) {
count++;
}
}
@@ -1151,7 +1258,7 @@
Shell [] result = new Shell [count];
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
- if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ if (!shell.isDisposed () && this == shell.display) {
result [index++] = shell;
}
}
@@ -1292,6 +1399,9 @@
drawItemCallback = new Callback (this, "drawItemProc", 7);
drawItemProc = drawItemCallback.getAddress ();
if (drawItemProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ itemCompareCallback = new Callback (this, "itemCompareProc", 4);
+ itemCompareProc = itemCompareCallback.getAddress ();
+ if (itemCompareProc == 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);
@@ -1404,17 +1514,27 @@
*/
public int internal_new_GC (GCData data) {
if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- // NEEDS WORK
- int window = OS.FrontWindow ();
+ //TODO - multiple monitors
+ int window = createOverlayWindow ();
+ OS.ShowWindow (window);
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);
+ Rect portRect = new Rect ();
+ OS.GetPortBounds (port, portRect);
+ OS.CGContextScaleCTM (context, 1, -1);
+ OS.CGContextTranslateCTM (context, 0, portRect.top - portRect.bottom);
if (data != null) {
+ int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ if ((data.style & mask) == 0) {
+ data.style |= SWT.LEFT_TO_RIGHT;
+ }
data.device = this;
- data.background = new float [] {0, 0, 0, 1};
- data.foreground = new float [] {1, 1, 1, 1};
+ data.window = window;
+ data.background = new float [] {1, 1, 1, 1};
+ data.foreground = new float [] {0, 0, 0, 1};
data.font = getSystemFont ();
}
return context;
@@ -1435,8 +1555,18 @@
*/
public void internal_dispose_GC (int context, GCData data) {
if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- // NEEDS WORK
- OS.CGContextFlush (context);
+ if (data != null) {
+ int window = data.window;
+ OS.DisposeWindow (window);
+ data.window = 0;
+ }
+
+ /*
+ * This code is intentionaly commented. Use CGContextSynchronize
+ * instead of CGContextFlush to improve performance.
+ */
+// OS.CGContextFlush (context);
+ OS.CGContextSynchronize (context);
OS.CGContextRelease (context);
}
@@ -1450,6 +1580,12 @@
return thread == Thread.currentThread ();
}
+int itemCompareProc (int browser, int itemOne, int itemTwo, int sortProperty) {
+ Widget widget = WidgetTable.get (browser);
+ if (widget != null) return widget.itemCompareProc (browser, itemOne, itemTwo, sortProperty);
+ return OS.noErr;
+}
+
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);
@@ -1465,7 +1601,7 @@
int keyboardProc (int nextHandler, int theEvent, int userData) {
Widget widget = WidgetTable.get (userData);
if (widget == null) {
- int theWindow = OS.ActiveNonFloatingWindow ();
+ int theWindow = OS.GetUserFocusWindow ();
if (theWindow == 0) return OS.eventNotHandledErr;
int [] theControl = new int [1];
OS.GetKeyboardFocus (theWindow, theControl);
@@ -1499,6 +1635,42 @@
}
eventQueue [index] = event;
}
+
+//3.0 API
+//public Rectangle map (Control from, Control to, Rectangle rectangle) {
+// checkDevice ();
+// if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);
+// return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+//}
+
+//3.0 API
+//public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
+// checkDevice ();
+// if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+// if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+// Rectangle rectangle = new Rectangle (x, y, width, height);
+// if (from != null) {
+// Rect rect = new Rect ();
+// OS.GetControlBounds (from.handle, rect);
+// rectangle.x += rect.left;
+// rectangle.y += rect.top;
+// int window = OS.GetControlOwner (from.handle);
+// OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
+// rectangle.x += rect.left;
+// rectangle.y += rect.top;
+// }
+// if (to != null) {
+// Rect rect = new Rect ();
+// OS.GetControlBounds (to.handle, rect);
+// rectangle.x -= rect.left;
+// rectangle.y -= rect.top;
+// int window = OS.GetControlOwner (to.handle);
+// OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
+// rectangle.x -= rect.left;
+// rectangle.y -= rect.top;
+// }
+// return rectangle;
+//}
int menuProc (int nextHandler, int theEvent, int userData) {
if (userData != 0) {
@@ -1609,7 +1781,7 @@
*/
public boolean readAndDispatch () {
checkDevice ();
- runDisposeWidgets ();
+ runTimers ();
runEnterExit ();
int [] outEvent = new int [1];
int status = OS.ReceiveNextEvent (0, null, OS.kEventDurationNoWait, true, outEvent);
@@ -1683,7 +1855,7 @@
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
if (!shell.isDisposed ()) {
- if (this == shell.getDisplay ()) shell.dispose ();
+ if (this == shell.display) shell.dispose ();
}
}
while (readAndDispatch ()) {};
@@ -1706,6 +1878,7 @@
commandCallback.dispose ();
controlCallback.dispose ();
drawItemCallback.dispose ();
+ itemCompareCallback.dispose ();
itemDataCallback.dispose ();
itemNotificationCallback.dispose ();
helpCallback.dispose ();
@@ -1719,10 +1892,10 @@
colorCallback.dispose ();
actionCallback = appleEventCallback = caretCallback = commandCallback = null;
controlCallback = drawItemCallback = itemDataCallback = itemNotificationCallback = null;
- helpCallback = hitTestCallback = keyboardCallback = menuCallback = null;
+ helpCallback = hitTestCallback = keyboardCallback = menuCallback = itemCompareCallback = null;
mouseHoverCallback = mouseCallback = trackingCallback = windowCallback = colorCallback = null;
actionProc = appleEventProc = caretProc = commandProc = 0;
- controlProc = drawItemProc = itemDataProc = itemNotificationProc = 0;
+ controlProc = drawItemProc = itemDataProc = itemNotificationProc = itemCompareProc = 0;
helpProc = hitTestProc = keyboardProc = menuProc = 0;
mouseHoverProc = mouseProc = trackingProc = windowProc = colorProc = 0;
timerCallback.dispose ();
@@ -1777,11 +1950,6 @@
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++) {
@@ -1883,7 +2051,7 @@
int modifiers = OS.GetCurrentEventKeyModifiers ();
boolean [] cursorWasSet = new boolean [1];
OS.HandleControlSetCursor (theControl [0], where, (short) modifiers, cursorWasSet);
- if (!cursorWasSet [0]) OS.SetThemeCursor (OS.kThemeArrowCursor);
+ if (!OS.StillDown () && !cursorWasSet [0]) OS.SetThemeCursor (OS.kThemeArrowCursor);
}
return eventSent;
}
@@ -2012,7 +2180,11 @@
}
// case OS.kMouseTrackingMouseExited: type = SWT.MouseExit; break;
// case OS.kMouseTrackingMouseEntered: type = SWT.MouseEnter; break;
- case OS.kMouseTrackingMouseDragged: type = SWT.MouseMove; break;
+ case OS.kMouseTrackingMouseDragged: {
+ type = SWT.MouseMove;
+ dragDetect (grabControl);
+ break;
+ }
case OS.kMouseTrackingMouseKeyModifiersChanged: break;
case OS.kMouseTrackingUserCancelled: break;
case OS.kMouseTrackingTimedOut: break;
@@ -2023,7 +2195,9 @@
int x = outPt.h - rect.left;
int y = outPt.v - rect.top;
int chord = OS.GetCurrentEventButtonState ();
- grabControl.sendMouseEvent (type, (short)button, chord, (short)x, (short)y, outModifiers [0]);
+ if (grabControl != null && !grabControl.isDisposed ()) {
+ grabControl.sendMouseEvent (type, (short)button, chord, (short)x, (short)y, outModifiers [0]);
+ }
//TEMPORARY CODE
if (grabControl != null && !grabControl.isDisposed ()) grabControl.update (true);
}
@@ -2054,6 +2228,23 @@
return result;
}
+boolean runTimers () {
+ if (timerList == null) return false;
+ boolean result = false;
+ for (int i=0; i<timerList.length; i++) {
+ if (timerIds [i] == -1) {
+ Runnable runnable = timerList [i];
+ timerList [i] = null;
+ timerIds [i] = 0;
+ if (runnable != null) {
+ result = true;
+ runnable.run ();
+ }
+ }
+ }
+ return result;
+}
+
void sendEvent (int eventType, Event event) {
if (eventTable == null && filterTable == null) {
return;
@@ -2091,6 +2282,25 @@
}
}
+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);
+ }
+}
+
/**
* Sets the location of the on-screen pointer relative to the top left corner
* of the screen. <b>Note: It is typically considered bad practice for a
@@ -2108,7 +2318,9 @@
*/
public void setCursorLocation (int x, int y) {
checkDevice ();
- /* Not possible on the MAC */
+ CGPoint pt = new CGPoint ();
+ pt.x = x; pt.y = y;
+ OS.CGWarpMouseCursorPosition (pt);
}
/**
@@ -2298,7 +2510,10 @@
*/
public boolean sleep () {
checkDevice ();
- return OS.ReceiveNextEvent (0, null, OS.kEventDurationForever, false, null) == OS.noErr;
+ allowTimers = false;
+ boolean result = OS.ReceiveNextEvent (0, null, OS.kEventDurationForever, false, null) == OS.noErr;
+ allowTimers = true;
+ return result;
}
/**
@@ -2387,15 +2602,15 @@
int timerProc (int id, int index) {
if (timerList == null) return 0;
if (0 <= index && index < timerList.length) {
-// if (allowTimers) {
+ if (allowTimers) {
Runnable runnable = timerList [index];
timerList [index] = null;
timerIds [index] = 0;
if (runnable != null) runnable.run ();
-// } else {
-// timerIds [index] = -1;
-// wakeUp ();
-// }
+ } else {
+ timerIds [index] = -1;
+ wakeUp ();
+ }
}
return 0;
}
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 30f05bf..cda8d63 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
@@ -231,7 +231,7 @@
rgb = null;
open = true;
OS.FPShowHideFontPanel ();
- Display display = parent.getDisplay ();
+ Display display = parent.display;
while (!parent.isDisposed() && open) {
if (!display.readAndDispatch ()) display.sleep ();
};
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 3dca46f..86c1010e 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
@@ -37,7 +37,7 @@
* </p>
*/
public class Group extends Composite {
- String text;
+ String text = "";
/**
* Constructs a new instance of this class given its parent
@@ -76,6 +76,7 @@
}
static int checkStyle (int style) {
+ style |= SWT.NO_FOCUS;
/*
* Even though it is legal to create this widget
* with scroll bars, they serve no useful purpose
@@ -102,7 +103,7 @@
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));
+ height += Math.max (text.length () == 0 ? 8 : 22, (bounds.bottom - bounds.top) - (client.bottom - client.top));
return new Rectangle (x, y, width, height);
}
@@ -132,9 +133,9 @@
OS.GetRegionBounds (rgnHandle, client);
OS.DisposeRgn (rgnHandle);
int x = Math.max (0, client.left - bounds.left);
- int y = text == null ? x : Math.max (0, client.top - bounds.top);
+ int y = text.length () == 0 ? x : Math.max (0, client.top - bounds.top);
int width = Math.max (0, client.right - client.left);
- int height = Math.max (0, text == null ? bounds.bottom - bounds.top - 2*y : client.bottom - client.top);
+ int height = Math.max (0, text.length () == 0 ? bounds.bottom - bounds.top - 2*y : client.bottom - client.top);
return new Rectangle (x, y, width, height);
}
@@ -169,10 +170,10 @@
*'&' can be escaped by doubling it in the string, causing
* a single '&' to be displayed.
* </p>
- * @param text the new text
+ * @param string the new text
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <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>
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 c6a0e1e..8eec303 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
@@ -11,7 +11,7 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.carbon.ATSTrapezoid;
+import org.eclipse.swt.internal.carbon.ControlFontStyleRec;
import org.eclipse.swt.internal.carbon.FontInfo;
import org.eclipse.swt.internal.carbon.OS;
@@ -107,58 +107,40 @@
}
} else {
if (isImage && image != null) {
- Rectangle r = image.getBounds();
+ Rectangle r = image.getBounds ();
width = r.width;
height = r.height;
} else {
width = DEFAULT_WIDTH;
- Font font = getFont ();
- FontInfo info = new FontInfo ();
- OS.FetchFontInfo(font.id, font.size, font.style, info);
- int fontHeight = info.ascent + info.descent;
- height = fontHeight;
int length = text.length ();
if (length != 0) {
- String string = Display.convertToLf (text);
- int [] layout = new int [1];
- OS.ATSUCreateTextLayout (layout);
- if (layout [0] == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- int [] atsuiStyle = new int [1];
- OS.ATSUCreateStyle (atsuiStyle);
- if (atsuiStyle [0] == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- int ptr1 = OS.NewPtr (16);
- OS.memcpy (ptr1, new int [] {font.handle}, 4);
- OS.memcpy (ptr1 + 4, new int [] {OS.X2Fix (font.size)}, 4);
- int [] tags = new int [] {OS.kATSUFontTag, OS.kATSUSizeTag};
- int [] sizes = new int [] {4, 4};
- int [] values = new int [] {ptr1, ptr1 + 4};
- OS.ATSUSetAttributes (atsuiStyle [0], tags.length, tags, sizes, values);
- OS.DisposePtr (ptr1);
- int ptr2 = OS.NewPtr (length * 2);
- OS.memcpy (ptr2, string, length * 2);
- OS.ATSUSetTextPointerLocation (layout [0], ptr2, 0, length, length);
- OS.ATSUSetRunStyle (layout [0], atsuiStyle [0], 0, length);
- height = 0;
- width = wHint != SWT.DEFAULT ? wHint : 0;
- int [] breakCount = new int [1];
- ATSTrapezoid trapezoid = new ATSTrapezoid();
- int start = 0, index = 0;
- do {
- index = string.indexOf ('\n', start);
- int end = index == -1 ? length : index;
- if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
- OS.ATSUBatchBreakLines (layout [0], start, end - start, OS.X2Fix (wHint), breakCount);
- height += (breakCount [0] + (index == -1 ? 1 : 0)) * fontHeight;
+ int [] ptr = new int [1];
+ OS.GetControlData (handle, (short) 0 , OS.kControlStaticTextCFStringTag, 4, ptr, null);
+ if (ptr [0] != 0) {
+ org.eclipse.swt.internal.carbon.Point ioBounds = new org.eclipse.swt.internal.carbon.Point ();
+ if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) ioBounds.h = (short) wHint;
+ if (font == null) {
+ OS.GetThemeTextDimensions (ptr [0], (short)OS.kThemePushButtonFont, OS.kThemeStateActive, ioBounds.h != 0, ioBounds, null);
} else {
- OS.ATSUGetGlyphBounds (layout [0], 0, 0, start, end - start, (short) OS.kATSUseDeviceOrigins, 1, trapezoid, null);
- width = Math.max (width, OS.Fix2Long (trapezoid.upperRight_x) - OS.Fix2Long (trapezoid.upperLeft_x));
- height += OS.Fix2Long (trapezoid.lowerRight_y) - OS.Fix2Long (trapezoid.upperRight_y);
+ int [] currentPort = new int [1];
+ OS.GetPort (currentPort);
+ OS.SetPortWindowPort (OS.GetControlOwner (handle));
+ OS.TextFont (font.id);
+ OS.TextFace (font.style);
+ OS.TextSize (font.size);
+ OS.GetThemeTextDimensions (ptr [0], (short) OS.kThemeCurrentPortFont, OS.kThemeStateActive, ioBounds.h != 0, ioBounds, null);
+ OS.SetPort (currentPort [0]);
}
- start = index + 1;
- } while (index != -1);
- OS.ATSUDisposeStyle (atsuiStyle [0]);
- OS.ATSUDisposeTextLayout (layout [0]);
- OS.DisposePtr (ptr2);
+ width = ioBounds.h;
+ height = ioBounds.v;
+ }
+ OS.CFRelease (ptr [0]);
+ } else {
+ Font font = getFont ();
+ FontInfo info = new FontInfo ();
+ OS.FetchFontInfo(font.id, font.size, font.style, info);
+ int fontHeight = info.ascent + info.descent;
+ height = fontHeight;
}
}
}
@@ -174,7 +156,13 @@
if ((style & SWT.SEPARATOR) != 0) {
OS.CreateSeparatorControl (window, null, outControl);
} else {
- OS.CreateStaticTextControl (window, null, 0, null, outControl);
+ int just = OS.teFlushLeft;
+ if ((style & SWT.CENTER) != 0) just = OS.teCenter;
+ if ((style & SWT.RIGHT) != 0) just = OS.teFlushRight;
+ ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
+ fontStyle.flags |= OS.kControlUseJustMask;
+ fontStyle.just = (short) just;
+ OS.CreateStaticTextControl (window, null, 0, fontStyle, outControl);
}
if (outControl [0] == 0) error (SWT.ERROR_NO_HANDLES);
handle = outControl [0];
@@ -192,7 +180,12 @@
data.paintEvent = theEvent;
data.visibleRgn = visibleRgn;
GC gc = GC.carbon_new (this, data);
- gc.drawImage (image, 0, 0);
+ int x = 0;
+ Point size = getSize ();
+ Rectangle bounds = image.getBounds ();
+ if ((style & SWT.CENTER) != 0) x = (size.x - bounds.width) / 2;
+ if ((style & SWT.RIGHT) != 0) x = size.x - bounds.width;
+ gc.drawImage (image, x, 0);
gc.dispose ();
}
super.drawWidget (control, damageRgn, visibleRgn, theEvent);
@@ -279,6 +272,18 @@
public void setAlignment (int alignment) {
checkWidget();
if ((style & SWT.SEPARATOR) != 0) return;
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+ style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ int just = OS.teFlushLeft;
+ if ((alignment & SWT.CENTER) != 0) just = OS.teCenter;
+ if ((alignment & SWT.RIGHT) != 0) just = OS.teFlushRight;
+ ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
+ OS.GetControlData (handle, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
+ fontStyle.flags |= OS.kControlUseJustMask;
+ fontStyle.just = (short) just;
+ OS.SetControlFontStyle (handle, fontStyle);
+ redraw ();
}
/**
@@ -298,6 +303,9 @@
public void setImage (Image image) {
checkWidget();
if ((style & SWT.SEPARATOR) != 0) return;
+ if (image != null && image.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
this.image = image;
isImage = true;
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 45033c3..f1f277d 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
@@ -288,12 +288,10 @@
}
Color defaultBackground () {
- Display display = getDisplay ();
return display.getSystemColor (SWT.COLOR_LIST_BACKGROUND);
}
Color defaultForeground () {
- Display display = getDisplay ();
return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
}
@@ -360,7 +358,7 @@
* @param indices the array of indices for the items to deselect
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -664,7 +662,6 @@
void hookEvents () {
super.hookEvents ();
- Display display= getDisplay();
DataBrowserCallbacks callbacks = new DataBrowserCallbacks ();
callbacks.version = OS.kDataBrowserLatestCallbacks;
OS.InitDataBrowserCallbacks (callbacks);
@@ -690,22 +687,6 @@
return OS.noErr;
}
-int kEventControlBoundsChanged (int nextHandler, int theEvent, int userData) {
- int result = super.kEventControlBoundsChanged (nextHandler, theEvent, userData);
- /*
- * This code is intentionally commented. Setting the column
- * width to be the size of the client are causes the initial
- * value of the veritcal scroll bar to be wrong and causes
- * '...' to appear in strings that are too long, even though
- * a horizontal scroll bar is present.
- */
-// 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.right));
- return result;
-}
-
int kEventMouseDown (int nextHandler, int theEvent, int userData) {
int result = super.kEventMouseDown (nextHandler, theEvent, userData);
if (result == OS.noErr) return result;
@@ -716,32 +697,35 @@
* 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.isDisposed ()) oldFocus.sendFocusEvent (false);
- if (!isDisposed () && isEnabled ()) sendFocusEvent (true);
+ if (oldFocus != null && !oldFocus.isDisposed ()) oldFocus.sendFocusEvent (false, false);
+ if (!isDisposed () && isEnabled ()) sendFocusEvent (true, false);
}
return result;
}
-int kEventRawKeyDown (int nextHandler, int theEvent, int userData) {
- int result = super.kEventRawKeyDown (nextHandler, theEvent, userData);
+int kEventRawKey (int nextHandler, int theEvent, int userData) {
+ int result = super.kEventRawKey (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 36: { /* Return */
+ postEvent (SWT.DefaultSelection);
+ break;
+ }
+ /*
+ * 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.
+ */
case 125: { /* Down */
int index = getSelectionIndex ();
setSelection (Math.min (itemCount - 1, index + 1), true);
@@ -753,35 +737,7 @@
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;
+ return result;
}
int itemNotificationProc (int browser, int id, int message) {
@@ -1118,7 +1074,7 @@
* @param indices the array of indices for the items to select
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1313,7 +1269,7 @@
* @param indices the indices of the items to select
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1347,7 +1303,7 @@
* @param items the array of items
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <li>ERROR_NULL_ARGUMENT - if the set of items is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
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 4d804a9..485d629 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
@@ -44,6 +44,7 @@
short id;
int x, y;
boolean hasLocation, modified, closed;
+ MenuItem [] items;
MenuItem cascade, defaultItem, lastTarget;
Decorations parent;
@@ -67,7 +68,7 @@
* @see Widget#getStyle
*/
public Menu (Control parent) {
- this (checkNull (parent).getShell (), SWT.POP_UP);
+ this (checkNull (parent).menuShell (), SWT.POP_UP);
}
/**
@@ -240,7 +241,6 @@
}
void createHandle () {
- Display display = getDisplay ();
display.addMenu (this);
int outMenuRef [] = new int [1];
OS.CreateNewMenu (id, 0, outMenuRef);
@@ -255,15 +255,19 @@
checkWidget ();
int count = OS.CountMenuItems (handle);
if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
- 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);
+ int result = OS.InsertMenuItemTextWithCFString (handle, 0, (short) index, attributes, 0);
if (result != OS.noErr) {
- display.removeMenuItem (item);
error (SWT.ERROR_ITEM_NOT_ADDED);
}
+ if (count == items.length) {
+ MenuItem [] newItems = new MenuItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ System.arraycopy (items, index, items, index + 1, count - index);
+ items [index] = item;
modified = true;
if ((style & SWT.BAR) != 0) {
// Display display = getDisplay ();
@@ -279,13 +283,20 @@
void createWidget () {
checkOrientation (parent);
super.createWidget ();
+ items = new MenuItem [4];
}
void destroyItem (MenuItem item) {
- short [] outIndex = new short [1];
- if (OS.GetIndMenuItemWithCommandID (handle, item.id, 1, null, outIndex) != OS.noErr) {
- error (SWT.ERROR_ITEM_NOT_REMOVED);
+ int count = OS.CountMenuItems (handle);
+ int index = 0;
+ while (index < count) {
+ if (items [index] == item) break;
+ index++;
}
+ if (index == count) return;
+ System.arraycopy (items, index + 1, items, index, --count - index);
+ items [count] = null;
+ if (count == 0) items = new MenuItem [4];
modified = true;
if ((style & SWT.BAR) != 0) {
// int [] outMenuRef = new int [1];
@@ -295,10 +306,10 @@
// OS.DisposeMenu (outMenuRef [0]);
// }
}
- OS.DeleteMenuItem (handle, outIndex [0]);
+ OS.DeleteMenuItem (handle, (short) (index + 1));
}
-void destroyWidget (Display display) {
+void destroyWidget () {
int theMenu = handle;
releaseHandle ();
if (theMenu != 0) {
@@ -324,12 +335,6 @@
return defaultItem;
}
-public Display getDisplay () {
- Decorations parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -367,12 +372,9 @@
*/
public MenuItem getItem (int index) {
checkWidget ();
- int [] outCommandID= new int [1];
- if (OS.GetMenuItemCommandID (handle, (short)(index+1), outCommandID) != OS.noErr) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- Display display = getDisplay ();
- return display.findMenuItem (outCommandID[0]);
+ int count = OS.CountMenuItems (handle);
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
}
/**
@@ -408,17 +410,10 @@
*/
public MenuItem [] getItems () {
checkWidget ();
- Display display = getDisplay ();
- int length = OS.CountMenuItems (handle);
- MenuItem [] items = new MenuItem [length];
- 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 [i] = display.findMenuItem (outCommandID [0]);
- }
- return items;
+ int count = OS.CountMenuItems (handle);
+ MenuItem [] result = new MenuItem [count];
+ System.arraycopy (items, 0, result, 0, count);
+ return result;
}
String getNameText () {
@@ -527,7 +522,6 @@
return this == parent.menuShell ().menuBar;
}
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++) {
@@ -540,7 +534,6 @@
void hookEvents () {
super.hookEvents ();
- Display display = getDisplay ();
int menuProc = display.menuProc;
int [] mask = new int [] {
OS.kEventClassMenu, OS.kEventMenuClosed,
@@ -572,10 +565,9 @@
int result = super.kEventMenuTargetItem (nextHandler, theEvent, userData);
if (result == OS.noErr) return result;
lastTarget = null;
- int [] commandID = new int [1];
- if (OS.GetEventParameter (theEvent, OS.kEventParamMenuCommand, OS.typeMenuCommand, null, 4, null, commandID) == OS.noErr) {
- Display display = getDisplay ();
- lastTarget = display.findMenuItem (commandID [0]);
+ short [] index = new short [1];
+ if (OS.GetEventParameter (theEvent, OS.kEventParamMenuItemIndex, OS.typeMenuItemIndex, null, 2, null, index) == OS.noErr) {
+ if (index [0] != 0) lastTarget = items [index [0] - 1];
if (lastTarget != null) lastTarget.sendEvent (SWT.Arm);
}
return OS.eventNotHandledErr;
@@ -601,11 +593,10 @@
public int indexOf (MenuItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- 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;
- }
+ int count = OS.CountMenuItems (handle);
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
return -1;
}
@@ -664,13 +655,13 @@
}
void releaseWidget () {
- MenuItem [] items = getItems ();
- for (int i=0; i<items.length; i++) {
+ int count = OS.CountMenuItems (handle);
+ for (int i=0; i<count; i++) {
MenuItem item = items [i];
if (!item.isDisposed ()) item.releaseResources ();
}
+ items = null;
super.releaseWidget ();
- Display display = getDisplay ();
display.removeMenu (this);
parent = null;
cascade = defaultItem = lastTarget = null;
@@ -837,7 +828,6 @@
public void setVisible (boolean visible) {
checkWidget ();
if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
- Display display = getDisplay ();
if (visible) {
display.addPopup (this);
} else {
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 052360c..fb855fc 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
@@ -34,7 +34,7 @@
*/
public class MenuItem extends Item {
Menu parent, menu;
- int id, accelerator;
+ int accelerator;
/**
* Constructs a new instance of this class given its parent
@@ -118,16 +118,17 @@
}
public void _setEnabled (boolean enabled) {
- short [] outIndex = new short [1];
- OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
int outMenuRef [] = new int [1];
- OS.GetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outMenuRef);
+ short menuIndex = (short) (index + 1);
+ OS.GetMenuItemHierarchicalMenu (parent.handle, menuIndex, outMenuRef);
if (enabled) {
if (outMenuRef [0] != 0) OS.EnableMenuItem (outMenuRef [0], (short) 0);
- OS.EnableMenuCommand (parent.handle, id);
+ OS.EnableMenuItem (parent.handle, menuIndex);
} else {
if (outMenuRef [0] != 0) OS.DisableMenuItem (outMenuRef [0], (short) 0);
- OS.DisableMenuCommand (parent.handle, id);
+ OS.DisableMenuItem (parent.handle, menuIndex);
}
}
@@ -241,12 +242,6 @@
return accelerator;
}
-public Display getDisplay () {
- Menu parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -323,10 +318,10 @@
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.noErr) {
- error (SWT.ERROR_CANNOT_GET_SELECTION);
- }
+ int index = parent.indexOf (this);
+ if (index == -1) return false;
+ short [] outMark = new short [1];
+ OS.GetItemMark (parent.handle, (short) (index + 1), outMark);
return outMark [0] != 0;
}
@@ -416,10 +411,9 @@
}
void releaseWidget () {
- Display display = getDisplay ();
if (menu != null) {
menu.releaseWidget ();
- menu.destroyWidget (display);
+ menu.destroyWidget ();
} else {
if ((parent.style & SWT.BAR) != 0) {
// short [] outIndex = new short [1];
@@ -437,7 +431,6 @@
super.releaseWidget ();
accelerator = 0;
if (this == parent.defaultItem) parent.defaultItem = null;
- display.removeMenuItem (this);
parent = null;
}
@@ -541,10 +534,8 @@
*/
public void setAccelerator (int accelerator) {
checkWidget ();
- short [] outIndex = new short [1];
- if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.noErr) {
- return;
- }
+ int index = parent.indexOf (this);
+ if (index == -1) return;
boolean update = (this.accelerator == 0 && accelerator != 0) || (this.accelerator != 0 && accelerator == 0);
this.accelerator = accelerator;
boolean inSetVirtualKey = false;
@@ -566,10 +557,11 @@
if ((accelerator & SWT.COMMAND) != 0) inModifiers &= ~OS.kMenuNoCommandModifier;
if ((accelerator & SWT.ALT) != 0) inModifiers |= OS.kMenuOptionModifier;
}
- OS.SetMenuItemModifiers (parent.handle, outIndex [0], (byte)inModifiers);
- OS.SetMenuItemCommandKey (parent.handle, outIndex [0], inSetVirtualKey, (char)inKey);
- OS.SetMenuItemKeyGlyph (parent.handle, outIndex [0], (short)inGlyph);
- if (update) updateText ();
+ short menuIndex = (short) (index + 1);
+ OS.SetMenuItemModifiers (parent.handle, menuIndex, (byte)inModifiers);
+ OS.SetMenuItemCommandKey (parent.handle, menuIndex, inSetVirtualKey, (char)inKey);
+ OS.SetMenuItemKeyGlyph (parent.handle, menuIndex, (short)inGlyph);
+ if (update) updateText (menuIndex);
}
/**
@@ -611,12 +603,12 @@
public void setImage (Image image) {
checkWidget ();
if ((style & SWT.SEPARATOR) != 0) return;
+ int index = parent.indexOf (this);
+ if (index == -1) return;
super.setImage (image);
- 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);
+ OS.SetMenuItemIconHandle (parent.handle, (short) (index + 1), type, imageHandle);
}
/**
@@ -663,10 +655,9 @@
this.menu = menu;
/* Update the menu in the OS */
- short [] outIndex = new short [1];
- if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.noErr) {
- error (SWT.ERROR_CANNOT_SET_MENU);
- }
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ short menuIndex = (short) (index + 1);
int outMenuRef [] = new int [1];
if (menu == null) {
if ((parent.style & SWT.BAR) != 0) {
@@ -689,13 +680,13 @@
}
outMenuRef [0] = menu.handle;
int [] outString = new int [1];
- if (OS.CopyMenuItemTextAsCFString (parent.handle, outIndex [0], outString) != OS.noErr) {
+ if (OS.CopyMenuItemTextAsCFString (parent.handle, menuIndex, outString) != OS.noErr) {
error (SWT.ERROR_CANNOT_SET_MENU);
}
OS.SetMenuTitleWithCFString (outMenuRef [0], outString [0]);
OS.CFRelease (outString [0]);
}
- if (OS.SetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outMenuRef [0]) != OS.noErr) {
+ if (OS.SetMenuItemHierarchicalMenu (parent.handle, menuIndex, outMenuRef [0]) != OS.noErr) {
error (SWT.ERROR_CANNOT_SET_MENU);
}
}
@@ -725,10 +716,10 @@
public void setSelection (boolean selected) {
checkWidget ();
if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ int index = parent.indexOf (this);
+ if (index == -1) return;
int inMark = selected ? ((style & SWT.RADIO) != 0) ? OS.diamondMark : OS.checkMark : 0;
- if (OS.SetMenuCommandMark (parent.handle, id, (char) inMark) != OS.noErr) {
- error (SWT.ERROR_CANNOT_SET_SELECTION);
- }
+ OS.SetItemMark (parent.handle, (short) (index + 1), (short) inMark);
}
/**
@@ -772,16 +763,14 @@
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.SEPARATOR) != 0) return;
+ int index = parent.indexOf (this);
+ if (index == -1) return;
super.setText (string);
- updateText ();
+ updateText ((short) (index + 1));
}
-void updateText () {
+void updateText (short menuIndex) {
if ((style & SWT.SEPARATOR) != 0) return;
- short [] outIndex = new short [1];
- if (OS.GetIndMenuItemWithCommandID (parent.handle, id, 1, null, outIndex) != OS.noErr) {
- error (SWT.ERROR_CANNOT_SET_TEXT);
- }
char [] buffer = new char [text.length ()];
text.getChars (0, buffer.length, buffer, 0);
int i=0, j=0;
@@ -795,9 +784,9 @@
}
int str = OS.CFStringCreateWithCharacters (OS.kCFAllocatorDefault, buffer, j);
if (str == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
- OS.SetMenuItemTextWithCFString (parent.handle, outIndex [0], str);
+ OS.SetMenuItemTextWithCFString (parent.handle, menuIndex, str);
int [] outHierMenu = new int [1];
- OS.GetMenuItemHierarchicalMenu (parent.handle, outIndex [0], outHierMenu);
+ OS.GetMenuItemHierarchicalMenu (parent.handle, menuIndex, outHierMenu);
if (outHierMenu [0] != 0) OS.SetMenuTitleWithCFString (outHierMenu [0], str);
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 8bace3b..48506ce 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
@@ -110,6 +110,13 @@
return style;
}
+int createCFString (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);
+}
+
/**
* Returns the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -121,13 +128,6 @@
return message;
}
-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);
-}
-
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -176,7 +176,7 @@
break;
case SWT.CANCEL:
param.defaultButton = (short)OS.kAlertStdAlertOKButton;
- param.defaultText = defaultStr = getCFString ("SWT_Cancel");
+ param.defaultText = defaultStr = createCFString ("SWT_Cancel");
break;
case SWT.OK | SWT.CANCEL:
param.defaultButton = (short)OS.kAlertStdAlertOKButton;
@@ -186,37 +186,37 @@
break;
case SWT.YES:
param.defaultButton = (short)OS.kAlertStdAlertOKButton;
- param.defaultText = defaultStr = getCFString ("SWT_Yes");
+ param.defaultText = defaultStr = createCFString ("SWT_Yes");
break;
case SWT.NO:
param.cancelButton = (short)OS.kAlertStdAlertOKButton;
- param.cancelText = defaultStr = getCFString ("SWT_No");
+ param.cancelText = defaultStr = createCFString ("SWT_No");
break;
case SWT.YES | SWT.NO:
param.defaultButton = (short)OS.kAlertStdAlertOKButton;
- param.defaultText = defaultStr = getCFString ("SWT_Yes");
+ param.defaultText = defaultStr = createCFString ("SWT_Yes");
param.cancelButton = (short)OS.kAlertStdAlertCancelButton;
- param.cancelText = cancelStr = getCFString ("SWT_No");
+ param.cancelText = cancelStr = createCFString ("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.defaultText = defaultStr = createCFString ("SWT_Yes");
+ param.otherText = cancelStr = createCFString ("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.defaultText = defaultStr = createCFString ("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.defaultText = defaultStr = createCFString ("SWT_Abort");
+ param.otherText = cancelStr = createCFString ("SWT_Retry");
param.cancelButton = (short)OS.kAlertStdAlertCancelButton;
- param.cancelText = otherStr = getCFString ("SWT_Ignore");
+ param.cancelText = otherStr = createCFString ("SWT_Ignore");
break;
}
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 8ae3589..323c0c5 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
@@ -98,6 +98,10 @@
handle = outControl [0];
}
+void drawBackground (int control) {
+ drawBackground (control, background);
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
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 28efede..d3288d8 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
@@ -70,7 +70,7 @@
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);
+ sizeCursor = new Cursor (display, cursorStyle);
}
/**
@@ -146,7 +146,7 @@
int kEventControlSetCursor (int nextHandler, int theEvent, int userData) {
int result = super.kEventControlSetCursor (nextHandler, theEvent, userData);
if (result == OS.noErr) return result;
- setCursor (sizeCursor.handle);
+ display.setCursor (sizeCursor.handle);
return OS.noErr;
}
@@ -255,4 +255,9 @@
eventTable.unhook(SWT.Selection, listener);
eventTable.unhook(SWT.DefaultSelection,listener);
}
+
+int traversalCode (int key, int theEvent) {
+ return 0;
+}
+
}
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 cf0cd00..4a2cfb5 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
@@ -130,7 +130,6 @@
}
void createHandle () {
- Display display = getDisplay ();
int actionProc = display.actionProc;
int [] outControl = new int [1];
int window = OS.GetControlOwner (parent.handle);
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 34527ac..b225878 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
@@ -83,6 +83,7 @@
*/
public class ScrollBar extends Widget {
int handle;
+ int visibleRgn;
Scrollable parent;
boolean dragging;
int increment = 1;
@@ -175,7 +176,8 @@
return 0;
}
-void destroyWidget (Display display) {
+void destroyWidget () {
+ Display display = this.display;
int theControl = handle;
releaseHandle ();
if (theControl != 0) {
@@ -192,7 +194,6 @@
}
void createHandle () {
- Display display = getDisplay ();
int actionProc = display.actionProc;
int [] outControl = new int [1];
int window = OS.GetControlOwner (parent.scrolledHandle);
@@ -211,12 +212,6 @@
WidgetTable.remove (handle);
}
-public Display getDisplay () {
- Scrollable parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
int getDrawCount (int control) {
return parent.getDrawCount (control);
}
@@ -396,9 +391,18 @@
return (state & HIDDEN) == 0;
}
+int getVisibleRegion (int control, boolean clipChildren) {
+ if (visibleRgn == 0) {
+ visibleRgn = OS.NewRgn ();
+ calculateVisibleRegion (control, visibleRgn, clipChildren);
+ }
+ int result = OS.NewRgn ();
+ OS.CopyRgn (visibleRgn, result);
+ return result;
+}
+
void hookEvents () {
super.hookEvents ();
- Display display = getDisplay ();
int controlProc = display.controlProc;
int [] mask = new int [] {
OS.kEventClassControl, OS.kEventControlDraw,
@@ -407,6 +411,12 @@
OS.InstallEventHandler (controlTarget, controlProc, mask.length / 2, mask, handle, null);
}
+
+void invalidateVisibleRegion (int control) {
+ resetVisibleRegion (control);
+ parent.resetVisibleRegion (control);
+}
+
/**
* Returns <code>true</code> if the receiver is enabled and all
* of the receiver's ancestors are enabled, and <code>false</code>
@@ -507,9 +517,18 @@
void releaseWidget () {
super.releaseWidget ();
+ if (visibleRgn != 0) OS.DisposeRgn (visibleRgn);
+ visibleRgn = 0;
parent = null;
}
+void resetVisibleRegion (int control) {
+ if (visibleRgn != 0) {
+ OS.DisposeRgn (visibleRgn);
+ visibleRgn = 0;
+ }
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -719,8 +738,8 @@
state |= HIDDEN;
}
setVisible (handle, visible);
- sendEvent (visible ? SWT.Show : SWT.Hide);
parent.layoutControl (true);
+ sendEvent (visible ? SWT.Show : SWT.Hide);
}
void setZOrder () {
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 a5a40af..575f88c 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
@@ -125,6 +125,7 @@
ScrollBar bar = new ScrollBar ();
bar.parent = this;
bar.style = style;
+ bar.display = display;
bar.handle = outControl [0];
bar.register ();
bar.hookEvents ();
@@ -202,7 +203,6 @@
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,
@@ -336,6 +336,12 @@
super.releaseWidget ();
}
+void resetVisibleRegion (int control) {
+ if (verticalBar != null) verticalBar.resetVisibleRegion (control);
+ if (horizontalBar != null) horizontalBar.resetVisibleRegion (control);
+ super.resetVisibleRegion (control);
+}
+
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) {
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 6087a8d..78c499a 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
Binary files differ
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 7825875..6c9353a 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
@@ -199,7 +199,6 @@
}
void createHandle () {
- Display display = getDisplay ();
int actionProc = display.actionProc;
int [] outControl = new int [1];
int window = OS.GetControlOwner (parent.handle);
@@ -208,6 +207,10 @@
handle = outControl [0];
}
+void drawBackground (int control) {
+ drawBackground (control, background);
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
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 19569b5..6b74462 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
@@ -398,7 +398,6 @@
}
Rect getInset () {
- Display display = getDisplay ();
return display.tabFolderInset;
}
@@ -534,6 +533,7 @@
}
void setSelection (int index, boolean notify) {
+ if (index >= OS.GetControl32BitMaximum (handle)) return;
int currentIndex = OS.GetControl32BitValue (handle) - 1;
if (currentIndex != -1) {
TabItem item = items [currentIndex];
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 bd928f3..efea460 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
@@ -130,11 +130,6 @@
return control;
}
-public Display getDisplay () {
- TabFolder parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
/**
* Returns the receiver's parent, which must be a <code>TabFolder</code>.
*
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 d83b0b8..6b343db 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
@@ -12,8 +12,10 @@
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.EventRecord;
+import org.eclipse.swt.internal.carbon.TXNBackground;
import org.eclipse.swt.internal.carbon.TXNLongRect;
import org.eclipse.swt.*;
@@ -182,7 +184,7 @@
* @param string the string to be appended
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -302,7 +304,6 @@
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);
@@ -318,16 +319,33 @@
OS.GetIndexedSubControl (theRoot [0], (short) i, scrollBar);
OS.HIViewRemoveFromSuperview (scrollBar [0]);
OS.HIViewAddSubview (handle, scrollBar [0]);
- }
+ }
+
+ /*
+ * Bug in the Macintosh. The caret height is too small until some text is set in the
+ * TXNObject. The fix is to temporary change the text.
+ */
+ char [] buffer = new char [] {' '};
+ OS.TXNSetData (txnObject, OS.kTXNUnicodeTextData, buffer, 2, OS.kTXNStartOffset, OS.kTXNEndOffset);
+ OS.TXNSetData (txnObject, OS.kTXNUnicodeTextData, buffer, 0, OS.kTXNStartOffset, OS.kTXNEndOffset);
/* 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});
+ int [] tags = new int [] {
+ OS.kTXNDisableDragAndDropTag,
+ OS.kTXNIOPrivilegesTag,
+ OS.kTXNMarginsTag,
+ };
+ int [] datas = new int [] {
+ 1,
+ (style & SWT.READ_ONLY) != 0 ? 1 : 0,
+ ptr,
+ };
+ OS.TXNSetTXNObjectControls (txnObject, false, tags.length, tags, datas);
+ OS.TXNSetFrameBounds (txnObject, 0, 0, 0, 0, txnFrameID);
OS.DisposePtr (ptr);
}
@@ -342,9 +360,6 @@
* 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>
@@ -368,7 +383,7 @@
}
void drawBackground (int control) {
- drawFocus (control, hasFocus (), hasBorder (), inset ());
+ drawFocus (control, hasFocus (), hasBorder (), getParentBackground (), inset ());
}
void drawWidget (int control, int damageRgn, int visibleRgn, int theEvent) {
@@ -384,9 +399,6 @@
*
* @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>
@@ -850,14 +862,14 @@
if (result == OS.noErr) return result;
short [] part = new short [1];
OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part);
- drawFocusClipped (handle, part [0] != 0, hasBorder (), inset ());
+ drawFocusClipped (handle, part [0] != 0, hasBorder (), getParentBackground (), inset ());
OS.TXNDraw (txnObject, 0);
OS.TXNFocus (txnObject, part [0] != 0);
return OS.noErr;
}
-int kEventRawKeyDown (int nextHandler, int theEvent, int userData) {
- int result = super.kEventRawKeyDown (nextHandler, theEvent, userData);
+int kEventRawKey (int nextHandler, int theEvent, int userData) {
+ int result = super.kEventRawKey (nextHandler, theEvent, userData);
if (result == OS.noErr) return result;
int [] modifiers = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
@@ -880,32 +892,20 @@
int [] keyCode = new int [1];
OS.GetEventParameter (theEvent, OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode);
switch (keyCode [0]) {
+ /*
+ * Feature in the Macintosh. Tab and Return characters are inserted into a
+ * single line TXN Object. While this may be correct platform behavior, it is
+ * unexpected. The fix is to avoid calling the default handler.
+ */
case 36: { /* Return */
- /*
- * 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.
- */
- OS.TXNFocus (txnObject, false);
- result = OS.CallNextEventHandler (nextHandler, theEvent);
- OS.TXNFocus (txnObject, true);
postEvent (SWT.DefaultSelection);
- break;
+ return OS.noErr;
}
case 48: { /* Tab */
- /*
- * Feature in the Macintosh. Tab characters are inserted into a single
- * line TXN Object. While this may be correct platform behavior, it is
- * unexpected. The fix is to avoid calling the default handler.
- */
return OS.noErr;
}
}
}
- if ((style & SWT.READ_ONLY) != 0) return OS.noErr;
return result;
}
@@ -1007,6 +1007,28 @@
eventTable.unhook (SWT.Verify, listener);
}
+void resetVisibleRegion (int control) {
+ super.resetVisibleRegion (control);
+
+ /*
+ * Bug in the Macintosh. For some reason, the TXN object draws when
+ * kTXNVisibilityTag is not set causing pixel corruption. The fix is
+ * to make the TXN frame small so that nothing is drawn.
+ */
+ Rect rect = new Rect ();
+ OS.GetControlBounds (handle, rect);
+ Rect inset = inset ();
+ rect.left += inset.left;
+ rect.top += inset.top;
+ rect.right -= inset.right;
+ if (OS.IsControlVisible (handle)) {
+ rect.bottom -= inset.bottom;
+ } else {
+ rect.bottom = rect.top;
+ }
+ OS.TXNSetFrameBounds (txnObject, rect.top, rect.left, rect.bottom, rect.right, txnFrameID);
+}
+
/**
* Selects all the text in the receiver.
*
@@ -1068,6 +1090,18 @@
return newText == oldText;
}
+void setBackground (float [] color) {
+ TXNBackground txnColor = new TXNBackground ();
+ txnColor.bgType = OS.kTXNBackgroundTypeRGB;
+ int red = (short) (color == null ? 0xff : color [0] * 255);
+ int green = (short) (color == null ? 0xff : color [1] * 255);
+ int blue = (short) (color == null ? 0xff : color [2] * 255);
+ txnColor.bg_red = (short) (red << 8 | red);
+ txnColor.bg_green = (short) (green << 8 | green);
+ txnColor.bg_blue = (short) (blue << 8 | blue);
+ OS.TXNSetBackground (txnObject, txnColor);
+}
+
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 | MOVED)) != 0) setTXNBounds ();
@@ -1137,6 +1171,50 @@
} else {
style |= SWT.READ_ONLY;
}
+ OS.TXNSetTXNObjectControls (txnObject, false, 1, new int [] {OS.kTXNIOPrivilegesTag}, new int [] {((style & SWT.READ_ONLY) != 0) ? 1 : 0});
+}
+
+void setForeground (float [] color) {
+ int ptr2 = OS.NewPtr (OS.kTXNQDFontColorAttributeSize);
+ RGBColor rgb;
+ if (color == null) {
+ rgb = new RGBColor ();
+ } else {
+ rgb = toRGBColor (foreground);
+ }
+ OS.memcpy (ptr2, rgb, RGBColor.sizeof);
+ int [] attribs = new int [] {
+ OS.kTXNQDFontColorAttribute,
+ OS.kTXNQDFontColorAttributeSize,
+ ptr2,
+ };
+ int ptr1 = OS.NewPtr (attribs.length * 4);
+ OS.memcpy (ptr1, attribs, attribs.length * 4);
+ OS.TXNSetTypeAttributes (txnObject, attribs.length / 3, ptr1, 0, 0);
+ OS.DisposePtr (ptr1);
+ OS.DisposePtr (ptr2);
+}
+
+void setFontStyle (Font font) {
+ int [] attribs = new int [] {
+ OS.kTXNQDFontSizeAttribute,
+ OS.kTXNQDFontSizeAttributeSize,
+ font == null ? OS.kTXNDefaultFontSize : OS.X2Fix (font.size),
+ OS.kTXNQDFontStyleAttribute,
+ OS.kTXNQDFontStyleAttributeSize,
+ font == null ? OS.kTXNDefaultFontStyle : font.style,
+ OS.kTXNQDFontFamilyIDAttribute,
+ OS.kTXNQDFontFamilyIDAttributeSize,
+ font == null ? OS.kTXNDefaultFontName : font.id,
+ };
+ int ptr = OS.NewPtr (attribs.length * 4);
+ OS.memcpy (ptr, attribs, attribs.length * 4);
+ boolean readOnly = (style & SWT.READ_ONLY) != 0;
+ int [] tag = new int [] {OS.kTXNIOPrivilegesTag};
+ if (readOnly) OS.TXNSetTXNObjectControls (txnObject, false, 1, tag, new int [] {0});
+ OS.TXNSetTypeAttributes (txnObject, attribs.length / 3, ptr, 0, 0);
+ if (readOnly) OS.TXNSetTXNObjectControls (txnObject, false, 1, tag, new int [] {1});
+ OS.DisposePtr (ptr);
}
/**
@@ -1320,8 +1398,12 @@
void setTXNText (int iStartOffset, int iEndOffset, String string) {
char [] buffer = new char [string.length ()];
- string.getChars (0, buffer.length, buffer, 0);
+ string.getChars (0, buffer.length, buffer, 0);
+ boolean readOnly = (style & SWT.READ_ONLY) != 0;
+ int [] tag = new int [] {OS.kTXNIOPrivilegesTag};
+ if (readOnly) OS.TXNSetTXNObjectControls (txnObject, false, 1, tag, new int [] {0});
OS.TXNSetData (txnObject, OS.kTXNUnicodeTextData, buffer, buffer.length * 2, iStartOffset, iEndOffset);
+ if (readOnly) OS.TXNSetTXNObjectControls (txnObject, false, 1, tag, new int [] {1});
}
/**
@@ -1383,11 +1465,6 @@
// OS.TXNSetSelection (txnObject, oStartOffset [0], oEndOffset [0]);
}
-public void setVisible (boolean visible) {
- super.setVisible (visible);
- OS.TXNSetTXNObjectControls (txnObject, false, 1, new int[] {OS.kTXNVisibilityTag}, new int[] {visible ? -1 : 0});
-}
-
/**
* Shows the selection.
* <p>
@@ -1396,9 +1473,6 @@
* 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>
@@ -1409,6 +1483,23 @@
OS.TXNShowSelection (txnObject, false);
}
+int traversalCode (int key, int theEvent) {
+ int bits = super.traversalCode (key, theEvent);
+ if ((style & SWT.READ_ONLY) != 0) return bits;
+ if ((style & SWT.MULTI) != 0) {
+ bits &= ~SWT.TRAVERSE_RETURN;
+ if (key == 48 /* Tab */ && theEvent != 0) {
+ int [] modifiers = new int [1];
+ OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+ boolean next = (modifiers [0] & OS.shiftKey) == 0;
+ if (next && (modifiers [0] & OS.controlKey) == 0) {
+ bits &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
+ }
+ }
+ }
+ return bits;
+}
+
String verifyText (String string, int start, int end) {
Event event = new Event ();
event.text = string;
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 d0fe266..9431c19 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
@@ -200,7 +200,7 @@
* @return the item at the given point
*
* @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * <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>
@@ -302,6 +302,14 @@
return -1;
}
+void invalidateChildrenVisibleRegion (int control) {
+ super.invalidateChildrenVisibleRegion (control);
+ for (int i=0; i<itemCount; i++) {
+ ToolItem item = items [i];
+ item.resetVisibleRegion (control);
+ }
+}
+
int [] layoutHorizontal (int width, int height, boolean resize) {
int xSpacing = 0, ySpacing = 2;
int marginWidth = 0, marginHeight = 0;
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 c38674c..1549945 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
@@ -39,6 +39,7 @@
public class ToolItem extends Item {
int handle, iconHandle, labelHandle, arrowHandle;
int cIcon, labelCIcon, arrowCIcon;
+ int visibleRgn;
ToolBar parent;
Image hotImage, disabledImage;
String toolTipText;
@@ -270,7 +271,8 @@
if (arrowHandle != 0) WidgetTable.remove (arrowHandle);
}
-void destroyWidget (Display display) {
+void destroyWidget () {
+ Display display = this.display;
int theControl = handle;
releaseHandle ();
if (theControl != 0) {
@@ -371,12 +373,6 @@
return (state & DISABLED) == 0;
}
-public Display getDisplay () {
- Composite parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
int getDrawCount (int control) {
return parent.getDrawCount (control);
}
@@ -472,8 +468,17 @@
return rect.right - rect.left;
}
+int getVisibleRegion (int control, boolean clipChildren) {
+ if (visibleRgn == 0) {
+ visibleRgn = OS.NewRgn ();
+ calculateVisibleRegion (control, visibleRgn, false);
+ }
+ int result = OS.NewRgn ();
+ OS.CopyRgn (visibleRgn, result);
+ return result;
+}
+
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};
@@ -520,7 +525,6 @@
void hookEvents () {
super.hookEvents ();
- Display display = getDisplay ();
int controlProc = display.controlProc;
int [] mask1 = new int [] {
OS.kEventClassControl, OS.kEventControlDraw,
@@ -551,6 +555,11 @@
OS.HMInstallControlContentCallback (handle, helpProc);
}
+void invalidateVisibleRegion (int control) {
+ resetVisibleRegion (control);
+ parent.resetVisibleRegion (control);
+}
+
/**
* Returns <code>true</code> if the receiver is enabled and all
* of the receiver's ancestors are enabled, and <code>false</code>
@@ -617,7 +626,6 @@
* NOTE: No mouse move events are sent while tracking. There is no
* fix for this at this time.
*/
- Display display = getDisplay ();
display.grabControl = null;
display.runDeferredEvents ();
tracking = false;
@@ -681,6 +689,8 @@
if (labelCIcon != 0) destroyCIcon (labelCIcon);
if (arrowCIcon != 0) destroyCIcon (arrowCIcon);
cIcon = labelCIcon = arrowCIcon = 0;
+ if (visibleRgn != 0) OS.DisposeRgn (visibleRgn);
+ visibleRgn = 0;
parent = null;
control = null;
toolTipText = null;
@@ -712,6 +722,13 @@
eventTable.unhook(SWT.DefaultSelection,listener);
}
+void resetVisibleRegion (int control) {
+ if (visibleRgn != 0) {
+ OS.DisposeRgn (visibleRgn);
+ visibleRgn = 0;
+ }
+}
+
void selectRadio () {
int index = 0;
ToolItem [] items = parent.getItems ();
@@ -1050,7 +1067,6 @@
void updateArrow () {
if (arrowCIcon != 0) destroyCIcon (arrowCIcon);
arrowCIcon = 0;
- Display display = getDisplay ();
Image image = new Image (display, 7, 4);
GC gc = new GC (image);
int startX = 0, startY = 0;
@@ -1062,7 +1078,7 @@
ImageData data = image.getImageData ();
data.transparentPixel = 0xFFFFFFFF;
image.dispose ();
- image = new Image (getDisplay (), data, data.getTransparencyMask());
+ image = new Image (display, data, data.getTransparencyMask());
arrowCIcon = createCIcon (image);
image.dispose ();
ControlButtonContentInfo inContent = new ControlButtonContentInfo ();
@@ -1090,7 +1106,6 @@
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);
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 007445d..ccd7fe2 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
@@ -14,6 +14,10 @@
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
+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;
/**
* Instances of this class implement rubber banding rectangles that are
@@ -35,11 +39,18 @@
* </p>
*/
public class Tracker extends Widget {
- Control parent;
- Display display;
- boolean tracking, stippled;
- Rectangle [] rectangles, proportions;
- int cursorOrientation = SWT.NONE;
+ Control parent;
+ boolean tracking, stippled;
+ Cursor clientCursor, resizeCursor;
+ Rectangle [] rectangles, proportions;
+ int cursorOrientation = SWT.NONE;
+ boolean inEvent = false;
+
+ /*
+ * The following values mirror step sizes on Windows
+ */
+ final static int STEPSIZE_SMALL = 1;
+ final static int STEPSIZE_LARGE = 9;
/**
* Constructs a new instance of this class given its parent
@@ -76,7 +87,6 @@
public Tracker (Composite parent, int style) {
super (parent, checkStyle (style));
this.parent = parent;
- display = parent.getDisplay ();
}
/**
@@ -149,12 +159,109 @@
addListener (SWT.Move,typedListener);
}
-Point adjustMoveCursor (int xDisplay, int xWindow) {
- return new Point (0, 0);
+Point adjustMoveCursor () {
+ Rectangle bounds = computeBounds ();
+ int newX = bounds.x + bounds.width / 2;
+ int newY = bounds.y;
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ Rect rect = new Rect ();
+ OS.GetControlBounds (parent.handle, rect);
+ newX += rect.left;
+ newY += rect.top;
+ int window = OS.GetControlOwner (parent.handle);
+ OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
+ newX += rect.left;
+ newY += rect.top;
+ }
+ CGPoint pt = new CGPoint ();
+ pt.x = newX; pt.y = newY;
+ OS.CGWarpMouseCursorPosition (pt);
+ return new Point ((int) pt.x, (int) pt.y);
}
-Point adjustResizeCursor (int xDisplay, int xWindow) {
- return new Point (0, 0);
+Point adjustResizeCursor () {
+ int newX, newY;
+ Rectangle bounds = computeBounds ();
+
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ newX = bounds.x;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ newX = bounds.x + bounds.width;
+ } else {
+ newX = bounds.x + bounds.width / 2;
+ }
+
+ if ((cursorOrientation & SWT.UP) != 0) {
+ newY = bounds.y;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ newY = bounds.y + bounds.height;
+ } else {
+ newY = bounds.y + bounds.height / 2;
+ }
+
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ Rect rect = new Rect ();
+ OS.GetControlBounds (parent.handle, rect);
+ newX += rect.left;
+ newY += rect.top;
+ int window = OS.GetControlOwner (parent.handle);
+ OS.GetWindowBounds (window, (short) OS.kWindowContentRgn, rect);
+ newX += rect.left;
+ newY += rect.top;
+ }
+ CGPoint pt = new CGPoint ();
+ pt.x = newX; pt.y = newY;
+ OS.CGWarpMouseCursorPosition (pt);
+
+ /*
+ * If the client has not provided a custom cursor then determine
+ * the appropriate resize cursor.
+ */
+ if (clientCursor == null) {
+ Cursor newCursor = null;
+ switch (cursorOrientation) {
+ case SWT.UP:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZENS);
+ break;
+ case SWT.DOWN:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZENS);
+ break;
+ case SWT.LEFT:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
+ break;
+ case SWT.RIGHT:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
+ break;
+ case SWT.LEFT | SWT.UP:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZENWSE);
+ break;
+ case SWT.RIGHT | SWT.DOWN:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZENWSE);
+ break;
+ case SWT.LEFT | SWT.DOWN:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZENESW);
+ break;
+ case SWT.RIGHT | SWT.UP:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZENESW);
+ break;
+ default:
+ newCursor = new Cursor(display, SWT.CURSOR_SIZEALL);
+ break;
+ }
+ display.setCursor (newCursor.handle);
+ if (resizeCursor != null) {
+ resizeCursor.dispose ();
+ }
+ resizeCursor = newCursor;
+ }
+
+ return new Point ((int) pt.x, (int) pt.y);
}
static int checkStyle (int style) {
@@ -199,16 +306,22 @@
Rectangle [] result = new Rectangle [rects.length];
Rectangle bounds = computeBounds ();
for (int i = 0; i < rects.length; i++) {
- result[i] = new Rectangle (
- (rects[i].x - bounds.x) * 100 / bounds.width,
- (rects[i].y - bounds.y) * 100 / bounds.height,
- rects[i].width * 100 / bounds.width,
- rects[i].height * 100 / bounds.height);
+ int x = 0, y = 0, width = 0, height = 0;
+ if (bounds.width != 0) {
+ x = (rects [i].x - bounds.x) * 100 / bounds.width;
+ width = rects [i].width * 100 / bounds.width;
+ }
+ if (bounds.height != 0) {
+ y = (rects [i].y - bounds.y) * 100 / bounds.height;
+ height = rects [i].height * 100 / bounds.height;
+ }
+ result [i] = new Rectangle (x, y, width, height);
}
return result;
}
-void drawRectangles () {
+
+void drawRectangles (int window, boolean erase) {
if (parent != null) {
if (parent.isDisposed ()) return;
Shell shell = parent.getShell ();
@@ -216,10 +329,32 @@
} else {
display.update ();
}
-}
-
-public Display getDisplay () {
- return display;
+ int[] context = new int [1];
+ int port = OS.GetWindowPort (window);
+ Rect portRect = new Rect ();
+ OS.GetPortBounds (port, portRect);
+ OS.QDBeginCGContext (port, context);
+ OS.CGContextScaleCTM (context [0], 1, -1);
+ OS.CGContextTranslateCTM (context [0], 0, portRect.top - portRect.bottom);
+ CGRect cgRect = new CGRect ();
+ for (int i=0; i<rectangles.length; i++) {
+ Rectangle rect = rectangles [i];
+ cgRect.x = rect.x;
+ cgRect.y = rect.y;
+ cgRect.width = rect.width;
+ cgRect.height = rect.height;
+ if (erase) {
+ cgRect.width++;
+ cgRect.height++;
+ OS.CGContextClearRect (context [0], cgRect);
+ } else {
+ cgRect.x += 0.5f;
+ cgRect.y += 0.5f;
+ OS.CGContextStrokeRect (context [0], cgRect);
+ }
+ }
+ OS.CGContextSynchronize (context [0]);
+ OS.QDEndCGContext (port, context);
}
/**
@@ -280,7 +415,163 @@
public boolean open () {
checkWidget ();
if (rectangles == null) return false;
- return false;
+ boolean cancelled = false;
+ tracking = true;
+ int window = display.createOverlayWindow ();
+ OS.ShowWindow (window);
+ drawRectangles (window, false);
+ Point cursorPos;
+ if (OS.StillDown ()) {
+ org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point ();
+ OS.GetGlobalMouse (pt);
+ cursorPos = new Point (pt.h, pt.v);
+ } else {
+ if ((style & SWT.RESIZE) != 0) {
+ cursorPos = adjustResizeCursor ();
+ } else {
+ cursorPos = adjustMoveCursor ();
+ }
+ }
+
+ int oldX = cursorPos.x, oldY = cursorPos.y;
+ /*
+ * Tracker behaves like a Dialog with its own OS event loop.
+ */
+ Event event = new Event ();
+ int [] outEvent = new int [1];
+ while (tracking && !cancelled) {
+ int status = OS.ReceiveNextEvent (0, null, OS.kEventDurationNoWait, true, outEvent);
+ if (status != OS.noErr) continue;
+ int eventClass = OS.GetEventClass (outEvent [0]);
+ int eventKind = OS.GetEventKind (outEvent [0]);
+ int newX = oldX, newY = oldY;
+ switch (eventClass) {
+ case OS.kEventClassMouse: {
+ switch (eventKind) {
+ case OS.kEventMouseUp:
+ case OS.kEventMouseMoved:
+ case OS.kEventMouseDragged:
+ int sizeof = org.eclipse.swt.internal.carbon.Point.sizeof;
+ org.eclipse.swt.internal.carbon.Point where = new org.eclipse.swt.internal.carbon.Point ();
+ OS.GetEventParameter (outEvent [0], OS.kEventParamMouseLocation, OS.typeQDPoint, null, sizeof, null, where);
+ newX = where.h;
+ newY = where.v;
+ if (newX != oldX || newY != oldY) {
+ drawRectangles (window, true);
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (newX - oldX, newY - oldY);
+ cursorPos = adjustResizeCursor ();
+ newX = cursorPos.x; newY = cursorPos.y;
+ inEvent = true;
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (newX - oldX, newY - oldY);
+ inEvent = true;
+ sendEvent (SWT.Move, event);
+ }
+ inEvent = false;
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the move
+ * event. If this happens, return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (window, false);
+ oldX = newX; oldY = newY;
+ }
+ tracking = eventKind != OS.kEventMouseUp;
+ break;
+ }
+ break;
+ }
+ case OS.kEventClassKeyboard: {
+ switch (eventKind) {
+ case OS.kEventRawKeyDown:
+ case OS.kEventRawKeyModifiersChanged:
+ case OS.kEventRawKeyRepeat: {
+ int [] keyCode = new int [1];
+ OS.GetEventParameter (outEvent [0], OS.kEventParamKeyCode, OS.typeUInt32, null, keyCode.length * 4, null, keyCode);
+ int [] modifiers = new int [1];
+ OS.GetEventParameter (outEvent [0], OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
+ int stepSize = (modifiers [0] & OS.controlKey) != 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
+ int xChange = 0, yChange = 0;
+ switch (keyCode [0]) {
+ case 53: /* Esc */
+ cancelled = true;
+ tracking = false;
+ break;
+ case 36: /* Return */
+ tracking = false;
+ break;
+ case 123: /* Left arrow */
+ xChange = -stepSize;
+ break;
+ case 124: /* Right arrow */
+ xChange = stepSize;
+ break;
+ case 126: /* Up arrow */
+ yChange = -stepSize;
+ break;
+ case 125: /* Down arrow */
+ yChange = stepSize;
+ break;
+ }
+ if (xChange != 0 || yChange != 0) {
+ drawRectangles (window, true);
+ newX = oldX + xChange;
+ newY = oldY + yChange;
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (xChange, yChange);
+ cursorPos = adjustResizeCursor ();
+ inEvent = true;
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (xChange, yChange);
+ cursorPos = adjustMoveCursor ();
+ inEvent = true;
+ sendEvent (SWT.Move, event);
+ }
+ inEvent = false;
+ /*
+ * It is possible (but unlikely) that application
+ * code could have disposed the widget in the move
+ * event. If this happens return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (window, false);
+ oldX = cursorPos.x; oldY = cursorPos.y;
+ }
+ break;
+ }
+ }
+ }
+ }
+ /*
+ * Don't dispatch mouse and key events in general, EXCEPT once this
+ * tracker has finished its work.
+ */
+ boolean dispatch = true;
+ if (tracking && !cancelled) {
+ if (eventClass == OS.kEventClassMouse) dispatch = false;
+ if (eventClass == OS.kEventClassKeyboard) dispatch = false;
+ }
+ if (dispatch) OS.SendEventToEventTarget (outEvent [0], OS.GetEventDispatcherTarget ());
+ OS.ReleaseEvent (outEvent [0]);
+ if (clientCursor != null && resizeCursor == null) {
+ display.setCursor (clientCursor.handle);
+ }
+ }
+ drawRectangles (window, true);
+ OS.DisposeWindow (window);
+ tracking = false;
+ display.grabControl = null;
+ return !cancelled;
}
/**
@@ -362,8 +653,12 @@
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setCursor (Cursor value) {
+public void setCursor (Cursor newCursor) {
checkWidget ();
+ clientCursor = newCursor;
+ if (newCursor != null) {
+ if (inEvent) display.setCursor (newCursor.handle);
+ }
}
/**
@@ -372,6 +667,9 @@
*
* @param rectangles the bounds of the rectangles to be drawn
*
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the set of rectangles 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>
@@ -379,6 +677,7 @@
*/
public void setRectangles (Rectangle [] rectangles) {
checkWidget ();
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
this.rectangles = rectangles;
proportions = computeProportions (rectangles);
}
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 6f4dd51..f3e1e07 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
@@ -50,27 +50,27 @@
*/
public abstract class Widget {
int style, state;
+ Display display;
EventTable eventTable;
Object data;
- String [] keys;
- Object [] values;
/* Global state flags */
// static final int AUTOMATIC = 1 << 0;
// static final int ACTIVE = 1 << 1;
- static final int GRAB = 1 << 2;
+ static final int 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 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 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 KEYED_DATA = 1 << 15;
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -114,6 +114,7 @@
checkSubclass ();
checkParent (parent);
this.style = style;
+ display = parent.display;
}
int actionProc (int theControl, int partCode) {
@@ -185,6 +186,44 @@
return style;
}
+void calculateVisibleRegion (int control, int visibleRgn, boolean clipChildren) {
+ int tempRgn = OS.NewRgn ();
+ if (OS.IsControlVisible (control)) {
+ int childRgn = OS.NewRgn ();
+ int window = OS.GetControlOwner (control);
+ short [] count = new short [1];
+ int [] outControl = new int [1];
+ OS.GetRootControl (window, outControl);
+ int root = outControl [0];
+ OS.GetControlRegion (root, (short) OS.kControlStructureMetaPart, visibleRgn);
+ int tempControl = control, lastControl = 0;
+ while (tempControl != root) {
+ OS.GetControlRegion (tempControl, (short) OS.kControlStructureMetaPart, tempRgn);
+ OS.SectRgn (tempRgn, visibleRgn, visibleRgn);
+ if (OS.EmptyRgn (visibleRgn)) break;
+ if (clipChildren || tempControl != control) {
+ 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);
+ } else {
+ OS.CopyRgn (tempRgn, visibleRgn);
+ }
+ OS.DisposeRgn (tempRgn);
+}
+
void checkOrientation (Widget parent) {
style &= ~SWT.MIRRORED;
if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
@@ -198,8 +237,7 @@
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);
+ parent.checkWidget ();
}
/**
@@ -258,8 +296,10 @@
* </ul>
*/
protected void checkWidget () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Display display = this.display;
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED);
}
int colorProc (int inControl, int inMessage, int inDrawDepth, int inDrawInColor) {
@@ -382,7 +422,7 @@
void deregister () {
}
-void destroyWidget (Display display) {
+void destroyWidget () {
releaseHandle ();
}
@@ -441,10 +481,9 @@
*/
if (isDisposed()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- Display display = getDisplay ();
releaseChild ();
releaseWidget ();
- destroyWidget (display);
+ destroyWidget ();
}
void drawBackground (int control) {
@@ -463,8 +502,8 @@
}
}
-void drawFocus (int control, boolean hasFocus, boolean hasBorder, Rect inset) {
- drawBackground (control, null);
+void drawFocus (int control, boolean hasFocus, boolean hasBorder, float[] background, Rect inset) {
+ drawBackground (control, background);
Rect rect = new Rect ();
OS.GetControlBounds (control, rect);
rect.left += inset.left;
@@ -481,7 +520,7 @@
}
}
-void drawFocusClipped (int control, boolean hasFocus, boolean hasBorder, Rect inset) {
+void drawFocusClipped (int control, boolean hasFocus, boolean hasBorder, float[] background, Rect inset) {
int visibleRgn = getVisibleRegion (control, true);
if (!OS.EmptyRgn (visibleRgn)) {
int [] currentPort = new int [1];
@@ -492,7 +531,7 @@
int oldClip = OS.NewRgn ();
OS.GetClip (oldClip);
OS.SetClip (visibleRgn);
- drawFocus (control, hasFocus, hasBorder, inset);
+ drawFocus (control, hasFocus, hasBorder, background, inset);
OS.SetClip (oldClip);
OS.SetPort (currentPort [0]);
}
@@ -507,7 +546,6 @@
}
boolean filters (int eventType) {
- Display display = getDisplay ();
return display.filters (eventType);
}
@@ -567,7 +605,7 @@
*/
public Object getData () {
checkWidget();
- return data;
+ return (state & KEYED_DATA) != 0 ? ((Object []) data) [0] : data;
}
/**
@@ -597,9 +635,11 @@
public Object getData (String key) {
checkWidget();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (keys == null) return null;
- for (int i=0; i<keys.length; i++) {
- if (keys [i].equals (key)) return values [i];
+ if ((state & KEYED_DATA) != 0) {
+ Object [] table = (Object []) data;
+ for (int i=1; i<table.length; i+=2) {
+ if (key.equals (table [i])) return table [i+1];
+ }
}
return null;
}
@@ -620,7 +660,19 @@
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public abstract Display getDisplay ();
+public Display getDisplay () {
+ Display display = this.display;
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return display;
+}
+
+int getDrawCount (int control) {
+ return 0;
+}
+
+Rect getInset () {
+ return EMPTY_RECT;
+}
String getName () {
String string = getClass ().getName ();
@@ -660,35 +712,7 @@
int getVisibleRegion (int control, boolean clipChildren) {
int visibleRgn = OS.NewRgn ();
- int 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;
- if (clipChildren || tempControl != control) {
- 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);
+ calculateVisibleRegion (control, visibleRgn, clipChildren);
return visibleRgn;
}
@@ -709,12 +733,7 @@
return eventTable.hooks (eventType);
}
-int getDrawCount (int control) {
- return 0;
-}
-
-Rect getInset () {
- return EMPTY_RECT;
+void invalidateVisibleRegion (int control) {
}
/**
@@ -770,6 +789,10 @@
return getDisplay ().isValidThread ();
}
+int itemCompareProc (int browser, int itemOne, int itemTwo, int sortProperty) {
+ return OS.noErr;
+}
+
int itemDataProc (int browser, int item, int property, int itemData, int setValue) {
return OS.noErr;
}
@@ -1031,6 +1054,7 @@
void releaseHandle () {
state |= DISPOSED;
+ display = null;
}
void releaseResources () {
@@ -1043,8 +1067,6 @@
deregister ();
eventTable = null;
data = null;
- keys = null;
- values = null;
}
/**
@@ -1143,7 +1165,6 @@
}
void sendEvent (int eventType, Event event, boolean send) {
- Display display = getDisplay ();
if (eventTable == null && !display.filters (eventType)) {
return;
}
@@ -1206,6 +1227,7 @@
boolean visible = OS.IsControlVisible (control);
if (visible) OS.InvalWindowRect (window, oldBounds);
OS.SetControlBounds (control, newBounds);
+ invalidateVisibleRegion (control);
if (visible) OS.InvalWindowRect (window, newBounds);
int result = 0;
if (move && !sameOrigin) {
@@ -1241,7 +1263,11 @@
*/
public void setData (Object data) {
checkWidget();
- this.data = data;
+ if ((state & KEYED_DATA) != 0) {
+ ((Object []) this.data) [0] = data;
+ } else {
+ this.data = data;
+ }
}
/**
@@ -1271,49 +1297,46 @@
public void setData (String key, Object value) {
checkWidget();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
-
- /* Remove the key/value pair */
- if (value == null) {
- if (keys == null) return;
- int index = 0;
- while (index < keys.length && !keys [index].equals (key)) index++;
- if (index == keys.length) return;
- if (keys.length == 1) {
- keys = null;
- values = null;
+ int index = 1;
+ Object [] table = null;
+ if ((state & KEYED_DATA) != 0) {
+ table = (Object []) data;
+ while (index < table.length) {
+ if (key.equals (table [index])) break;
+ index += 2;
+ }
+ }
+ if (value != null) {
+ if ((state & KEYED_DATA) != 0) {
+ if (index == table.length) {
+ Object [] newTable = new Object [table.length + 2];
+ System.arraycopy (table, 0, newTable, 0, table.length);
+ data = table = newTable;
+ }
} else {
- String [] newKeys = new String [keys.length - 1];
- Object [] newValues = new Object [values.length - 1];
- System.arraycopy (keys, 0, newKeys, 0, index);
- System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
- System.arraycopy (values, 0, newValues, 0, index);
- System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
- keys = newKeys;
- values = newValues;
+ table = new Object [3];
+ table [0] = data;
+ data = table;
+ state |= KEYED_DATA;
}
- return;
- }
-
- /* Add the key/value pair */
- if (keys == null) {
- keys = new String [] {key};
- values = new Object [] {value};
- return;
- }
- for (int i=0; i<keys.length; i++) {
- if (keys [i].equals (key)) {
- values [i] = value;
- return;
+ table [index] = key;
+ table [index + 1] = value;
+ } else {
+ if ((state & KEYED_DATA) != 0) {
+ if (index != table.length) {
+ int length = table.length - 2;
+ if (length == 1) {
+ data = table [0];
+ state &= ~KEYED_DATA;
+ } else {
+ Object [] newTable = new Object [length];
+ System.arraycopy (table, 0, newTable, 0, index);
+ System.arraycopy (table, index + 2, newTable, index, length - index);
+ data = newTable;
+ }
+ }
}
}
- String [] newKeys = new String [keys.length + 1];
- Object [] newValues = new Object [values.length + 1];
- System.arraycopy (keys, 0, newKeys, 0, keys.length);
- System.arraycopy (values, 0, newValues, 0, values.length);
- newKeys [keys.length] = key;
- newValues [values.length] = value;
- keys = newKeys;
- values = newValues;
}
void setInputState (Event event, int theEvent) {
@@ -1354,7 +1377,6 @@
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;
@@ -1380,7 +1402,6 @@
}
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;
@@ -1435,6 +1456,7 @@
boolean drawing = getDrawCount (control) == 0;
if (drawing && !visible) visibleRgn = getVisibleRegion (control, false);
OS.SetControlVisibility (control, visible, false);
+ invalidateVisibleRegion (control);
if (drawing && visible) visibleRgn = getVisibleRegion (control, false);
if (drawing) {
int window = OS.GetControlOwner (control);
@@ -1443,14 +1465,32 @@
}
}
+void setZOrder (int control, int otheControl, boolean above) {
+ int inOp = above ? OS.kHIViewZOrderBelow : OS.kHIViewZOrderAbove;
+ int oldRgn = 0;
+ boolean drawing = isDrawing (control);
+ if (drawing) oldRgn = getVisibleRegion (control, false);
+ OS.HIViewSetZOrder (control, inOp, otheControl);
+ invalidateVisibleRegion (control);
+ if (drawing) {
+ int newRgn = getVisibleRegion (control, false);
+ if (above) {
+ OS.DiffRgn (newRgn, oldRgn, newRgn);
+ } else {
+ OS.DiffRgn (oldRgn, newRgn, newRgn);
+ }
+ int window = OS.GetControlOwner (control);
+ OS.InvalWindowRgn (window, newRgn);
+ OS.DisposeRgn (oldRgn);
+ OS.DisposeRgn (newRgn);
+ }
+}
+
RGBColor toRGBColor (float [] color) {
- int red = (short) (color [0] * 255);
- int green = (short) (color [1] * 255);
- int blue = (short) (color [2] * 255);
RGBColor rgb = new RGBColor ();
- rgb.red = (short) (red << 8 | red);
- rgb.green = (short) (green << 8 | green);
- rgb.blue = (short) (blue << 8 | blue);
+ rgb.red = (short) (color [0] * 0xffff);
+ rgb.green = (short) (color [1] * 0xffff);
+ rgb.blue = (short) (color [2] * 0xffff);
return rgb;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/Table.java
deleted file mode 100644
index 9e67be1..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/Table.java
+++ /dev/null
@@ -1,1772 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.Rect;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement a selectable user interface
- * object that displays a list of images and strings and issue
- * notificiation when selected.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TableItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles SINGLE, and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Table extends Composite {
- TableItem [] items;
- TableColumn [] columns;
- GC paintGC;
- int itemCount, columnCount, idCount, anchorFirst, anchorLast, headerHeight;
- boolean ignoreSelect;
- int showIndex = -1;
- static final int CHECK_COLUMN_ID = 1024;
- static final int COLUMN_ID = 1025;
- static final int EXTRA_WIDTH = 25;
- static final int CHECK_COLUMN_WIDTH = 25;
-
-/**
- * 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#CHECK
- * @see SWT#FULL_SELECTION
- * @see SWT#HIDE_SELECTION
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Table (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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);
- int columnCount = Math.max (this.columnCount, 1);
- for (int j=0; j<columnCount; j++) {
- int columnWidth = 0;
- for (int i=0; i<itemCount; i++) {
- TableItem item = items [i];
- columnWidth = Math.max (columnWidth, item.calculateWidth (j, gc));
- }
- width += columnWidth + EXTRA_WIDTH;
- }
- gc.dispose ();
- if ((style & SWT.CHECK) != 0) width += CHECK_COLUMN_WIDTH;
- } 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 = 0;
- int [] outMetric = new int [1];
- OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric);
- border += outMetric [0];
- OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric);
- border += outMetric [0];
- Rect rect = new Rect ();
- OS.GetDataBrowserScrollBarInset (handle, rect);
- short [] headerHeight = new short [1];
- OS.GetDataBrowserListViewHeaderBtnHeight (handle, headerHeight);
- x -= rect.left + border;
- y -= rect.top + border + headerHeight [0];
- width += rect.left + rect.right + border + border;
- height += rect.top + rect.bottom + border + border + headerHeight [0];
- 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);
- }
- 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;
- //TODO - CHECK column size
- checkColumn.headerBtnDesc_minimumWidth = CHECK_COLUMN_WIDTH;
- checkColumn.headerBtnDesc_maximumWidth = CHECK_COLUMN_WIDTH;
- 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.kDataBrowserCustomType;
- column.propertyDesc_propertyFlags = OS.kDataBrowserListViewSelectionColumn | OS.kDataBrowserDefaultPropertyFlags;
- column.headerBtnDesc_maximumWidth = 0x7fff;
- column.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing;
- OS.AddDataBrowserListViewColumn (handle, column, position);
- OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short) 0);
-
- /*
- * Feature in the Macintosh. Scroll bars are not created until
- * the data browser needs to draw them. The fix is to force the scroll
- * bars to be created by temporarily giving the widget a size, drawing
- * it on a offscreen buffer to avoid flashes and then restoring it to
- * size zero.
- */
- int size = 50;
- Rect rect = new Rect ();
- rect.right = rect.bottom = (short) size;
- OS.SetControlBounds (handle, rect);
- int bpl = size * 4;
- int [] gWorld = new int [1];
- int data = OS.NewPtr (bpl * size);
- OS.NewGWorldFromPtr (gWorld, OS.k3ARGBPixelFormat, rect, 0, 0, 0, data, bpl);
- int [] curPort = new int [1];
- int [] curGWorld = new int [1];
- OS.GetGWorld (curPort, curGWorld);
- OS.SetGWorld (gWorld [0], curGWorld [0]);
- OS.DrawControlInCurrentPort (handle);
- OS.SetGWorld (curPort [0], curGWorld [0]);
- OS.DisposeGWorld (gWorld [0]);
- OS.DisposePtr (data);
- rect.right = rect.bottom = (short) 0;
- OS.SetControlBounds (handle, rect);
-}
-
-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.kDataBrowserCustomType;
- desc.propertyDesc_propertyFlags = OS.kDataBrowserDefaultPropertyFlags;
- desc.headerBtnDesc_maximumWidth = 0x7fff;
- desc.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing;
- OS.AddDataBrowserListViewColumn (handle, desc, position);
- 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;
- //TODO - 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];
-}
-
-Color defaultBackground () {
- Display display = getDisplay ();
- return display.getSystemColor (SWT.COLOR_LIST_BACKGROUND);
-}
-
-Color defaultForeground () {
- Display display = getDisplay ();
- return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
-}
-
-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 (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();
- //TODO - 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;
-}
-
-/**
- * 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);
- //TODO - 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;
-}
-
-/**
- * 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;
-}
-
-void destroyItem (TableColumn column) {
- int index = 0;
- while (index < columnCount) {
- if (columns [index] == column) break;
- index++;
- }
- //TODO - 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) {
- //TODO - 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);
-}
-
-int drawItemProc (int browser, int id, int property, int itemState, int theRect, int gdDepth, int colorDevice) {
- int index = id - 1;
- if (!(0 <= index && index < itemCount)) return OS.noErr;
- int columnIndex = 0;
- if (columnCount > 0) {
- for (columnIndex=0; columnIndex<columnCount; columnIndex++) {
- if (columns [columnIndex].id == property) break;
- }
- if (columnIndex == columnCount) return OS.noErr;
- }
- TableItem item = items [index];
- Rect rect = new Rect ();
- OS.memcpy (rect, theRect, Rect.sizeof);
- int x = rect.left;
- int y = rect.top;
- int height = rect.bottom - rect.top;
- boolean selected = (itemState & OS.kDataBrowserItemIsSelected) != 0;
- Rect controlRect = new Rect ();
- OS.GetControlBounds (handle, controlRect);
- x -= controlRect.left;
- y -= controlRect.top;
- GC gc = paintGC;
- if (gc == null) {
- GCData data = new GCData ();
- int [] port = new int [1];
- OS.GetPort (port);
- data.port = port [0];
- gc = GC.carbon_new (this, data);
- }
- int clip = OS.NewRgn ();
- OS.GetClip (clip);
- OS.OffsetRgn (clip, (short)-controlRect.left, (short)-controlRect.top);
- gc.setClipping (Region.carbon_new (clip));
- Rect itemRect = new Rect();
- OS.GetDataBrowserItemPartBounds (handle, id, property, OS.kDataBrowserPropertyEnclosingPart, itemRect);
- OS.OffsetRect (itemRect, (short) -controlRect.left, (short) -controlRect.top);
- Display display = getDisplay ();
- if (selected && (style & SWT.FULL_SELECTION) != 0) {
- gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
- gc.fillRectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top);
- } else {
- gc.setBackground (item.getBackground ());
- gc.fillRectangle (itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top);
- }
- int rectRgn = OS.NewRgn ();
- OS.RectRgn (rectRgn, rect);
- OS.OffsetRgn (rectRgn, (short)-controlRect.left, (short)-controlRect.top);
- OS.SectRgn (rectRgn, clip, clip);
- OS.DisposeRgn (rectRgn);
- gc.setClipping (Region.carbon_new (clip));
- OS.DisposeRgn (clip);
- Image image = item.getImage (columnIndex);
- if (image != null) {
- Rectangle bounds = image.getBounds ();
- gc.drawImage (image, 0, 0, bounds.width, bounds.height, x, y + (height - bounds.height) / 2, bounds.width, bounds.height);
- x += bounds.width + 2;
- }
- String text = item.getText (columnIndex);
- Point extent = gc.stringExtent (text);
- if (selected) {
- gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
- if (columnIndex == 0 && (style & SWT.FULL_SELECTION) == 0) {
- gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
- gc.fillRectangle (x - 1, y, extent.x + 2, height);
- }
- } else {
- Color foreground = item.getForeground ();
- gc.setForeground (foreground);
- }
- gc.drawString (text, x, y + (height - extent.y) / 2);
- if (gc != paintGC) gc.dispose ();
- return OS.noErr;
-}
-
-void drawWidget (int control, int damageRgn, int visibleRgn, int theEvent) {
- GC currentGC = paintGC;
- if (currentGC == null) {
- GCData data = new GCData ();
- data.paintEvent = theEvent;
- data.visibleRgn = visibleRgn;
- paintGC = GC.carbon_new (this, data);
- }
- super.drawWidget (control, damageRgn, visibleRgn, theEvent);
- if (currentGC == null) {
- paintGC.dispose ();
- paintGC = null;
- }
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- int border = 0;
- int [] outMetric = new int [1];
- OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric);
- border += outMetric [0];
- OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric);
- border += outMetric [0];
- Rect rect = new Rect (), inset = new Rect ();
- OS.GetControlBounds (handle, rect);
- OS.GetDataBrowserScrollBarInset (handle, inset);
- short [] headerHeight = new short [1];
- OS.GetDataBrowserListViewHeaderBtnHeight (handle, headerHeight);
- int width = Math.max (0, rect.right - rect.left - inset.right - border - border);
- int height = Math.max (0, rect.bottom - rect.top - inset.bottom - border - border - headerHeight [0]);
- return new Rectangle (inset.left, inset.top, width, height);
-}
-
-/**
- * Returns the column at the given, zero-relative index in the
- * receiver. Throws an exception if the index is out of range.
- * If no <code>TableColumn</code>s were created by the programmer,
- * this method will throw <code>ERROR_INVALID_RANGE</code> despite
- * the fact that a single column of data may be visible in the table.
- * This occurs when the programmer uses the table like a list, adding
- * items but never creating a column.
- *
- * @param index the index of the column to return
- * @return the column at the given index
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableColumn getColumn (int index) {
- checkWidget ();
- if (!(0 <=index && index < columnCount)) error (SWT.ERROR_INVALID_RANGE);
- return columns [index];
-}
-
-/**
- * Returns the number of columns contained in the receiver.
- * If no <code>TableColumn</code>s were created by the programmer,
- * this value is zero, despite the fact that visually, one column
- * of items is may be visible. This occurs when the programmer uses
- * the table like a list, adding items but never creating a column.
- *
- * @return the number of columns
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
- * </ul>
- */
-public int getColumnCount () {
- checkWidget ();
- return columnCount;
-}
-
-/**
- * Returns an array of <code>TableColumn</code>s which are the
- * columns in the receiver. If no <code>TableColumn</code>s were
- * created by the programmer, the array is empty, despite the fact
- * that visually, one column of items may be visible. This occurs
- * when the programmer uses the table like a list, adding items but
- * never creating a column.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableColumn [] getColumns () {
- checkWidget ();
- TableColumn [] result = new TableColumn [columnCount];
- System.arraycopy (columns, 0, result, 0, columnCount);
- return result;
-}
-
-/**
- * Returns the width in pixels of a grid line.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getGridLineWidth () {
- checkWidget ();
- return 0;
-}
-
-/**
- * Returns the height of the receiver's header
- *
- * @return the height of the header or zero if the header is not visible
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- */
-public int getHeaderHeight () {
- checkWidget ();
- short [] height = new short [1];
- OS.GetDataBrowserListViewHeaderBtnHeight (handle, height);
- return height [0];
-}
-
-/**
- * Returns <code>true</code> if the receiver's header is visible,
- * and <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the receiver's header's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getHeaderVisible () {
- checkWidget ();
- short [] height = new short [1];
- OS.GetDataBrowserListViewHeaderBtnHeight (handle, height);
- return height [0] != 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 TableItem getItem (int index) {
- checkWidget ();
- if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
- return items [index];
-}
-
-/**
- * Returns the item at the given point in the receiver
- * or null if no such item exists. The point is in the
- * coordinate system of the receiver.
- *
- * @param point the point used to locate the item
- * @return the item at the given point
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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));
- //TODO - 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;
-}
-
-/**
- * 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 the height of the area which would be used to
- * display <em>one</em> of the items in the receiver's.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemHeight () {
- 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>TableItem</code>s which are the items
- * in the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the items in the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getItems () {
- checkWidget ();
- TableItem [] result = new TableItem [itemCount];
- System.arraycopy (items, 0, result, 0, itemCount);
- return result;
-}
-
-/**
- * Returns <code>true</code> if the receiver's lines are visible,
- * and <code>false</code> otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, this method
- * may still indicate that it is considered visible even though
- * it may not actually be showing.
- * </p>
- *
- * @return the visibility state of the lines
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getLinesVisible () {
- checkWidget ();
- return false;
-}
-
-/**
- * Returns an array of <code>TableItem</code>s that are currently
- * selected in the receiver. An empty array indicates that no
- * items are selected.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its selection, so modifying the array will
- * not affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TableItem [] getSelection () {
- 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;
-}
-
-/**
- * Returns the number of selected items contained in the receiver.
- *
- * @return the number of selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionCount () {
- checkWidget ();
- int [] 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];
-}
-
-/**
- * Returns the zero-relative index of the item which is currently
- * selected in the receiver, or -1 if no item is selected.
- *
- * @return the index of the selected item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionIndex () {
- checkWidget();
- int [] 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>
- */
-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;
-}
-
-/**
- * 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], left = new int [1];
- OS.GetDataBrowserScrollPosition (handle, top, left);
- return top [0] / getItemHeight ();
-}
-
-int hitTestProc (int browser, int id, int property, int theRect, int mouseRect) {
- 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);
-}
-
-/**
- * Searches the receiver's list starting at the first column
- * (index 0) until a column is found that is equal to the
- * argument, and returns the index of that column. If no column
- * is found, returns -1.
- *
- * @param column the search column
- * @return the index of the column
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (TableColumn column) {
- checkWidget ();
- if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<columnCount; i++) {
- if (columns [i] == column) return i;
- }
- return -1;
-}
-
-/**
- * Searches the receiver's list starting at the first item
- * (index 0) until an item is found that is equal to the
- * argument, and returns the index of that item. If no item
- * is found, returns -1.
- *
- * @param item the search item
- * @return the index of the item
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int indexOf (TableItem item) {
- checkWidget ();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<itemCount; i++) {
- if (items [i] == item) 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();
- 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;
- item.checked = !item.checked;
- if (item.checked && item.grayed) {
- OS.SetDataBrowserItemDataButtonValue (itemData, (short) OS.kThemeButtonMixed);
- } else {
- int theData = item.checked ? OS.kThemeButtonOn : OS.kThemeButtonOff;
- OS.SetDataBrowserItemDataButtonValue (itemData, (short) theData);
- }
- 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);
- int theData = OS.kThemeButtonOff;
- if (item.checked) theData = item.grayed ? OS.kThemeButtonMixed : OS.kThemeButtonOn;
- OS.SetDataBrowserItemDataButtonValue (itemData, (short) 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.isDisposed ()) oldFocus.sendFocusEvent (false);
- if (!isDisposed () && 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), true);
- return OS.noErr;
- }
- case 126: { /* Up*/
- int index = getSelectionIndex ();
- setSelection (Math.max (0, index - 1), true);
- return OS.noErr;
- }
- }
- return result;
-}
-
-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 result;
-}
-
-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 ();
-}
-
-/**
- * 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 (!(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);
-}
-
-/**
- * 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 (!(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);
-}
-
-/**
- * Removes the items from the receiver's list at the given
- * zero-relative indices.
- *
- * @param indices the array of indices of the items
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
- * </ul>
- */
-public void remove (int [] indices) {
- if (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;
- }
-}
-
-/**
- * Removes all of the items from the receiver.
- * <p>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void removeAll () {
- checkWidget();
- OS.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 = idCount = 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);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Selects the item at the given zero-relative index in the receiver.
- * 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 (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 and no items will be selected if start is
- * greater than end.
- *
- * @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();
- //TODO - 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;
-}
-
-/**
- * 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 array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void select (int [] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- //TODO - 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;
-}
-
-/**
- * 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 ();
- if ((style & SWT.SINGLE) != 0) return;
- ignoreSelect = true;
- OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsAssign);
- ignoreSelect = false;
-}
-
-int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- /*
- * Ensure that the top item is visible when the tree is resized
- * from a zero size to a size that can show the selection.
- */
- int result = super.setBounds (control, x, y, width, height, move, resize, events);
- if (showIndex != -1) {
- showIndex (showIndex);
- }
- return result;
-}
-
-/**
- * Marks the receiver's header as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setHeaderVisible (boolean show) {
- checkWidget ();
- int height = show ? headerHeight : 0;
- OS.SetDataBrowserListViewHeaderBtnHeight (handle, (short)height);
-}
-
-/**
- * Marks the receiver's lines as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * If one of the receiver's ancestors is not visible or some
- * other condition makes the receiver not visible, marking
- * it visible may not actually cause it to be displayed.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setLinesVisible (boolean show) {
- checkWidget ();
-}
-
-void setScrollWidth (TableItem item) {
- if (columnCount != 0) return;
- GC gc = new GC (this);
- int newWidth = item.calculateWidth (0, gc);
- gc.dispose ();
- newWidth += EXTRA_WIDTH;
- short [] width = new short [1];
- OS.GetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, width);
- if (width [0] < newWidth) {
- OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short) newWidth);
- }
-}
-
-/**
- * Selects the item at the given zero-relative index in the receiver.
- * The current selected is first cleared, then the new item is selected.
- *
- * @param index the index of the item to select
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#deselectAll()
- * @see Table#select(int)
- */
-public void setSelection (int index) {
- checkWidget();
- setSelection (index, false);
-}
-
-void setSelection (int index, boolean notify) {
-// checkWidget();
- if (0 <= index && index < itemCount) {
- int [] id = new int [] {index + 1};
- if (!notify) ignoreSelect = true;
- OS.SetDataBrowserSelectedItems (handle, id.length, id, OS.kDataBrowserItemsAssign);
- if (!notify) ignoreSelect = false;
- showIndex (id [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.
- * Indices that are out of range are ignored and no items will be selected
- * if start is greater than end.
- *
- * @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) {
- 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, length, ids, OS.kDataBrowserItemsAssign);
- ignoreSelect = false;
- showIndex (ids [0] - 1);
-}
-
-/**
- * Selects the items at the given zero-relative indices in the receiver.
- * The current selected is first cleared, then the new items are selected.
- *
- * @param indices the indices of the items to select
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#deselectAll()
- * @see Table#select(int[])
- */
-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, length, 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 array of items is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the 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>
- *
- * @see Table#deselectAll()
- * @see Table#select(int)
- */
-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, length, 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], 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) {
- Rectangle rect = getClientArea ();
- if (rect.height < getItemHeight ()) {
- showIndex = index;
- return;
- }
- showIndex = -1;
- TableItem item = items [index];
- Rectangle itemRect = item.getBounds (0);
- if (!itemRect.isEmpty()) {
- if (rect.contains (itemRect.x, itemRect.y)
- && rect.contains (itemRect.x, itemRect.y + itemRect.height)) return;
- }
- int id = columnCount == 0 ? COLUMN_ID : columns [0].id;
- if ((style & SWT.CHECK) != 0) id = CHECK_COLUMN_ID;
- OS.RevealDataBrowserItem (handle, index + 1, id, (byte) OS.kDataBrowserRevealWithoutSelecting);
- }
-}
-
-/**
- * Shows the item. If the item is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the item is visible.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the 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>
- *
- * @see Table#showSelection()
- */
-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);
-}
-
-/**
- * Shows the selection. If the selection is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the selection is visible.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Table#showItem(TableItem)
- */
-public void showSelection () {
- checkWidget();
- int index = getSelectionIndex ();
- if (index >= 0) showIndex (index);
-}
-
-int trackingProc (int browser, int id, int property, int theRect, int startPt, int modifiers) {
- return 1;
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TableColumn.java
deleted file mode 100644
index c25f3d4..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TableColumn.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.*;
-
-/**
- * Instances of this class represent a column in a table widget.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>LEFT, RIGHT, CENTER</dd>
- * <dt><b>Events:</b></dt>
- * <dd> Move, Resize, Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class TableColumn extends Item {
- Table parent;
- int id;
- boolean resizable;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</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#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableColumn (Table parent, int style) {
- super (parent, checkStyle (style));
- resizable = true;
- this.parent = parent;
- parent.createItem (this, parent.getColumnCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</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#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableColumn (Table parent, int style, int index) {
- super (parent, checkStyle (style));
- resizable = true;
- this.parent = parent;
- parent.createItem (this, index);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is moved or resized, by sending
- * it one of the messages defined in the <code>ControlListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #removeControlListener
- */
-public void addControlListener(ControlListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Resize,typedListener);
- addListener (SWT.Move,typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is selected, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the column header is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener (SelectionListener listener) {
- 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);
-}
-
-/**
- * Returns a value which describes the position of the
- * text or image in the receiver. The value will be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>.
- *
- * @return the alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getAlignment () {
- 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 ();
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Table</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Table getParent () {
- checkWidget ();
- return parent;
-}
-
-/**
- * Gets the resizable attribute. A column that is
- * not resizable cannot be dragged by the user but
- * may be resized by the programmer.
- *
- * @return the resizable attribute
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getResizable () {
- checkWidget ();
- return resizable;
-}
-
-/**
- * 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 ();
- short [] width = new short [1];
- OS.GetDataBrowserTableViewNamedColumnWidth (parent.handle, id, width);
- return Math.max (0, width [0] - Table.EXTRA_WIDTH);
-}
-
-/**
- * Causes the receiver to be resized to its preferred size.
- * For a composite, this involves computing the preferred size
- * from its layout, if there is one.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- */
-public void pack () {
- checkWidget ();
- GC gc = new GC (parent);
- int width = 0;
- int index = parent.indexOf (this);
- for (int i=0; i<parent.itemCount; i++) {
- TableItem item = parent.items [i];
- width = Math.max (width, item.calculateWidth (index, gc));
- }
- gc.dispose ();
- width += Table.EXTRA_WIDTH;
- OS.SetDataBrowserTableViewNamedColumnWidth (parent.handle, id, (short) width);
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = 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);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Move, listener);
- eventTable.unhook (SWT.Resize, listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control 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);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-/**
- * Controls how text and images will be displayed in the receiver.
- * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
- * or <code>CENTER</code>.
- *
- * @param alignment the new alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setAlignment (int alignment) {
- 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);
-}
-
-/**
- * Sets the resizable attribute. A column that is
- * not resizable cannot be dragged by the user but
- * may be resized by the programmer.
- *
- * @param resizable the resize attribute
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setResizable (boolean resizable) {
- checkWidget ();
- this.resizable = resizable;
- updateHeader ();
-}
-
-public void setText (String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- updateHeader ();
-}
-
-/**
- * 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 ();
- OS.SetDataBrowserTableViewNamedColumnWidth (parent.handle, id, (short) (width + Table.EXTRA_WIDTH));
- updateHeader ();
-}
-
-void updateHeader () {
- 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;
- if (resizable) {
- desc.minimumWidth = 0;
- desc.maximumWidth = 0x7fff;
- } else {
- short [] width = new short [1];
- OS.GetDataBrowserTableViewNamedColumnWidth (parent.handle, id, width);
- desc.minimumWidth = desc.maximumWidth = width [0];
- }
- desc.titleString = str;
- OS.SetDataBrowserListViewHeaderDesc (parent.handle, id, desc);
- OS.CFRelease (str);
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TableItem.java
deleted file mode 100644
index dfcb151..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TableItem.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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 this class represent a selectable user interface object
- * that represents an item in a table.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class TableItem extends Item {
- Table parent;
- String [] strings;
- Image [] images;
- boolean checked, grayed;
- Color foreground, background;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>) and a style value
- * describing its behavior and appearance. The item is added
- * to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableItem (Table parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, parent.getItemCount ());
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</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
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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);
-}
-
-int calculateWidth (int index, GC gc) {
- int width = 0;
- Image image = getImage (index);
- String text = getText (index);
- if (image != null) width = image.getBounds ().width + 2;
- if (text != null && text.length () > 0) width += gc.stringExtent (text).x;
- return width;
-}
-
-/**
- * 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>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- return background != null ? background : parent.getBackground ();
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent at a column in the table.
- *
- * @param index the index that specifies the column
- * @return the receiver's bounding column rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle getBounds (int index) {
- checkWidget ();
- if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);;
- Rect rect = new Rect();
- int itemIndex = parent.indexOf (this);
- int id = itemIndex + 1;
- int columnId = index == 0 ? Table.COLUMN_ID : parent.columns [index].id;
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- int x = rect.left, y = rect.top;
- int width = rect.right - rect.left;
- int height = rect.bottom - rect.top;
- OS.GetControlBounds (parent.handle, rect);
- x -= rect.left;
- y -= rect.top;
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Returns <code>true</code> if the receiver is checked,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- *
- * @return the checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-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 ();
-}
-
-/**
- * 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>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- return foreground != null ? foreground : parent.getForeground ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is grayed,
- * and false otherwise. When the parent does not have
- * the <code>CHECK</code> style, return false.
- *
- * @return the grayed state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getGrayed () {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return false;
- return grayed;
-}
-
-/**
- * Returns the image stored at the given column index in the receiver,
- * or null if the image has not been set or if the column does not exist.
- *
- * @param index the column index
- * @return the image stored at the given column index 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 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;
-}
-
-/**
- * Returns a rectangle describing the size and location
- * relative to its parent of an image at a column in the
- * table.
- *
- * @param index the index that specifies the column
- * @return the receiver's bounding image rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle getImageBounds (int index) {
- checkWidget();
- if (index != 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
- Rect rect = new Rect();
- int itemIndex = parent.indexOf (this);
- int id = itemIndex + 1;
- int columnId = index == 0 ? Table.COLUMN_ID : parent.columns [index].id;
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, columnId, OS.kDataBrowserPropertyContentPart, rect) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- int x = rect.left, y = rect.top;
- int width = 0;
- if (image != null) {
- Rectangle bounds = image.getBounds ();
- width += bounds.width + 2;
- }
- int height = rect.bottom - rect.top;
- OS.GetControlBounds (parent.handle, rect);
- x -= rect.left;
- y -= rect.top;
- return new Rectangle (x, y, width, height);
-}
-
-/**
- * Gets the image indent.
- *
- * @return the indent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getImageIndent () {
- checkWidget();
- return 0;
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Table</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Table getParent () {
- checkWidget();
- return parent;
-}
-
-/**
- * Returns the text stored at the given column index in the receiver,
- * or empty string if the text has not been set.
- *
- * @param index the column index
- * @return the text stored at the given column index 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>
- * @exception SWTError <ul>
- * <li>ERROR_CANNOT_GET_TEXT - if the column at index does not exist</li>
- * </ul>
- */
-public String getText (int index) {
- checkWidget();
- if (index == 0) return super.getText ();
- if (strings != null) {
- if (0 <= index && index < strings.length) {
- String string = strings [index];
- return string != null ? string : "";
- }
- }
- return "";
-}
-
-void redraw () {
- int itemIndex = parent.indexOf (this);
- int [] id = new int [] {itemIndex + 1};
- OS.UpdateDataBrowserItems (parent.handle, 0, id.length, id, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem);
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- background = foreground = null;
- parent = null;
-}
-
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * 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>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- background = color;
- redraw ();
-}
-
-/**
- * Sets the checked state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param checked the new checked state of the checkbox
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setChecked (boolean checked) {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return;
- this.checked = checked;
- redraw ();
-}
-
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * 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>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- foreground = color;
- redraw ();
-}
-
-/**
- * Sets the grayed state of the checkbox for this item. This state change
- * only applies if the Table was created with the SWT.CHECK style.
- *
- * @param grayed the new grayed state of the checkbox;
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setGrayed (boolean grayed) {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return;
- this.grayed = grayed;
- redraw ();
-}
-
-/**
- * Sets the image for multiple columns in the Table.
- *
- * @param images the array of new images
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the images 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 [] images) {
- checkWidget();
- if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<images.length; i++) {
- setImage (i, images [i]);
- }
-}
-
-/**
- * Sets the receiver's image at a column.
- *
- * @param index the column index
- * @param image the new image
- *
- * @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 (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);
- parent.setScrollWidth (this);
- }
- int columnCount = parent.columnCount;
- if (0 <= index && index < columnCount) {
- if (images == null) images = new Image [columnCount];
- if (images.length != columnCount) {
- Image [] newImages = new Image [columnCount];
- System.arraycopy (images, 0, newImages, 0, images.length);
- images = newImages;
- }
- if (0 <= index && index < images.length) images [index] = image;
- }
- int [] id = new int [] {itemIndex + 1};
- OS.UpdateDataBrowserItems (parent.handle, 0, id.length, id, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem);
-}
-
-public void setImage (Image image) {
- checkWidget ();
- setImage (0, image);
-}
-
-/**
- * Sets the image indent.
- *
- * @param indent the new indent
- *
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setImageIndent (int indent) {
- checkWidget();
- if (indent < 0) return;
-}
-
-/**
- * Sets the text for multiple columns in the table.
- *
- * @param strings the array of new strings
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (String [] strings) {
- 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);
- }
-}
-
-/**
- * Sets the receiver's text at a column
- *
- * @param index the column index
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setText (int 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);
- parent.setScrollWidth (this);
- }
- 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/carbon2/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/Tree.java
deleted file mode 100644
index cf69edc..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/Tree.java
+++ /dev/null
@@ -1,1226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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.Rect;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Instances of this class provide a selectable user interface object
- * that displays a hierarchy of items and issue notificiation when an
- * item in the hierarchy is selected.
- * <p>
- * The item children that may be added to instances of this class
- * must be of type <code>TreeItem</code>.
- * </p><p>
- * Note that although this class is a subclass of <code>Composite</code>,
- * it does not make sense to add <code>Control</code> children to it,
- * or set a layout on it.
- * </p><p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>SINGLE, MULTI, CHECK</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles SINGLE and MULTI may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Tree extends Composite {
- TreeItem [] items;
- GC paintGC;
- int anchorFirst, anchorLast;
- boolean ignoreSelect, ignoreExpand;
- TreeItem showItem;
- static final int CHECK_COLUMN_ID = 1024;
- static final int COLUMN_ID = 1025;
- static final int EXTRA_WIDTH = 30;
- static final int CHECK_COLUMN_WIDTH = 25;
-
-/**
- * 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#CHECK
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public Tree (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's selection changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the item field of the event object is valid.
- * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,
- * the event object detail field contains the value <code>SWT.CHECK</code>.
- * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
- * The item field of the event object is valid for default selection, but the detail field is not used.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
-public void addSelectionListener(SelectionListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection, typedListener);
- addListener (SWT.DefaultSelection, typedListener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when an item in the receiver is expanded or collapsed
- * by sending it one of the messages defined in the <code>TreeListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see TreeListener
- * @see #removeTreeListener
- */
-public void addTreeListener(TreeListener listener) {
- 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++) {
- TreeItem item = items [i];
- width = Math.max (width, item.calculateWidth (gc));
- }
- gc.dispose ();
- width += EXTRA_WIDTH;
- if ((style & SWT.CHECK) != 0) width += CHECK_COLUMN_WIDTH;
- } 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();
- int border = 0;
- int [] outMetric = new int [1];
- OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric);
- border += outMetric [0];
- OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric);
- border += outMetric [0];
- Rect rect = new Rect ();
- OS.GetDataBrowserScrollBarInset (handle, rect);
- x -= rect.left + border;
- y -= rect.top + border;
- width += rect.left + rect.right + border + border;
- height += rect.top + rect.bottom + border + border;
- 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);
- 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;
- //TODO - check column size
- checkColumn.headerBtnDesc_minimumWidth = CHECK_COLUMN_WIDTH;
- checkColumn.headerBtnDesc_maximumWidth = CHECK_COLUMN_WIDTH;
- 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.kDataBrowserCustomType;
- column.propertyDesc_propertyFlags = OS.kDataBrowserListViewSelectionColumn | OS.kDataBrowserDefaultPropertyFlags;
- column.headerBtnDesc_initialOrder = OS.kDataBrowserOrderIncreasing;
- OS.AddDataBrowserListViewColumn (handle, column, position);
- OS.SetDataBrowserListViewDisclosureColumn (handle, COLUMN_ID, true);
- OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short) 0);
-
- /*
- * Feature in the Macintosh. Scroll bars are not created until
- * the data browser needs to draw them. The fix is to force the scroll
- * bars to be created by temporarily giving the widget a size, drawing
- * it on a offscreen buffer to avoid flashes and then restoring it to
- * size zero.
- */
- int size = 50;
- Rect rect = new Rect ();
- rect.right = rect.bottom = (short) size;
- OS.SetControlBounds (handle, rect);
- int bpl = size * 4;
- int [] gWorld = new int [1];
- int data = OS.NewPtr (bpl * size);
- OS.NewGWorldFromPtr (gWorld, OS.k3ARGBPixelFormat, rect, 0, 0, 0, data, bpl);
- int [] curPort = new int [1];
- int [] curGWorld = new int [1];
- OS.GetGWorld (curPort, curGWorld);
- OS.SetGWorld (gWorld [0], curGWorld [0]);
- OS.DrawControlInCurrentPort (handle);
- OS.SetGWorld (curPort [0], curGWorld [0]);
- OS.DisposeGWorld (gWorld [0]);
- OS.DisposePtr (data);
- rect.right = rect.bottom = (short) 0;
- OS.SetControlBounds (handle, rect);
-}
-
-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;
- if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
- 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];
-}
-
-Color defaultBackground () {
- Display display = getDisplay ();
- return display.getSystemColor (SWT.COLOR_LIST_BACKGROUND);
-}
-
-Color defaultForeground () {
- Display display = getDisplay ();
- return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND);
-}
-
-int defaultThemeFont () {
- return OS.kThemeViewsFont;
-}
-
-/**
- * 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;
-}
-
-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);
- }
- releaseItems (item.getItems ());
- releaseItem (item);
- 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;
- }
- }
- setScrollWidth ();
-}
-
-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];
- Rect rect = new Rect ();
- OS.memcpy (rect, theRect, Rect.sizeof);
- 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;
- if (gc == null) {
- GCData data = new GCData ();
- int [] port = new int [1];
- OS.GetPort (port);
- data.port = port [0];
- gc = GC.carbon_new (this, data);
- }
- 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);
- Color background = item.getBackground ();
- 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 + (height - bounds.height) / 2, bounds.width, bounds.height);
- x += bounds.width + 2;
- }
- Point extent = gc.stringExtent (item.text);
- if ((itemState & OS.kDataBrowserItemIsSelected) != 0) {
- Display display = getDisplay ();
- gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
- gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
- gc.fillRectangle (x - 1, y, extent.x + 2, height);
- } else {
- Color foreground = item.getForeground ();
- gc.setForeground (foreground);
- }
- gc.drawString (item.text, x, y + (height - extent.y) / 2);
- if (gc != paintGC) gc.dispose ();
- return OS.noErr;
-}
-
-void drawWidget (int control, int damageRgn, int visibleRgn, int theEvent) {
- GC currentGC = paintGC;
- if (currentGC == null) {
- GCData data = new GCData ();
- data.paintEvent = theEvent;
- data.visibleRgn = visibleRgn;
- paintGC = GC.carbon_new (this, data);
- }
- super.drawWidget (control, damageRgn, visibleRgn, theEvent);
- if (currentGC == null) {
- paintGC.dispose ();
- paintGC = null;
- }
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- int border = 0;
- int [] outMetric = new int [1];
- OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric);
- border += outMetric [0];
- OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric);
- border += outMetric [0];
- Rect rect = new Rect (), inset = new Rect ();
- OS.GetControlBounds (handle, rect);
- OS.GetDataBrowserScrollBarInset (handle, inset);
- int width = Math.max (0, rect.right - rect.left - inset.right - border - border);
- int height = Math.max (0, rect.bottom - rect.top - inset.bottom - border - border);
- return new Rectangle (inset.left, inset.top, width, height);
-}
-
-/**
- * Returns the item at the given point in the receiver
- * or null if no such item exists. The point is in the
- * coordinate system of the receiver.
- *
- * @param point the point used to locate the item
- * @return the item at the given point
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public 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));
- //TODO - optimize
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
- if (item != null) {
- if (OS.GetDataBrowserItemPartBounds (handle, item.id, COLUMN_ID, OS.kDataBrowserPropertyEnclosingPart, rect) == OS.noErr) {
- if (OS.PtInRect (pt, rect)) return item;
- }
- }
- }
- return null;
-}
-
-/**
- * Returns the number of items contained in the receiver
- * that are direct item children of the receiver. The
- * number that is returned is the number of roots in the
- * tree.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- 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;
-}
-
-/**
- * Returns the height of the area which would be used to
- * display <em>one</em> of the items in the tree.
- *
- * @return the height of one item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemHeight () {
- checkWidget ();
- short [] height = new short [1];
- if (OS.GetDataBrowserTableViewRowHeight (handle, height) != OS.noErr) {
- error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
- }
- return height [0];
-}
-
-/**
- * Returns the number of items contained in the receiver
- * that are direct item children of the receiver. These
- * are the roots of the tree.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getItems () {
- checkWidget ();
- return getItems (null);
-}
-
-TreeItem [] getItems (TreeItem item) {
- if (items == null) return new TreeItem [0];
- 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;
-}
-
-/**
- * Returns the receiver's parent item, which must be a
- * <code>TreeItem</code> or null when the receiver is a
- * root.
- *
- * @return the receiver's parent item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem getParentItem () {
- checkWidget ();
- return null;
-}
-
-/**
- * Returns an array of <code>TreeItem</code>s that are currently
- * selected in the receiver. An empty array indicates that no
- * items are selected.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its selection, so modifying the array will
- * not affect the receiver.
- * </p>
- * @return an array representing the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getSelection () {
- 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;
-}
-
-/**
- * Returns the number of selected items contained in the receiver.
- *
- * @return the number of selected items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getSelectionCount () {
- checkWidget ();
- int [] 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];
-}
-
-/**
- * Returns the item which is currently at the top of the receiver.
- * This item can change when items are expanded, collapsed, scrolled
- * or new items are added or removed.
- *
- * @return the item at the top of the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public TreeItem getTopItem () {
- checkWidget();
- //TODO - optimize
- Rect rect = new Rect ();
- OS.GetControlBounds (handle, rect);
- int offset = 0;
- int [] outMetric = new int [1];
- OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric);
- offset += outMetric [0];
- OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric);
- offset += outMetric [0];
- int y = rect.top + offset;
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
- if (item != null) {
- if (OS.GetDataBrowserItemPartBounds (handle, item.id, COLUMN_ID, OS.kDataBrowserPropertyEnclosingPart, rect) == OS.noErr) {
- if (rect.top <= y && y <= rect.bottom) return item;
- }
- }
- }
- return null;
-}
-
-int hitTestProc (int browser, int id, int property, int theRect, int mouseRect) {
- 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;
- item.checked = !item.checked;
- if (item.checked && item.grayed) {
- OS.SetDataBrowserItemDataButtonValue (itemData, (short) OS.kThemeButtonMixed);
- } else {
- int theData = item.checked ? OS.kThemeButtonOn : OS.kThemeButtonOff;
- OS.SetDataBrowserItemDataButtonValue (itemData, (short) theData);
- }
- 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);
- int theData = OS.kThemeButtonOff;
- if (item.checked) theData = item.grayed ? OS.kThemeButtonMixed : OS.kThemeButtonOn;
- OS.SetDataBrowserItemDataButtonValue (itemData, (short) 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.kDataBrowserContainerClosing: {
- /*
- * Bug in the Macintosh. For some reason, if the selected sub items of an item
- * get a kDataBrowserItemDeselected notificaton when the item is collapsed, a
- * call to GetDataBrowserSelectionAnchor () will cause a segment fault. The
- * fix is to deselect these items ignoring kDataBrowserItemDeselected and them
- * issue a selection event.
- */
- int ptr = OS.NewHandle (0);
- if (OS.GetDataBrowserItems (handle, item.id, true, OS.kDataBrowserItemIsSelected, ptr) == OS.noErr) {
- int count = OS.GetHandleSize (ptr) / 4;
- if (count > 0) {
- int [] ids = new int [count];
- OS.HLock (ptr);
- int [] start = new int [1];
- OS.memcpy (start, ptr, 4);
- OS.memcpy (ids, start [0], count * 4);
- OS.HUnlock (ptr);
- ignoreSelect = true;
- OS.SetDataBrowserSelectedItems (handle, ids.length, ids, OS.kDataBrowserItemsRemove);
- ignoreSelect = false;
- Event event = new Event ();
- event.item = item;
- if (ignoreExpand) {
- sendEvent (SWT.Selection, event);
- } else {
- postEvent (SWT.Selection, event);
- }
- }
- }
- OS.DisposeHandle (ptr);
- break;
- }
- case OS.kDataBrowserContainerClosed: {
- if (!ignoreExpand) {
- Event event = new Event ();
- event.item = item;
- sendEvent (SWT.Collapse, event);
- }
- setScrollWidth ();
- 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++;
- }
- TreeItem [] newItems = new TreeItem [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;
- newItems [items [i].index] = items [i];
- }
- }
- OS.AddDataBrowserItems (handle, id, ids.length, ids, 0);
- setScrollWidth (newItems, false);
- 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.isDisposed ()) oldFocus.sendFocusEvent (false);
- if (!isDisposed () && isEnabled ()) sendFocusEvent (true);
- }
- return result;
-}
-
-boolean releaseItem (TreeItem item) {
- if (item.isDisposed ()) return false;
- items [item.id - 1] = null;
- return true;
-}
-
-void releaseItems (TreeItem [] nodes) {
- for (int i=0; i<nodes.length; i++) {
- TreeItem item = nodes [i];
- TreeItem [] sons = item.getItems ();
- if (sons.length != 0) {
- releaseItems (sons);
- }
- if (releaseItem (item)) {
- item.releaseResources ();
- }
- }
-}
-
-void releaseWidget () {
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
- if (item != null && !item.isDisposed ()) {
- item.releaseResources ();
- }
- }
- super.releaseWidget ();
-}
-
-/**
- * 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 ();
- 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;
- setScrollWidth ();
-}
-
-/**
- * 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);
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection, listener);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when items in the receiver are expanded or collapsed..
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see TreeListener
- * @see #addTreeListener
- */
-public void removeTreeListener(TreeListener listener) {
- checkWidget ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Expand, listener);
- eventTable.unhook (SWT.Collapse, listener);
-}
-
-/**
- * Display a mark indicating the point at which an item will be inserted.
- * The drop insert item has a visual hint to show where a dragged item
- * will be inserted when dropped on the tree.
- *
- * @param item the insert item. Null will clear the insertion mark.
- * @param after true places the insert mark above 'item'. false places
- * the insert mark below 'item'.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the 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 setInsertMark (TreeItem item, boolean before) {
- checkWidget ();
- if (item != null) {
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- }
-}
-
-/**
- * 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 ();
- if ((style & SWT.SINGLE) != 0) return;
- ignoreSelect = true;
- OS.SetDataBrowserSelectedItems (handle, 0, null, OS.kDataBrowserItemsAssign);
- ignoreSelect = false;
-}
-
-int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- /*
- * Ensure that the selection is visible when the tree is resized
- * from a zero size to a size that can show the selection.
- */
- int result = super.setBounds (control, x, y, width, height, move, resize, events);
- if (showItem != null && !showItem.isDisposed ()) {
- showItem (showItem , true);
- }
- return result;
-}
-
-int calculateWidth (TreeItem [] items, GC gc) {
- int width = 0;
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items [i];
- width = Math.max (width, item.calculateWidth (gc));
- if (item.getExpanded ()) {
- width = Math.max (width, calculateWidth (item.getItems (), gc));
- }
- }
- return width;
-}
-
-void setScrollWidth () {
- setScrollWidth (getItems (), true);
-}
-
-void setScrollWidth (TreeItem item) {
- TreeItem parentItem = item.parentItem;
- if (parentItem != null && !parentItem.getExpanded ()) return;
- GC gc = new GC (this);
- int newWidth = item.calculateWidth (gc);
- gc.dispose ();
- short [] width = new short [1];
- OS.GetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, width);
- if (width [0] < newWidth) {
- OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short) newWidth);
- }
-}
-
-void setScrollWidth (TreeItem [] items, boolean set) {
- GC gc = new GC (this);
- int newWidth = calculateWidth (items, gc);
- gc.dispose ();
- if (!set) {
- short [] width = new short [1];
- OS.GetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, width);
- if (width [0] >= newWidth) return;
- }
- OS.SetDataBrowserTableViewNamedColumnWidth (handle, COLUMN_ID, (short) newWidth);
-}
-
-/**
- * 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 array of items is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if one of the 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>
- *
- * @see Tree#deselectAll()
- */
-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);
-}
-
-/**
- * Sets the item which is currently at the top of the receiver.
- * This item can change when items are expanded, collapsed, scrolled
- * or new items are added or removed.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the 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>
- *
- * @see Tree#getTopItem()
- *
- * @since 2.1
- */
-public void setTopItem (TreeItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- showItem (item, false);
- OS.RevealDataBrowserItem (handle, item.id, COLUMN_ID, (byte) OS.kDataBrowserRevealWithoutSelecting);
-// Rect rect = new Rect ();
-// OS.GetControlBounds (handle, rect);
-// int x = rect.left, y = rect.top;
-// if (OS.GetDataBrowserItemPartBounds (handle, item.id, COLUMN_ID, OS.kDataBrowserPropertyEnclosingPart, rect) == OS.noErr) {
-// OS.SetDataBrowserScrollPosition (handle, rect.top - y - 3, 0);
-// }
-}
-
-/**
- * Shows the item. If the item is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled
- * and expanded until the item is visible.
- *
- * @param item the item to be shown
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the item is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the 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>
- *
- * @see Tree#showSelection()
- */
-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) {
- //TODO - optimize
- Rectangle rect = getClientArea ();
- if (rect.height < getItemHeight ()) {
- showItem = item;
- return;
- }
- showItem = null;
- Rectangle itemRect = item.getBounds ();
- if (!itemRect.isEmpty()) {
- if (rect.contains (itemRect.x, itemRect.y)
- && rect.contains (itemRect.x, itemRect.y + itemRect.height)) return;
- }
- OS.RevealDataBrowserItem (handle, item.id, COLUMN_ID, (byte) OS.kDataBrowserRevealWithoutSelecting);
- }
-}
-
-/**
- * Shows the selection. If the selection is already showing in the receiver,
- * this method simply returns. Otherwise, the items are scrolled until
- * the selection is visible.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Tree#showItem(TreeItem)
- */
-public void showSelection () {
- checkWidget ();
- //TODO - 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) {
- return 1;
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TreeItem.java
deleted file mode 100644
index f83947b..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon2/org/eclipse/swt/widgets/TreeItem.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.widgets;
-
-
-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 this class represent a selectable user interface object
- * that represents a hierarchy of tree items in a tree widget.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class TreeItem extends Item {
- Tree parent;
- TreeItem parentItem;
- int id, index = -1;
- boolean checked, grayed;
- Color foreground, background;
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TreeItem (Tree parent, int style) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, null, -1);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</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
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</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 parentItem 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 TreeItem (TreeItem parentItem, int style) {
- super (checkNull (parentItem).parent, style);
- parent = parentItem.parent;
- this.parentItem = parentItem;
- parent.createItem (this, parentItem, -1);
-}
-
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</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 parentItem 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
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-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;
-}
-
-int calculateWidth (GC gc) {
- int width = 0;
- Image image = getImage ();
- String text = getText ();
- if (image != null) width = image.getBounds ().width + 2;
- if (text != null && text.length () > 0) width += gc.stringExtent (text).x;
- return width;
-}
-
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/**
- * 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>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- return background != null ? background : parent.getBackground ();
-}
-
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent.
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Rectangle getBounds () {
- checkWidget ();
- Rect rect = new Rect();
- if (OS.GetDataBrowserItemPartBounds (parent.handle, id, Tree.COLUMN_ID, OS.kDataBrowserPropertyContentPart, rect) != OS.noErr) {
- return new Rectangle (0, 0, 0, 0);
- }
- 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);
-}
-
-/**
- * Returns <code>true</code> if the receiver is checked,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- * <p>
- *
- * @return the checked state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getChecked () {
- 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 ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is expanded,
- * and false otherwise.
- * <p>
- *
- * @return the expanded state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getExpanded () {
- checkWidget ();
- int [] state = new int [1];
- OS.GetDataBrowserItemState (parent.handle, id, state);
- return (state [0] & OS.kDataBrowserContainerIsOpen) != 0;
-}
-
-/**
- * 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>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- return foreground != null ? foreground : parent.getForeground ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is grayed,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- * <p>
- *
- * @return the grayed state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean getGrayed () {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return false;
- return grayed;
-}
-
-/**
- * Returns the number of items contained in the receiver
- * that are direct item children of the receiver.
- *
- * @return the number of items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getItemCount () {
- checkWidget ();
- return parent.getItemCount (this);
-}
-
-/**
- * Returns an array of <code>TreeItem</code>s which are the
- * direct item children of the receiver.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of items, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return the receiver's items
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem [] getItems () {
- checkWidget ();
- return parent.getItems (this);
-}
-
-/**
- * Returns the receiver's parent, which must be a <code>Tree</code>.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Tree getParent () {
- checkWidget ();
- return parent;
-}
-
-/**
- * Returns the receiver's parent item, which must be a
- * <code>TreeItem</code> or null when the receiver is a
- * root.
- *
- * @return the receiver's parent item
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public TreeItem getParentItem () {
- checkWidget ();
- return parentItem;
-}
-
-void redraw () {
- int parentID = parentItem == null ? OS.kDataBrowserNoItem : parentItem.id;
- OS.UpdateDataBrowserItems (parent.handle, parentID, 1, new int[] {id}, OS.kDataBrowserItemNoProperty, OS.kDataBrowserNoItem);
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- background = foreground = null;
- parentItem = null;
- parent = null;
- id = 0;
- index = -1;
-}
-
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * 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>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- background = color;
- redraw ();
-}
-
-/**
- * Sets the checked state of the receiver.
- * <p>
- *
- * @param checked the new checked state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setChecked (boolean checked) {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return;
- this.checked = checked;
- redraw ();
-}
-
-/**
- * Sets the expanded state of the receiver.
- * <p>
- *
- * @param expanded the new expanded state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setExpanded (boolean expanded) {
- checkWidget ();
- parent.ignoreExpand = true;
- if (expanded) {
- OS.OpenDataBrowserContainer (parent.handle, id);
- } else {
- OS.CloseDataBrowserContainer (parent.handle, id);
- }
- parent.ignoreExpand = false;
-}
-
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @since 2.0
- *
- * @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>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ()) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- foreground = color;
- redraw ();
-}
-
-/**
- * Sets the grayed state of the receiver.
- * <p>
- *
- * @param checked the new grayed state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setGrayed (boolean grayed) {
- checkWidget ();
- if ((parent.style & SWT.CHECK) == 0) return;
- this.grayed = grayed;
- redraw ();
-}
-
-public void setImage (Image image) {
- checkWidget ();
- super.setImage (image);
- parent.setScrollWidth (this);
- redraw ();
-}
-
-public void setText (String string) {
- checkWidget ();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- parent.setScrollWidth (this);
- redraw ();
-}
-
-}