Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2016-01-11 11:57:50 +0000
committerLakshmi Shanmugam2016-01-11 12:08:49 +0000
commit1948ed27f9c8f4567ab80c7410c11eec0faa5340 (patch)
treec25f31ff062974c15da1ad44fc42d025d1a29829 /bundles
parent02e6c28048a67e05d4e38f127fe127764eb15958 (diff)
downloadeclipse.platform.swt-1948ed27f9c8f4567ab80c7410c11eec0faa5340.tar.gz
eclipse.platform.swt-1948ed27f9c8f4567ab80c7410c11eec0faa5340.tar.xz
eclipse.platform.swt-1948ed27f9c8f4567ab80c7410c11eec0faa5340.zip
Bug 481611 - Table/tree column header events have incorrect coordinates
in OS X 10.11 El Capitan In OSX 10.11, the origin of the tree is the header, not the top-left of the rows. Adjust the co-ordinates accordingly. Fixed getClientArea, getTopItem, setTopItem, setTopIndex & getTopIndex() for 10.11. The behavior on older OSX versions remains unchanged.
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java43
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java43
2 files changed, 72 insertions, 14 deletions
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 615e899141..756162a876 100644
--- 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
@@ -1291,13 +1291,21 @@ int getCheckColumnWidth () {
public Rectangle getClientArea () {
checkWidget ();
Rectangle rect = super.getClientArea ();
- NSTableHeaderView headerView = ((NSTableView) view).headerView ();
- if (headerView != null) {
- // The origin of the table is the top-left of the rows of the table,
- // not the header. Adjust the y value accordingly.
- int height = (int) headerView.bounds ().height;
- rect.y -= height;
- rect.height += height;
+ /*
+ * OSX version < 10.11 - The origin of the table is the top-left of the rows
+ * of the table, not the header. We adjust the y value and height of the rect
+ * accordingly, to include the header.
+ *
+ * OSX 10.11 - The origin of the table is the header and the header's
+ * height is already included in the rect. Hence, we return the rect as is.
+ */
+ if (OS.VERSION_MMB < OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ rect.y -= height;
+ rect.height += height;
+ }
}
return rect;
}
@@ -1798,6 +1806,17 @@ public int getTopIndex () {
point.x = rect.x;
point.y = rect.y;
+ /*
+ * In OSX 10.11, the origin of the table is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ point.y += height;
+ }
+ }
int /*64*/ rowAtPoint = (int)/*64*/((NSTableView)view).rowAtPoint(point);
if (rowAtPoint == -1) return 0; /* Empty table */
return rowAtPoint;
@@ -2999,6 +3018,16 @@ public void setTopIndex (int index) {
NSPoint pt = new NSPoint();
pt.x = scrollView.contentView().bounds().x;
pt.y = widget.frameOfCellAtColumn(0, row).y;
+ /*
+ * In OSX 10.11, the origin of the table is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) {
+ if (widget.headerView() != null) {
+ NSRect headerRect = headerView.frame();
+ pt.y -= headerRect.y + headerRect.height;
+ }
+ }
view.scrollPoint(pt);
}
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 2a17111d33..672e6ac6d7 100644
--- 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
@@ -1364,13 +1364,21 @@ int getCheckColumnWidth () {
public Rectangle getClientArea () {
checkWidget ();
Rectangle rect = super.getClientArea ();
- NSTableHeaderView headerView = ((NSTableView) view).headerView ();
- if (headerView != null) {
- // The origin of the tree is the top-left of the rows of the tree,
- // not the header. Adjust the y value accordingly.
- int height = (int) headerView.bounds ().height;
- rect.y -= height;
- rect.height += height;
+ /*
+ * OSX version < 10.11 - The origin of the tree is the top-left of the rows
+ * of the table, not the header. We adjust the y value and height of the rect
+ * accordingly, to include the header.
+ *
+ * OSX 10.11 & above - The origin of the tree is the header and the header's
+ * height is already included in the rect. Hence, we return the rect as is.
+ */
+ if (OS.VERSION_MMB < OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ rect.y -= height;
+ rect.height += height;
+ }
}
return rect;
}
@@ -1864,6 +1872,17 @@ public TreeItem getTopItem () {
NSPoint point = new NSPoint ();
point.x = rect.x;
point.y = rect.y;
+ /*
+ * In OSX 10.11, the origin of the tree is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB (10, 11, 0)) {
+ NSTableHeaderView headerView = ((NSTableView) view).headerView ();
+ if (headerView != null) {
+ int height = (int) headerView.bounds ().height;
+ point.y += height;
+ }
+ }
NSOutlineView outlineView = (NSOutlineView)view;
long /*int*/ index = outlineView.rowAtPoint (point);
if (index == -1) return null; /* empty */
@@ -3225,6 +3244,16 @@ public void setTopItem (TreeItem item) {
NSPoint pt = new NSPoint();
pt.x = scrollView.contentView().bounds().x;
pt.y = widget.frameOfCellAtColumn(0, row).y;
+ /*
+ * In OSX 10.11, the origin of the tree is the header, not the top-left of the rows.
+ * Offset the point's y coordinate accordingly.
+ */
+ if (OS.VERSION_MMB >= OS.VERSION_MMB(10, 11, 0)) {
+ if (widget.headerView() != null) {
+ NSRect headerRect = headerView.frame();
+ pt.y -= headerRect.y + headerRect.height;
+ }
+ }
view.scrollPoint(pt);
}

Back to the top