Skip to content

Commit

Permalink
Fixes : #662
Browse files Browse the repository at this point in the history
The default intercell spacing value that is obtained from Cocoa for
width is 17. So providing a HCELL_GAP value of 17 for width and
retaining the same value of 1 for height. VCELL_GAP is 1.
  • Loading branch information
elsazac committed Oct 30, 2023
1 parent 17dcab0 commit ace305a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public class Table extends Composite {
static final int FIRST_COLUMN_MINIMUM_WIDTH = 5;
static final int IMAGE_GAP = 3;
static final int TEXT_GAP = 2;
static final int CELL_GAP = 1;
/*Default Horizontal inter-cell spacing value obtained from Cocoa is 17*/
static final int HCELL_GAP = 17;
static final int VCELL_GAP =1;

/**
* Constructs a new instance of this class given its parent
Expand Down Expand Up @@ -473,7 +475,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
} else {
GC gc = new GC (this);
width += calculateWidth (items, 0, gc) + CELL_GAP;
width += calculateWidth (items, 0, gc) + HCELL_GAP;
gc.dispose ();
}
if ((style & SWT.CHECK) != 0) width += getCheckColumnWidth ();
Expand Down Expand Up @@ -549,7 +551,8 @@ void createHandle () {
widget.setDelegate(widget);
widget.setColumnAutoresizingStyle (OS.NSTableViewNoColumnAutoresizing);
NSSize spacing = new NSSize();
spacing.width = spacing.height = CELL_GAP;
spacing.width= HCELL_GAP;
spacing.height = VCELL_GAP;
widget.setIntercellSpacing(spacing);
widget.setDoubleAction(OS.sel_sendDoubleSelection);

Expand Down Expand Up @@ -1661,7 +1664,7 @@ public int getItemCount () {
*/
public int getItemHeight () {
checkWidget ();
return (int)((NSTableView)view).rowHeight() + CELL_GAP;
return (int)((NSTableView)view).rowHeight() + VCELL_GAP;
}

/**
Expand Down Expand Up @@ -1911,8 +1914,8 @@ NSRect headerRectOfColumn (long id, long sel, long column) {
if (column == 1) {
NSRect returnValue = callSuperRect(id, sel, column);
// Save a call to [NSTableView intercellSpacing] by using our constant.
returnValue.width += (checkColumn.width() + CELL_GAP);
returnValue.x -= (checkColumn.width() + CELL_GAP);
returnValue.width += (checkColumn.width() + HCELL_GAP);
returnValue.x -= (checkColumn.width() + HCELL_GAP);
return returnValue;
}
return callSuperRect(id, sel, column);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public int getWidth () {
checkWidget ();
int width = (int)nsColumn.width();
// TODO how to differentiate 0 and 1 cases?
if (width > 0) width += Table.CELL_GAP;
if (width > 0) width += Table.HCELL_GAP;
return width;
}

Expand Down Expand Up @@ -774,7 +774,7 @@ public void setWidth (int width) {
checkWidget ();
if (width < 0) return;
// TODO how to differentiate 0 and 1 cases?
width = Math.max (0, width - Table.CELL_GAP);
width = Math.max (0, width - Table.HCELL_GAP);
nsColumn.setWidth (width);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ int calculateWidth (int index, GC gc, boolean rowSelected) {
width = event.width;
}
if (index == 0) this.width = width;
return width;
return width+Table.HCELL_GAP;
}

@Override
Expand Down

0 comments on commit ace305a

Please sign in to comment.