eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

On TabFolder, Foreground and Background colors are not getting applied inspite of setting.

Open deepika-u opened this issue 1 year ago • 4 comments

On TabFolder, when trying to change Foreground and Background colors, they are not getting applied.

To Reproduce I am able to see the same problem via the below snippet, via ControlExample or via SWT Controls.

Snippet to reproduce the behavior

package org.eclipse.swt.snippets;

/*
 * TabFolder example snippet: create a tab folder (six pages)
 *
 * For a list of all SWT example snippets see
 * http://www.eclipse.org/swt/snippets/
 */
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class Snippet76 {

public static void main (String [] args) {
	Display display = new Display ();
	final Shell shell = new Shell (display);
	shell.setText("Snippet 76");
	final TabFolder tabFolder = new TabFolder (shell, SWT.BORDER);
	Rectangle clientArea = shell.getClientArea ();
	tabFolder.setLocation (clientArea.x, clientArea.y);
	tabFolder.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
	tabFolder.setForeground(display.getSystemColor(SWT.COLOR_RED));
	for (int i=0; i<6; i++) {
		TabItem item = new TabItem (tabFolder, SWT.NONE);
		item.setText ("TabItem " + i);
		Button button = new Button (tabFolder, SWT.PUSH);
		button.setText ("Page " + i);
		item.setControl (button);
	}
	//tabFolder.setSelection(4);
	tabFolder.pack ();
	shell.pack ();
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
}

Expected behavior Like how CTabFolder, color changes should be applied even on TabFolder.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • [ ] All OS
    • [X] Windows
    • [ ] Linux
    • [ ] macOS

Seeing the problem on below environment: Eclipse SDK Version: 2024-09 (4.33) Build id: I20240805-1800 OS: Windows 11, v.10.0, x86_64 / win32 Java vendor: Eclipse Adoptium Java runtime version: 21.0.1+12-LTS Java version: 21.0.1

deepika-u avatar Aug 07 '24 08:08 deepika-u

Setting foreground and background colour on Tabfolder works fine on MacOS.

This is how it is in Mac :

Screenshot 2024-08-07 at 2 59 08 PM

elsazac avatar Aug 07 '24 09:08 elsazac

Could someone verify the behavior on Linux?

elsazac avatar Aug 07 '24 09:08 elsazac

Here how TabFolder looks like on RHEL 9.2:

image

Here CTabFolder used in your snippet:

image

Obviously they differ, but the one is created by native widget toolkit, other one is "faked".

I believe this could be difficult to get consistent behavior on all platforms without breaking existing code. But if you want consistency, please provide patches...

iloveeclipse avatar Aug 08 '24 08:08 iloveeclipse

When checked further on windows apis, i am not able to find anything specifically to set foreground or background on tabfolder on windows from below api list like tabctrl_set.... => https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-tabctrl_setcurfocus

So as of now this issue can be closed as an windows limitation. Can someone add labels as limitation, windows and close this issue please.

deepika-u avatar Aug 21 '24 13:08 deepika-u