Skip to content

Commit

Permalink
Add javadoc (including @SInCE tag) to new API methods
Browse files Browse the repository at this point in the history
  • Loading branch information
schneidermic0 committed Dec 18, 2024
1 parent 98ff3d3 commit 72a32a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -881,31 +881,29 @@ void drawClose(GC gc, Rectangle closeRect, int closeImageState, boolean showDirt
if (closeRect.width == 0 || closeRect.height == 0) return;

int originalLineWidth = gc.getLineWidth();
Color originalForeground = gc.getForeground();
int state = closeImageState & (SWT.HOT | SWT.SELECTED | SWT.BACKGROUND);
if (state == SWT.NONE) {
if (showDirtyIndicator)
drawDirtyIndicator(gc, closeRect, originalForeground, false);
drawDirtyIndicator(gc, closeRect, false);
else
drawCloseButton(gc, closeRect, false);
} else if (state == SWT.HOT || state == SWT.SELECTED) {
drawCloseButton(gc, closeRect, true);
} else if (state == SWT.BACKGROUND) {
if (showDirtyIndicator)
drawDirtyIndicator(gc, closeRect, originalForeground, false);
drawDirtyIndicator(gc, closeRect, false);
else
drawBackground(gc, closeRect, SWT.BACKGROUND);

}
gc.setLineWidth(originalLineWidth);
gc.setForeground(originalForeground);
}

private void drawDirtyIndicator(GC gc, Rectangle closeRect, Color originalForeground, boolean hot) {
Color originalBackground = gc.getBackground();
gc.setBackground(originalForeground);
gc.fillOval(closeRect.x + 3, closeRect.y + 4, closeRect.width - 6, closeRect.height - 6);
gc.setBackground(originalBackground);
private void drawDirtyIndicator(GC gc, Rectangle closeRect, boolean hot) {
String DIRTY_INDICATOR = "●";
Point stringExtent = gc.stringExtent(DIRTY_INDICATOR);
int x = closeRect.x + (closeRect.width - stringExtent.x) / 2;
int y = closeRect.y + (closeRect.height - stringExtent.y) / 2;
gc.drawString(DIRTY_INDICATOR, x, y, true);
}

private void drawCloseBackground(GC gc, Rectangle closeRect, Color backgroundColor) {
Expand Down Expand Up @@ -1477,7 +1475,7 @@ void drawSelected(int itemIndex, GC gc, Rectangle bounds, int state ) {
gc.setBackground(orginalBackground);
}
}
if (shouldDrawCloseIcon(item)) drawClose(gc, item.closeRect, item.closeImageState, item.showDirty);
if (shouldDrawCloseIcon(item)) drawClose(gc, item.closeRect, item.closeImageState, item.showDirty);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ public boolean getShowClose() {
}

/**
* TODO
* @return
* Returns <code>true</code> to indicate that the dirty indicator should be shown.
* Otherwise return <code>false</code>.
*
* @return <code>true</code> if the dirty indicatorn should be shown
*
* @since 4.35
*/
Expand Down Expand Up @@ -506,9 +507,9 @@ public void setShowClose(boolean close) {
}

/**
* TODO
* Sets to <code>true</code> to indicate that the dirty indicator should be shown.
*
* @param dirty
* @param dirty the new value whether the dirty indicator shall be shown
*
* @since 4.35
*/
Expand Down

0 comments on commit 72a32a9

Please sign in to comment.