Bug 516873: Tree & Table border not drawn correctly when header
background is set
	
Draws top border line when SWT.BORDER style is set. Draws separator line
between header and first row. 

Change-Id: I875be1e10ff6b7f18a626302ef18136be677bf01
Signed-off-by: Lakshmi Shanmugam <lshanmug@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java
index f5a54fe..985a340 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableColumn.java
@@ -214,6 +214,7 @@
 	 */
 	int columnIndex = parent.indexOf (nsColumn);
 	NSRect headerRect = parent.headerView.headerRectOfColumn (columnIndex);
+	double borderWidth = parent.hasBorder() ? 0.5 : 0;
 	if (headerRect.x != cellRect.x || headerRect.width != cellRect.width) {
 		if (parent.headerBackground != null) {
 			NSGraphicsContext context = NSGraphicsContext.currentContext ();
@@ -225,12 +226,14 @@
 			 * Before this method is invoked, the header cell's border is already drawn with the system
 			 * default color. Use headerRect's height & y values so that we can draw over
 			 * the header cell's borders with the header background color.
+			 * Don't draw over the top border when the border style is set. Also, adjust rect height
+			 * so that separator line between header & first row is drawn.
 			 */
 			NSRect rect = new NSRect();
 			rect.x = cellRect.x;
-			rect.y = headerRect.y;
+			rect.y = headerRect.y + borderWidth;
 			rect.width = cellRect.width;
-			rect.height = headerRect.height;
+			rect.height = headerRect.height - borderWidth - 0.5; /* 0.5 -> header-row separator width */
 			NSBezierPath.fillRect(rect);
 			context.restoreGraphicsState();
 		}
@@ -262,8 +265,15 @@
 		 * Before this method is invoked, the header cell's border is already drawn
 		 * with the system default color. Use headerRect instead of cellRect so that we
 		 * can draw over the header cell's borders with the header background color.
+		 * Don't draw over the top border when the border style is set. Also, adjust rect
+		 * height so that separator line between header & first row is drawn.
 		 */
-		NSBezierPath.fillRect(headerRect);
+		NSRect rect = new NSRect();
+		rect.x = headerRect.x;
+		rect.y = headerRect.y + borderWidth;
+		rect.width = headerRect.width;
+		rect.height = headerRect.height - borderWidth - 0.5; /* 0.5 -> header-row separator width */
+		NSBezierPath.fillRect(rect);
 
 		// draw header column separator
 		if (parent.headerForeground != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java
index d464536..20bcb64 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeColumn.java
@@ -216,6 +216,7 @@
 	 */
 	int columnIndex = parent.indexOf (nsColumn);
 	NSRect headerRect = parent.headerView.headerRectOfColumn (columnIndex);
+	double borderWidth = parent.hasBorder() ? 0.5 : 0;
 	if (headerRect.x != cellRect.x || headerRect.width != cellRect.width) {
 		if (parent.headerBackground != null) {
 			NSGraphicsContext context = NSGraphicsContext.currentContext ();
@@ -227,12 +228,14 @@
 			 * Before this method is invoked, the header cell's border is already drawn
 			 * with the system default color. Use headerRect's height & y values so that we
 			 * can draw over the header cell's borders with the header background color.
+			 * Don't draw over the top border when the border style is set. Also, adjust rect
+			 * height so that separator line between header & first row is drawn.
 			 */
 			NSRect rect = new NSRect();
 			rect.x = cellRect.x;
-			rect.y = headerRect.y;
+			rect.y = headerRect.y + borderWidth;
 			rect.width = cellRect.width;
-			rect.height = headerRect.height;
+			rect.height = headerRect.height - borderWidth - 0.5; /* 0.5 -> header-row separator width */
 			NSBezierPath.fillRect(rect);
 			context.restoreGraphicsState();
 		}
@@ -264,8 +267,15 @@
 		 * Before this method is invoked, the header cell's border is already drawn
 		 * with the system default color. Use headerRect instead of cellRect so that we
 		 * can draw over the header cell's borders with the header background color.
+		 * Don't draw over the top border when the border style is set. Also, adjust rect
+		 * height so that separator line between header & first row is drawn.
 		 */
-		NSBezierPath.fillRect(headerRect);
+		NSRect rect = new NSRect();
+		rect.x = headerRect.x;
+		rect.y = headerRect.y + borderWidth;
+		rect.width = headerRect.width;
+		rect.height = headerRect.height - borderWidth - 0.5; /* 0.5 -> header-row separator width */
+		NSBezierPath.fillRect(rect);
 
 		// draw column separator
 		if (parent.headerForeground != null) {