summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/cocoa
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2008-06-06 19:14:18 +0000
committerSilenio Quarti <silenio>2008-06-06 19:14:18 +0000
commit44db0957d87cb491a85384855623a3380a72614e (patch)
tree276a126120d4b86272f5e47ef3a9d0c89dc17a5f /bundles/org.eclipse.swt/Eclipse SWT/cocoa
parent6752d439d76030429e87bce5575ca5fc06a4993b (diff)
downloadeclipse.platform.swt-44db0957d87cb491a85384855623a3380a72614e.tar.gz
eclipse.platform.swt-44db0957d87cb491a85384855623a3380a72614e.tar.xz
eclipse.platform.swt-44db0957d87cb491a85384855623a3380a72614e.zip
initial z-order / cleanup calls to JNIGetObject / background of composites
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/cocoa')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java34
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java228
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Group.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scale.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Slider.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java37
24 files changed, 186 insertions, 231 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java
index 0c7c71de2d..a3c85a817b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java
@@ -203,8 +203,7 @@ void createHandle () {
widget.setTarget(widget);
widget.setAction(OS.sel_sendSelection);
widget.setTag(jniRef);
- view = widget;
- parent.contentView().addSubview_(widget);
+ view = widget;
_setAlignment(style);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
index 239eaa0c6b..55dc6415e2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
@@ -369,14 +369,12 @@ void createHandle () {
widget.setAction(OS.sel_sendSelection);
widget.setTag(jniRef);
view = widget;
- parent.view.addSubview_(widget);
} else {
NSComboBox widget = (NSComboBox)new SWTComboBox().alloc();
widget.initWithFrame(new NSRect());
widget.setTag(jniRef);
widget.setDelegate(widget);
view = widget;
- parent.contentView().addSubview_(widget);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java
index f5541d4e04..7b129f5bdb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Composite.java
@@ -94,16 +94,12 @@ Control [] _getChildren () {
NSArray views = contentView().subviews();
int count = views.count();
Control [] children = new Control [count];
+ if (count == 0) return children;
int j = 0;
for (int i=0; i<count; i++){
- int tag = new NSView(views.objectAtIndex(i)).tag();
- if (tag != 0 && tag != -1) {
- Object widget = OS.JNIGetObject(tag);
- if (widget != null && widget != this) {
- if (widget instanceof Control) {
- children [j++] = (Control) widget;
- }
- }
+ Widget widget = display.getWidget (views.objectAtIndex (count - i - 1));
+ if (widget != null && widget != this && widget instanceof Control) {
+ children [j++] = (Control) widget;
}
}
if (j == count) return children;
@@ -233,10 +229,6 @@ NSView contentView () {
}
void createHandle () {
- createHandle (parent.contentView());
-}
-
-void createHandle (NSView parent) {
state |= CANVAS;
NSRect rect = new NSRect();
if ((style & (SWT.V_SCROLL | SWT.H_SCROLL)) != 0 || hasBorder ()) {
@@ -258,9 +250,21 @@ void createHandle (NSView parent) {
if (scrollView != null) {
// view.setAutoresizingMask (OS.NSViewWidthSizable | OS.NSViewHeightSizable);
scrollView.setDocumentView(view);
- if (parent != null) parent.addSubview_(scrollView);
- } else {
- if (parent != null) parent.addSubview_(view);
+ }
+}
+
+void drawRect (int id, NSRect rect) {
+ super.drawRect (id, rect);
+ if ((state & CANVAS) != 0) {
+ if (background != null && !background.isDisposed ()) {
+ float [] color = background.handle;
+ NSRect bounds = view.bounds();
+ NSGraphicsContext context = NSGraphicsContext.currentContext();
+ context.saveGraphicsState();
+ NSColor.colorWithDeviceRed(color [0], color [1], color [2], color [3]).setFill();
+ NSBezierPath.fillRect(bounds);
+ context.restoreGraphicsState();
+ }
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index 46c8f33ccf..ff9f6cf3b1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -1538,17 +1538,20 @@ void sendMouseEvent (NSEvent nsEvent, int type, int button) {
sendEvent (type, event);
}
-void mouseDown(int theEvent) {
+void mouseDown(int id, int sel, int theEvent) {
+ super.mouseDown(id, sel, theEvent);
NSEvent nsEvent = new NSEvent (theEvent);
sendMouseEvent (nsEvent, SWT.MouseDown, 1);
}
-void mouseDragged(int theEvent) {
+void mouseDragged(int id, int sel, int theEvent) {
+ super.mouseDragged(id, sel, theEvent);
NSEvent nsEvent = new NSEvent (theEvent);
sendMouseEvent (nsEvent, SWT.MouseMove, 1);
}
-void mouseUp(int theEvent) {
+void mouseUp(int id, int sel, int theEvent) {
+ super.mouseUp(id, sel, theEvent);
NSEvent nsEvent = new NSEvent (theEvent);
sendMouseEvent (nsEvent, SWT.MouseUp, 1);
}
@@ -2137,7 +2140,6 @@ public void removeTraverseListener(TraverseListener listener) {
void resetCursorRects (int id, int sel) {
super.resetCursorRects (id, sel);
- Cursor cursor = findCursor();
if (cursor != null) view.addCursorRect(view.visibleRect(), cursor.handle);
}
@@ -2960,14 +2962,8 @@ public void setVisible (boolean visible) {
}
void setZOrder () {
-// int topHandle = topHandle ();
-// int parentHandle = parent.handle;
-// OS.HIViewAddSubview (parentHandle, topHandle);
-// OS.HIViewSetZOrder (topHandle, OS.kHIViewZOrderBelow, 0);
-// Rect rect = getInset ();
-// rect.right = rect.left;
-// rect.bottom = rect.top;
-// OS.SetControlBounds (topHandle, rect);
+ NSView topView = topView ();
+ parent.contentView().addSubview_positioned_relativeTo_(topView, OS.NSWindowBelow, null);
}
void setZOrder (Control control, boolean above) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java
index babf32c07b..fef75895d3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java
@@ -170,8 +170,7 @@ void createHandle () {
widget.setTarget(widget);
widget.setAction(OS.sel_sendSelection);
widget.setTag(jniRef);
- view = widget;
- parent.contentView().addSubview_(widget);
+ view = widget;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index b337ea4a77..2b27e0bf7e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -742,16 +742,7 @@ boolean filters (int eventType) {
*/
public Widget findWidget (int handle) {
checkDevice ();
- if (handle != 0 && OS.objc_msgSend(handle, OS.sel_respondsToSelector_1, OS.sel_tag) != 0) {
- int tag = OS.objc_msgSend(handle, OS.sel_tag);
- if (tag != -1) {
- Object object = OS.JNIGetObject(tag);
- if (object instanceof Widget) {
- return (Widget)object;
- }
- }
- }
- return null;
+ return getWidget (handle);
}
/**
@@ -841,15 +832,9 @@ public Shell getActiveShell () {
checkDevice ();
NSWindow window = application.keyWindow();
if (window != null) {
- NSView view = window.contentView();
- if (view != null && view.respondsToSelector(OS.sel_tag)) {
- int tag = OS.objc_msgSend(view.id, OS.sel_tag);
- if (tag != -1) {
- Object object = OS.JNIGetObject(tag);
- if (object instanceof Shell) {
- return (Shell)object;
- }
- }
+ Widget widget = getWidget(window.contentView());
+ if (widget instanceof Shell) {
+ return (Shell)widget;
}
}
return null;
@@ -1093,34 +1078,23 @@ public Control getFocusControl () {
NSWindow window = application.keyWindow();
if (window != null) {
NSResponder view = window.firstResponder();
- if (view != null && view.respondsToSelector(OS.sel_tag)) {
- int tag = OS.objc_msgSend(view.id, OS.sel_tag);
- if (tag != -1) {
- Object object = OS.JNIGetObject(tag);
- if (object instanceof Control) {
- //TODO go up hierarchy
- return (Control)object;
- }
- } else {
- /*
- * If the first responder is the shared field editor then answer its
- * delegate as the focus control.
- */
- if (view.isKindOfClass(NSText.static_class())) {
- NSText text = new NSText(view.id);
- if (text.isFieldEditor()) {
- id delegateId = text.delegate();
- if (delegateId != null) {
- NSObject delegate = new NSObject(delegateId.id);
- if (delegate.respondsToSelector(OS.sel_tag)) {
- tag = OS.objc_msgSend(delegate.id, OS.sel_tag);
- if (tag != 0 && tag != -1) {
- Object object = OS.JNIGetObject(tag);
- if (object instanceof Control) {
- return (Control)object;
- }
- }
- }
+ Widget widget = getWidget (view.id);
+ if (widget != null && widget instanceof Control) {
+ //TODO go up hierarchy
+ return (Control)widget;
+ } else {
+ /*
+ * If the first responder is the shared field editor then answer its
+ * delegate as the focus control.
+ */
+ if (view.isKindOfClass(NSText.static_class())) {
+ NSText text = new NSText(view.id);
+ if (text.isFieldEditor()) {
+ id delegateId = text.delegate();
+ if (delegateId != null) {
+ widget = getWidget (delegateId.id);
+ if (widget != null && widget instanceof Control) {
+ return (Control)widget;
}
}
}
@@ -1305,15 +1279,9 @@ public Shell [] getShells () {
Shell [] result = new Shell [windows.count()];
for (int i = 0; i < result.length; i++) {
NSWindow window = new NSWindow(windows.objectAtIndex(i));
- NSView view = window.contentView();
- if (view != null) {
- int jniRef = OS.objc_msgSend(view.id, OS.sel_tag);
- if (jniRef != 0 && jniRef != -1) {
- Object object = OS.JNIGetObject(jniRef);
- if (object instanceof Shell) {
- result[index++] = (Shell)object;
- }
- }
+ Widget widget = getWidget(window.contentView());
+ if (widget instanceof Shell) {
+ result[index++] = (Shell)widget;
}
}
if (index == result.length) return result;
@@ -1548,6 +1516,20 @@ public Thread getThread () {
}
}
+Widget getWidget (int id) {
+ if (id == 0) return null;
+ if (OS.objc_msgSend(id, OS.sel_respondsToSelector_1, OS.sel_tag) == 0) return null;
+ int jniRef = OS.objc_msgSend(id, OS.sel_tag);
+ if (jniRef == 0 || jniRef == -1) return null;
+ Widget widget = (Widget)OS.JNIGetObject(jniRef);
+ return widget;
+}
+
+Widget getWidget (NSView view) {
+ if (view == null) return null;
+ return getWidget(view.id);
+}
+
/**
* Initializes any internal resources needed by the
* device.
@@ -1585,6 +1567,21 @@ void initApplicationDelegate() {
application.setDelegate(applicationDelegate);
}
+void addEventMethods (int cls, int proc2, int proc3) {
+ OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_mouseUp_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_rightMouseDown_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_rightMouseUp_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_otherMouseDown_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_otherMouseUp_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_mouseDragged_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_mouseMoved_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_mouseEntered_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_mouseExited_1, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+}
+
void initClasses () {
dialogCallback3 = new Callback(this, "dialogProc", 3);
int dialogProc3 = dialogCallback3.getAddress();
@@ -1652,15 +1649,10 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
- OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_mouseDragged_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_mouseEntered_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_mouseUp_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
OS.class_addMethod(cls, OS.sel_resignFirstResponder, proc2, "@:");
OS.class_addMethod(cls, OS.sel_becomeFirstResponder, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTScrollView";
@@ -1670,32 +1662,27 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendHorizontalSelection, proc2, "@:");
-// OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTButton";
cls = OS.objc_allocateClassPair(OS.class_NSButton, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
-// OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendArrowSelection, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTTableView";
cls = OS.objc_allocateClassPair(OS.class_NSTableView, className, 0);
OS.class_addMethod(cls, OS.sel_sendDoubleSelection, proc2, "@:");
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_numberOfRowsInTableView_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_tableView_1objectValueForTableColumn_1row_1, proc5, "@:@:@:@");
OS.class_addMethod(cls, OS.sel_tableView_1shouldEditTableColumn_1row_1, proc5, "@:@:@:@");
OS.class_addMethod(cls, OS.sel_tableViewSelectionDidChange_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1, proc6, "@:@@@i");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_tableView_1setObjectValue_1forTableColumn_1row_1, proc6, "@:@@@i");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTOutlineView";
@@ -1710,13 +1697,11 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_outlineView_1objectValueForTableColumn_1byItem_1, proc5, "@:@@@");
OS.class_addMethod(cls, OS.sel_outlineView_1willDisplayCell_1forTableColumn_1item_1, proc6, "@:@@@@");
OS.class_addMethod(cls, OS.sel_outlineView_1setObjectValue_1forTableColumn_1byItem_1, proc6, "@:@@@@");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTTreeItem";
cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
@@ -1724,115 +1709,89 @@ void initClasses () {
className = "SWTTabView";
cls = OS.objc_allocateClassPair(OS.class_NSTabView, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
OS.class_addMethod(cls, OS.sel_tabView_1willSelectTabViewItem_1, proc4, "@:@@");
OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTBox";
cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTProgressIndicator";
cls = OS.objc_allocateClassPair(OS.class_NSProgressIndicator, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTSlider";
cls = OS.objc_allocateClassPair(OS.class_NSSlider, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTPopUpButton";
cls = OS.objc_allocateClassPair(OS.class_NSPopUpButton, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTComboBox";
cls = OS.objc_allocateClassPair(OS.class_NSComboBox, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_1, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTDatePicker";
cls = OS.objc_allocateClassPair(OS.class_NSDatePicker, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTImageView";
cls = OS.objc_allocateClassPair(OS.class_NSImageView, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_drawRect_1, OS.drawRect_CALLBACK(proc3), "@:i");
- OS.class_addMethod(cls, OS.sel_mouseDown_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_mouseUp_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_rightMouseDown_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTStepper";
cls = OS.objc_allocateClassPair(OS.class_NSStepper, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTScroller";
cls = OS.objc_allocateClassPair(OS.class_NSScroller, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTMenuItem";
cls = OS.objc_allocateClassPair(OS.class_NSMenuItem, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.objc_registerClassPair(cls);
className = "SWTTextView";
cls = OS.objc_allocateClassPair(OS.class_NSTextView, className, 0);
-// OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
// OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, (byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
OS.class_addMethod(cls, OS.sel_tag, proc2, "@:");
OS.class_addMethod(cls, OS.sel_setTag_1, proc3, "@:i");
- OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@");
- OS.class_addMethod(cls, OS.sel_textView_1clickedOnLink_1atIndex_1, proc5, "@:@@i");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTTextField";
cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0);
OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i");
- OS.class_addMethod(cls, OS.sel_resetCursorRects, proc2, "@:");
+ addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
className = "SWTWindow";
@@ -3158,9 +3117,7 @@ int windowDelegateProc(int delegate, int sel) {
OS.object_getInstanceVariable(delegate, "tag", tag);
return tag[0];
}
- int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
- if (jniRef == 0 || jniRef == -1) return 0;
- Widget widget = (Widget)OS.JNIGetObject(jniRef);
+ Widget widget = getWidget(delegate);
if (widget == null) return 0;
if (sel == OS.sel_isFlipped) {
return widget.isFlipped() ? 1 : 0;
@@ -3209,9 +3166,7 @@ int windowDelegateProc(int id, int sel, int arg0) {
OS.object_setInstanceVariable(id, "tag", arg0);
return 0;
}
- int jniRef = OS.objc_msgSend(id, OS.sel_tag);
- if (jniRef == 0 || jniRef == -1) return 0;
- Widget widget = (Widget)OS.JNIGetObject(jniRef);
+ Widget widget = getWidget(id);
if (widget == null) return 0;
if (sel == OS.sel_windowWillClose_1) {
widget.windowWillClose(arg0);
@@ -3222,15 +3177,27 @@ int windowDelegateProc(int id, int sel, int arg0) {
} else if (sel == OS.sel_windowShouldClose_1) {
return widget.windowShouldClose(arg0) ? 1 : 0;
} else if (sel == OS.sel_mouseDown_1) {
- widget.mouseDown(arg0);
+ widget.mouseDown(id, sel, arg0);
+ } else if (sel == OS.sel_mouseUp_1) {
+ widget.mouseUp(id, sel, arg0);
} else if (sel == OS.sel_rightMouseDown_1) {
- widget.rightMouseDown(arg0);
+ widget.rightMouseDown(id, sel, arg0);
+ } else if (sel == OS.sel_rightMouseUp_1) {
+ widget.rightMouseUp(id, sel, arg0);
+ } else if (sel == OS.sel_otherMouseDown_1) {
+ widget.otherMouseDown(id, sel, arg0);
+ } else if (sel == OS.sel_otherMouseUp_1) {
+ widget.otherMouseUp(id, sel, arg0);
+ } else if (sel == OS.sel_mouseMoved_1) {
+ widget.mouseMoved(id, sel, arg0);
} else if (sel == OS.sel_mouseDragged_1) {
- widget.mouseDragged(arg0);
- } else if (sel == OS.sel_mouseUp_1) {
- widget.mouseUp(arg0);
+ widget.mouseDragged(id, sel, arg0);
} else if (sel == OS.sel_mouseEntered_1) {
- widget.mouseEntered(arg0);
+ widget.mouseEntered(id, sel, arg0);
+ } else if (sel == OS.sel_mouseExited_1) {
+ widget.mouseExited(id, sel, arg0);
+ } else if (sel == OS.sel_menuForEvent_1) {
+ return widget.menuForEvent(id, sel, arg0);
} else if (sel == OS.sel_flagsChanged_1) {
widget.flagsChanged(arg0);
} else if (sel == OS.sel_numberOfRowsInTableView_1) {
@@ -3247,8 +3214,6 @@ int windowDelegateProc(int id, int sel, int arg0) {
widget.windowDidResize(arg0);
} else if (sel == OS.sel_windowDidMove_1) {
widget.windowDidMove(arg0);
- } else if (sel == OS.sel_menuForEvent_1) {
- return widget.menuForEvent(arg0);
} else if (sel == OS.sel_menuWillOpen_1) {
widget.menuWillOpen(arg0);
} else if (sel == OS.sel_menuWillClose_1) {
@@ -3265,11 +3230,8 @@ int windowDelegateProc(int id, int sel, int arg0) {
return 0;
}
-
int windowDelegateProc(int delegate, int sel, int arg0, int arg1) {
- int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
- if (jniRef == 0 || jniRef == -1) return 0;
- Widget widget = (Widget)OS.JNIGetObject(jniRef);
+ Widget widget = getWidget(delegate);
if (widget == null) return 0;
if (sel == OS.sel_tabView_1willSelectTabViewItem_1) {
widget.willSelectTabViewItem(arg0, arg1);
@@ -3288,9 +3250,7 @@ int windowDelegateProc(int delegate, int sel, int arg0, int arg1) {
}
int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2) {
- int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
- if (jniRef == 0 || jniRef == -1) return 0;
- Widget widget = (Widget)OS.JNIGetObject(jniRef);
+ Widget widget = getWidget(delegate);
if (widget == null) return 0;
if (sel == OS.sel_tableView_1objectValueForTableColumn_1row_1) {
return widget.tableView_objectValueForTableColumn_row(arg0, arg1, arg2);
@@ -3308,9 +3268,7 @@ int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2) {
}
int windowDelegateProc(int delegate, int sel, int arg0, int arg1, int arg2, int arg3) {
- int jniRef = OS.objc_msgSend(delegate, OS.sel_tag);
- if (jniRef == 0 || jniRef == -1) return 0;
- Widget widget = (Widget)OS.JNIGetObject(jniRef);
+ Widget widget = getWidget(delegate);
if (widget == null) return 0;
if (sel == OS.sel_tableView_1willDisplayCell_1forTableColumn_1row_1) {
widget.tableView_willDisplayCell_forTableColumn_row(arg0, arg1, arg2, arg3);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Group.java
index 8a537ede90..f07a289606 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Group.java
@@ -119,8 +119,7 @@ void createHandle () {
// contentWidget.setDrawsBackground(false);
widget.setContentView(contentWidget);
contentView = contentWidget;
- view = widget;
- parent.contentView().addSubview_(widget);
+ view = widget;
}
public Rectangle getClientArea () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
index deab562d46..2682f175f1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
@@ -169,7 +169,6 @@ void createHandle () {
_setAlignment();
}
view = widget;
- parent.contentView().addSubview_(widget);
}
NSAttributedString createString() {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java
index 7abec18e60..799aa0b912 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java
@@ -156,9 +156,7 @@ void createHandle () {
scrollView = scrollWidget;
view = widget;
- scrollView.addSubview_(view);
scrollView.setDocumentView(view);
- parent.contentView().addSubview_(scrollView);
}
void createWidget () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java
index c57ba3dc30..4006b6f174 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java
@@ -231,7 +231,6 @@ void createHandle () {
scrollView = scrollWidget;
view = widget;
scrollView.setDocumentView(widget);
- parent.contentView().addSubview_(scrollView);
}
void createWidget () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
index 49370aa597..47bff06484 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
@@ -645,13 +645,10 @@ public boolean isVisible () {
}
void menu_willHighlightItem(int menu, int itemID) {
- int jniRef = OS.objc_msgSend(itemID, OS.sel_tag);
- if (jniRef != -1 && jniRef != 0) {
- Object object = OS.JNIGetObject(jniRef);
- if (object instanceof MenuItem) {
- MenuItem item = (MenuItem)object;
- item.sendEvent (SWT.Arm);
- }
+ Widget widget = display.getWidget(itemID);
+ if (widget instanceof MenuItem) {
+ MenuItem item = (MenuItem)widget;
+ item.sendEvent (SWT.Arm);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java
index c5028a18fc..d930fc762c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ProgressBar.java
@@ -107,7 +107,6 @@ void createHandle () {
if ((style & SWT.INDETERMINATE) != 0) widget.startAnimation(null);
widget.setTag(jniRef);
view = widget;
- parent.contentView().addSubview_(widget);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java
index b1fc0ec098..be4f1f0a40 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Sash.java
@@ -146,7 +146,6 @@ void createHandle () {
widget.initWithFrame (new NSRect());
widget.setTag(jniRef);
view = widget;
- parent.contentView().addSubview_(view);
}
boolean sendKeyEvent(NSEvent nsEvent, int type) {
@@ -208,8 +207,8 @@ boolean sendKeyEvent(NSEvent nsEvent, int type) {
return true;
}
-void mouseDown(int theEvent) {
- super.mouseDown(theEvent);
+void mouseDown(int id, int sel, int theEvent) {
+ super.mouseDown(id, sel, theEvent);
NSEvent nsEvent = new NSEvent(theEvent);
if (nsEvent.clickCount() != 1) return;
NSPoint location = nsEvent.locationInWindow();
@@ -232,8 +231,8 @@ void mouseDown(int theEvent) {
}
}
-void mouseDragged(int theEvent) {
- super.mouseDragged(theEvent);
+void mouseDragged(int id, int sel, int theEvent) {
+ super.mouseDragged(id, sel, theEvent);
if (!dragging) return;
NSEvent nsEvent = new NSEvent(theEvent);
NSPoint location = nsEvent.locationInWindow();
@@ -261,14 +260,8 @@ void mouseDragged(int theEvent) {
}
}
-void mouseEntered(int theEvent) {
- //TODO need to add tracking area
- super.mouseEntered(theEvent);
- sizeCursor.handle.set();
-}
-
-void mouseUp(int theEvent) {
- super.mouseUp(theEvent);
+void mouseUp(int id, int sel, int theEvent) {
+ super.mouseUp(id, sel, theEvent);
if (!dragging) return;
dragging = false;
NSRect frame = view.frame();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scale.java
index 75d8f63401..b6f77b5dee 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Scale.java
@@ -143,7 +143,6 @@ void createHandle () {
widget.setMaxValue(100);
widget.setTag(jniRef);
view = widget;
- parent.contentView().addSubview_(widget);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
index b9739d7bdd..2a8a4962f1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
@@ -492,7 +492,7 @@ void createHandle () {
}
}
- createHandle (null);
+ super.createHandle ();
window.setContentView (topView());
windowDelegate = (SWTWindowDelegate)new SWTWindowDelegate().alloc().init();
@@ -1331,7 +1331,6 @@ void setWindowVisible (boolean visible, boolean key) {
}
void setZOrder () {
-// if (scrolledHandle != 0) OS.HIViewAddSubview (scrolledHandle, handle);
}
void setZOrder (Control control, boolean above) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Slider.java
index 505d6283cf..80e4e7514c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Slider.java
@@ -180,7 +180,6 @@ void createHandle () {
widget.setAction(OS.sel_sendSelection);
widget.setTag(jniRef);
view = widget;
- parent.contentView().addSubview_(widget);
updateBar(0, minimum, maximum, thumb);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java
index 995487adad..4b1fb91bae 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java
@@ -260,8 +260,7 @@ void createHandle () {
widget.addSubview_(buttonWidget);
buttonView = buttonWidget;
textView = textWidget;
- view = widget;
- parent.contentView().addSubview_(widget);
+ view = widget;
setSelection (0, false, true, false);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java
index 9d54a3d20a..1860dff492 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TabFolder.java
@@ -179,7 +179,6 @@ void createHandle () {
widget.setTabViewType(OS.NSBottomTabsBezelBorder);
}
view = widget;
- parent.contentView().addSubview_(view);
}
void createItem (TabItem item, int index) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
index 7186f631b6..571b6917e4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
@@ -417,7 +417,6 @@ void createHandle () {
scrollView = scrollWidget;
view = widget;
scrollView.setDocumentView(widget);
- parent.contentView().addSubview_(scrollView);
}
void createItem (TableColumn column, int index) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java
index 176a1b2686..e5e67be557 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java
@@ -356,7 +356,6 @@ void createHandle () {
// widget.setAction(OS.sel_sendSelection);
widget.setTag(jniRef);
view = widget;
- parent.contentView().addSubview_(widget);
} else {
SWTScrollView scrollWidget = (SWTScrollView)new SWTScrollView().alloc();
scrollWidget.initWithFrame(new NSRect());
@@ -396,7 +395,6 @@ void createHandle () {
view = widget;
scrollView = scrollWidget;
scrollView.setDocumentView(widget);
- parent.contentView().addSubview_(scrollView);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
index 4ebc9f5448..7ad737908e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
@@ -131,7 +131,6 @@ void createHandle () {
// widget.setDrawsBackground(false);
widget.setTag(jniRef);
view = widget;
- parent.contentView().addSubview_(widget);
}
void createItem (ToolItem item, int index) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java
index 216e69eaff..7fb731659b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TrayItem.java
@@ -413,7 +413,8 @@ void showMenu () {
_setToolTipText (toolTipText);
}
-void mouseDown(int event) {
+void mouseDown(int id, int sel, int event) {
+ super.mouseDown(id, sel, event);
NSEvent nsEvent = new NSEvent(event);
int mask = nsEvent.modifierFlags() & OS.NSDeviceIndependentModifierFlagsMask;
if (mask == OS.NSControlKeyMask) {
@@ -426,12 +427,14 @@ void mouseDown(int event) {
}
}
-void mouseUp(int event) {
+void mouseUp(int id, int sel, int theEvent) {
+ super.mouseUp(id, sel, theEvent);
highlight = false;
view.setNeedsDisplay(true);
}
-void rightMouseDown(int event) {
+void rightMouseDown(int id, int sel, int theEvent) {
+ super.rightMouseDown(id, sel, theEvent);
showMenu();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
index d85a071b82..338e0ca4eb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
@@ -425,7 +425,6 @@ void createHandle () {
scrollView = scrollWidget;
view = widget;
scrollView.setDocumentView(widget);
- parent.contentView().addSubview_(scrollView);
}
void createItem (TreeColumn column, int index) {
@@ -1208,13 +1207,13 @@ public TreeItem [] getSelection () {
int count = selection.count();
int [] indexBuffer = new int [count];
selection.getIndexes(indexBuffer, count, 0);
- TreeItem [] result = new TreeItem [count];
+ TreeItem [] result = new TreeItem [count];
for (int i=0; i<count; i++) {
- id item = widget.itemAtRow(indexBuffer [i]);
- int jniRef = OS.objc_msgSend(item.id, OS.sel_tag);
- if (jniRef != -1 && jniRef != 0) {
+ id id = widget.itemAtRow(indexBuffer [i]);
+ Widget item = display.getWidget(id.id);
+ if (item != null && item instanceof TreeItem) {
//TODO virtual
- result[i] = (TreeItem)OS.JNIGetObject(jniRef);
+ result[i] = (TreeItem)item;
}
}
return result;
@@ -1369,14 +1368,13 @@ public int indexOf (TreeItem item) {
}
int outlineView_child_ofItem(int outlineView, int index, int ref) {
- TreeItem parent = null;
- if (ref != 0) parent = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+ TreeItem parent = (TreeItem)display.getWidget(ref);
TreeItem item = _getItem(parent, index);
return item.handle.id;
}
int outlineView_objectValueForTableColumn_byItem(int outlineView, int tableColumn, int ref) {
- TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+ TreeItem item = (TreeItem)display.getWidget(ref);
if (checkColumn != null && tableColumn == checkColumn.id) {
NSNumber value;
if (item.checked && item.grayed) {
@@ -1396,17 +1394,17 @@ int outlineView_objectValueForTableColumn_byItem(int outlineView, int tableColum
boolean outlineView_isItemExpandable(int outlineView, int ref) {
if (ref == 0) return true;
- return ((TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag))).itemCount != 0;
+ return ((TreeItem)display.getWidget(ref)).itemCount != 0;
}
int outlineView_numberOfChildrenOfItem(int outlineView, int ref) {
if (ref == 0) return itemCount;
- return ((TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag))).itemCount;
+ return ((TreeItem)display.getWidget(ref)).itemCount;
}
void outlineView_willDisplayCell_forTableColumn_item(int outlineView, int cell, int tableColumn, int ref) {
if (checkColumn != null && tableColumn == checkColumn.id) return;
- TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+ TreeItem item = (TreeItem)display.getWidget(ref);
Image image = item.image;
for (int i=0; i<columnCount; i++) {
if (columns [i].nsColumn.id == tableColumn) {
@@ -1425,7 +1423,7 @@ void outlineViewSelectionDidChange(int notification) {
postEvent(SWT.Selection);
else {
id _id = widget.itemAtRow(row);
- TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(_id.id, OS.sel_tag));
+ TreeItem item = (TreeItem)display.getWidget(_id.id);
Event event = new Event();
event.item = item;
event.index = row;
@@ -1435,7 +1433,7 @@ void outlineViewSelectionDidChange(int notification) {
boolean outlineView_shouldCollapseItem(int outlineView, int ref) {
if (!ignoreExpand) {
- TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+ TreeItem item = (TreeItem)display.getWidget(ref);
Event event = new Event();
event.item = item;
sendEvent(SWT.Collapse, event);
@@ -1446,7 +1444,7 @@ boolean outlineView_shouldCollapseItem(int outlineView, int ref) {
boolean outlineView_shouldExpandItem(int outlineView, int ref) {
if (!ignoreExpand) {
- TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+ TreeItem item = (TreeItem)display.getWidget(ref);
Event event = new Event();
event.item = item;
sendEvent(SWT.Expand, event);
@@ -1456,7 +1454,7 @@ boolean outlineView_shouldExpandItem(int outlineView, int ref) {
}
void outlineView_setObjectValue_forTableColumn_byItem(int outlineView, int object, int tableColumn, int ref) {
- TreeItem item = (TreeItem)OS.JNIGetObject(OS.objc_msgSend(ref, OS.sel_tag));
+ TreeItem item = (TreeItem)display.getWidget(ref);
if (checkColumn != null && tableColumn == checkColumn.id) {
item.checked = !item.checked;
Event event = new Event();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
index 0113b486d8..981741e14e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
@@ -613,22 +613,47 @@ boolean isValidThread () {
void flagsChanged(int event) {
}
-void mouseDragged(int event) {
+void mouseDown(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
}
-void mouseDown(int event) {
+void mouseUp(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
}
-void rightMouseDown(int event) {
+void rightMouseDown(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
}
-void mouseEntered(int event) {
+void rightMouseUp(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
}
-void mouseUp(int event) {
+void otherMouseDown(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
}
-int menuForEvent (int event) {
+void otherMouseUp(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
+}
+
+void mouseMoved(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
+}
+
+void mouseDragged(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
+}
+
+void mouseEntered(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
+}
+
+void mouseExited(int id, int sel, int theEvent) {
+ callSuper(id, sel, theEvent);
+}
+
+int menuForEvent (int id, int sel, int event) {
return 0;
}