summaryrefslogtreecommitdiffstats
path: root/bundles
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2009-03-27 15:11:30 +0000
committerSilenio Quarti <silenio>2009-03-27 15:11:30 +0000
commitc564313ed6e2e9d0951805f760e9b7b48bcbb307 (patch)
treed1eba1ceb00c9c7612f9f0f6b376b1adf90b7b27 /bundles
parenta824acfb525cc9dac45bc30e079ed4f19fa2b182 (diff)
downloadeclipse.platform.swt-c564313ed6e2e9d0951805f760e9b7b48bcbb307.tar.gz
eclipse.platform.swt-c564313ed6e2e9d0951805f760e9b7b48bcbb307.tar.xz
eclipse.platform.swt-c564313ed6e2e9d0951805f760e9b7b48bcbb307.zip
270177 - SWT - DateTime component is broken on MAC cocoa 64 bits.
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java7
5 files changed, 61 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
index 3e26b289a1..1a398d984a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
@@ -236,10 +236,15 @@ NSAutoreleasePool checkGC (int mask) {
handle.restoreGraphicsState();
handle.saveGraphicsState();
handle.setShouldAntialias(antialias);
- if (view != null && data.paintRect == null) {
+ boolean flipped = false;
+ if (view != null && (data.paintRect == null || !(flipped = view.isFlipped()))) {
NSAffineTransform transform = NSAffineTransform.transform();
NSRect rect = view.convertRect_toView_(view.bounds(), null);
- transform.translateXBy(rect.x, rect.y + rect.height);
+ if (flipped) {
+ transform.translateXBy(rect.x, rect.y + rect.height);
+ } else {
+ transform.translateXBy(0, rect.height);
+ }
transform.scaleXBy(1, -1);
transform.concat();
if (data.visibleRgn != 0) {
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 5f9c93f541..97e414c524 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
@@ -1042,6 +1042,9 @@ boolean dragDetect (int x, int y, boolean filter, boolean [] consume) {
dragEvents.addObject(event);
NSPoint windowLoc = event.locationInWindow();
NSPoint viewLoc = view.convertPoint_fromView_(windowLoc, null);
+ if (!view.isFlipped ()) {
+ viewLoc.y = view.bounds().height - viewLoc.y;
+ }
if ((Math.abs(viewLoc.x - dragX) > DEFAULT_DRAG_HYSTERESIS) || (Math.abs(viewLoc.y - dragY) > DEFAULT_DRAG_HYSTERESIS)) {
dragging = true;
break;
@@ -1712,6 +1715,9 @@ int /*long*/ hitTest (int /*long*/ id, int /*long*/ sel, NSPoint point) {
NSView superview = new NSView(id).superview();
if (superview != null) {
NSPoint pt = superview.convertPoint_toView_(point, view);
+ if (!view.isFlipped ()) {
+ pt.y = view.bounds().height - pt.y;
+ }
if (!regionPath.containsPoint(pt)) return 0;
}
}
@@ -1765,7 +1771,9 @@ public int /*long*/ internal_new_GC (GCData data) {
NSView view = paintView();
int /*long*/ context = 0;
if (data != null && data.paintRect != null) {
- context = NSGraphicsContext.currentContext().id;
+ NSGraphicsContext graphicsContext = NSGraphicsContext.currentContext();
+ context = graphicsContext.id;
+ if (!view.isFlipped()) data.state &= ~VISIBLE_REGION;
} else {
NSGraphicsContext graphicsContext = NSGraphicsContext.graphicsContextWithWindow (view.window ());
NSGraphicsContext flippedContext = NSGraphicsContext.graphicsContextWithGraphicsPort(graphicsContext.graphicsPort(), true);
@@ -2099,6 +2107,9 @@ boolean mouseEvent (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent, in
if (nsEvent.clickCount() == 1 && (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) {
consume = new boolean[1];
NSPoint location = view.convertPoint_fromView_(nsEvent.locationInWindow(), null);
+ if (!view.isFlipped ()) {
+ location.y = view.bounds().height - location.y;
+ }
dragging = dragDetect((int)location.x, (int)location.y, false, consume);
}
break;
@@ -2887,6 +2898,9 @@ boolean sendMouseEvent (NSEvent nsEvent, int type, boolean send) {
windowPoint = nsEvent.locationInWindow();
}
NSPoint point = view.convertPoint_fromView_(windowPoint, null);
+ if (!view.isFlipped ()) {
+ point.y = view.bounds().height - point.y;
+ }
event.x = (int) point.x;
event.y = (int) point.y;
setInputState (event, nsEvent, type);
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 d1dd5eae50..76a8257c76 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
@@ -297,6 +297,11 @@ boolean isEventView (int /*long*/ id) {
return true;
}
+boolean isFlipped (int /*long*/ id, int /*long*/ sel) {
+ if ((style & SWT.CALENDAR) != 0) return super.isFlipped (id, sel);
+ return true;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected by the user.
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 9fa4f423e9..5ceae49095 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
@@ -2162,7 +2162,7 @@ void initClasses () {
className = "SWTDatePicker";
cls = OS.objc_allocateClassPair(OS.class_NSDatePicker, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
- OS.class_addMethod(cls, OS.sel_isFlipped, isFlippedProc, "@:");
+ OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
@@ -2690,11 +2690,20 @@ public Point map (Control from, Control to, int x, int y) {
NSWindow fromWindow = from != null ? from.view.window() : null;
NSWindow toWindow = to != null ? to.view.window() : null;
if (toWindow != null && fromWindow != null && toWindow.id == fromWindow.id) {
+ if (!from.view.isFlipped ()) {
+ pt.y = from.view.bounds().height - pt.y;
+ }
pt = from.view.convertPoint_toView_(pt, to.view);
+ if (!to.view.isFlipped ()) {
+ pt.y = to.view.bounds().height - pt.y;
+ }
} else {
NSRect primaryFrame = getPrimaryFrame();
if (from != null) {
NSView view = from.eventView ();
+ if (!view.isFlipped ()) {
+ pt.y = view.bounds().height - pt.y;
+ }
pt = view.convertPoint_toView_(pt, null);
pt = fromWindow.convertBaseToScreen(pt);
pt.y = primaryFrame.height - pt.y;
@@ -2704,6 +2713,9 @@ public Point map (Control from, Control to, int x, int y) {
pt.y = primaryFrame.height - pt.y;
pt = toWindow.convertScreenToBase(pt);
pt = view.convertPoint_fromView_(pt, null);
+ if (!view.isFlipped ()) {
+ pt.y = view.bounds().height - pt.y;
+ }
}
}
point.x = (int)pt.x;
@@ -2803,11 +2815,20 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei
NSWindow fromWindow = from != null ? from.view.window() : null;
NSWindow toWindow = to != null ? to.view.window() : null;
if (toWindow != null && fromWindow != null && toWindow.id == fromWindow.id) {
+ if (!from.view.isFlipped ()) {
+ pt.y = from.view.bounds().height - pt.y;
+ }
pt = from.view.convertPoint_toView_(pt, to.view);
+ if (!to.view.isFlipped ()) {
+ pt.y = to.view.bounds().height - pt.y;
+ }
} else {
NSRect primaryFrame = getPrimaryFrame();
if (from != null) {
NSView view = from.eventView ();
+ if (!view.isFlipped ()) {
+ pt.y = view.bounds().height - pt.y;
+ }
pt = view.convertPoint_toView_(pt, null);
pt = fromWindow.convertBaseToScreen(pt);
pt.y = primaryFrame.height - pt.y;
@@ -2817,6 +2838,9 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei
pt.y = primaryFrame.height - pt.y;
pt = toWindow.convertScreenToBase(pt);
pt = view.convertPoint_fromView_(pt, null);
+ if (!view.isFlipped ()) {
+ pt.y = view.bounds().height - pt.y;
+ }
}
}
rectangle.x = (int)pt.x;
@@ -4227,6 +4251,8 @@ static int /*long*/ windowDelegateProc(int /*long*/ id, int /*long*/ sel) {
return widget.resignFirstResponder(id, sel) ? 1 : 0;
} else if (sel == OS.sel_isOpaque) {
return widget.isOpaque(id, sel) ? 1 : 0;
+ } else if (sel == OS.sel_isFlipped) {
+ return widget.isFlipped(id, sel) ? 1 : 0;
} else if (sel == OS.sel_unmarkText) {
//TODO not called?
} else if (sel == OS.sel_validAttributesForMarkedText) {
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 6c8f674ac5..06a933f1a0 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
@@ -817,6 +817,13 @@ boolean isDrawing () {
return true;
}
+boolean isFlipped(int /*long*/ id, int /*long*/ sel) {
+ objc_super super_struct = new objc_super();
+ super_struct.receiver = id;
+ super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
+ return OS.objc_msgSendSuper(super_struct, sel) != 0;
+}
+
/**
* Returns <code>true</code> if there are any listeners
* for the specified event type associated with the receiver,