0

I would like to change tooltip for close button from "close" to "delete" and to replace an "x" with another image. I found the corresponding places in the code of SWT.

Class CTabFolder:

String _getToolTip(int x, int y) {
    // ...
    if ((showClose || item.getShowClose()) && item.closeRect.contains(x, y)) {
        return SWT.getMessage("SWT_Close"); //$NON-NLS-1$
}

Class CTabFolderRenderer:

void drawClose(GC gc, Rectangle closeRect, int closeImageState) {
    // ...
}

To my sorrow I noticed neither of both methods can be overridden. So is there really no chance to fulfill my requirement? And this although CTabFolderRenderer is even intended to be subclassed. User Niranjan asked a similar question and he apparently managed to solve one of my problems. But how?

Community
  • 1
  • 1
Danny Lo
  • 1,553
  • 4
  • 26
  • 48
  • You could do something similar to [this](http://stackoverflow.com/questions/11844119/how-to-add-close-button-with-swt-tabitem). In that case you'd have the icon on the left though. – Baz Sep 25 '14 at 14:57

1 Answers1

0

You can set a new renderer to be used instead of CTabFolderRenderer by calling CTabFolder.setRenderer.

Your new renderer can extend CTabFolderRenderer but as you can't override drawClose you would have to override draw and duplicate a lot of code.

Eclipse itself uses a tab renderer org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering to change some of the drawing (but not the close button).

So this is a lot more work that it might have been with a better base render class.

greg-449
  • 109,219
  • 232
  • 102
  • 145