Bug 88030 - Table and SWT.CHECK: Check not visible on selection
Summary: Table and SWT.CHECK: Check not visible on selection
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords: ui
Depends on:
Blocks:
 
Reported: 2005-03-15 05:45 EST by Benjamin Pasero CLA
Modified: 2005-05-03 11:15 EDT (History)
3 users (show)

See Also:


Attachments
Table with check style (25.78 KB, image/png)
2005-04-05 18:45 EDT, Brock Janiczak CLA
no flags Details
Workaround (824 bytes, patch)
2005-04-07 20:53 EDT, Florian Priester CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Pasero CLA 2005-03-15 05:45:09 EST
Having a Table with SWT.CHECK Style, the Checkbox becomes invisible, when the
TableItem is selected. This is happening on WinXP w/o using Manifest. It is not
happening using the Manifest.

Ben
Comment 1 Steve Northover CLA 2005-04-05 17:21:41 EDT
Can you post a screen shot?
Comment 2 Brock Janiczak CLA 2005-04-05 18:44:44 EDT
I am seeing this too, but i am running with the manifest.  If i use the standard
WinXP theme the problem goes away.
Comment 3 Brock Janiczak CLA 2005-04-05 18:45:46 EDT
Created attachment 19574 [details]
Table with check style
Comment 4 Florian Priester CLA 2005-04-05 21:45:58 EDT
Apparently, the disappearing check box is related to the use of the
ILC_COLOR32 flag for ImageList_Create (in Table.setCheckboxImageList)
which does not seem to work as expected when visual styles are disabled.
Before v3119, ILC_COLOR was used and that's when it last worked.
Comment 5 Steve Northover CLA 2005-04-06 11:06:13 EDT
Good catch Florian!  FH and SN to confirm that the style is causing the 
problem and fix the problem.
Comment 6 Steve Northover CLA 2005-04-06 11:21:38 EDT
Ok, this WORKSFORME.  Can you provide more information, specifically the 
version of XP, display resolution and graphics card?  Thanks.
Comment 7 Florian Priester CLA 2005-04-06 11:50:16 EDT
- Windows XP Professional, SP2
- COMCTL32.DLL product version=6.00.2900.2180
- ATI Radeon 8500
- Colour depth 32-bit
- Windows Classic Theme
- javaw.exe.manifest installed
Comment 8 Felipe Heidrich CLA 2005-04-06 12:45:27 EDT
(In reply to comment #4)
> Apparently, the disappearing check box is related to the use of the
> ILC_COLOR32 flag for ImageList_Create (in Table.setCheckboxImageList)
> which does not seem to work as expected when visual styles are disabled.
> Before v3119, ILC_COLOR was used and that's when it last worked.

That wasn't all. We also removed the flag ILC_MASK from ImageList#COLOR_FLAGS 
(formely CREATE_FLAGS) and we replaced ImageList_AddMasked by ImageList_Add in 
Table.setCheckboxImageList.
This changes were necessary to draw a xp themed checkbox correctly in Table 
and Tree (Does Tree work for you).

You can try this patch:
-------------cut here--------------don't include this line-------------
Index: ImageList.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse 
SWT/win32/org/eclipse/swt/widgets/ImageList.java,v
retrieving revision 1.22
diff -u -r1.22 ImageList.java
--- ImageList.java	30 Mar 2005 19:27:28 -0000	1.22
+++ ImageList.java	6 Apr 2005 16:41:48 -0000
@@ -24,7 +24,7 @@
 			COLOR_FLAGS = OS.ILC_COLOR;
 		} else {
 			int flags = 0;
-			if (OS.COMCTL32_MAJOR >= 6) {
+			if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed()) {
 				flags |= OS.ILC_COLOR32;
 			} else {
 				int hDC = OS.GetDC (0);
-------------cut here--------------don't include this line-------------

Or this other one:

-------------cut here--------------don't include this line-------------
Index: Table.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse 
SWT/win32/org/eclipse/swt/widgets/Table.java,v
retrieving revision 1.199
diff -u -r1.199 Table.java
--- Table.java	28 Mar 2005 20:29:44 -0000	1.199
+++ Table.java	6 Apr 2005 16:45:13 -0000
@@ -2203,7 +2203,7 @@
 void setCheckboxImageList (int width, int height) {
 	if ((style & SWT.CHECK) == 0) return;
 	int count = 4;
-	int flags = ImageList.COLOR_FLAGS;
+	int flags = ImageList.COLOR_FLAGS | OS.ILC_MASK;
 	if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.ILC_MIRROR;
 	int hImageList = OS.ImageList_Create (width, height, flags, count, 
count);
 	int hDC = OS.GetDC (handle);
@@ -2245,7 +2245,7 @@
 	OS.SelectObject (memDC, hOldBitmap);
 	OS.DeleteDC (memDC);
 	OS.ReleaseDC (handle, hDC);
-	OS.ImageList_Add (hImageList, hBitmap, 0);
+	OS.ImageList_AddMasked (hImageList, hBitmap, 0);
 	OS.DeleteObject (hBitmap);
 	int hOldStateList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, 
OS.LVSIL_STATE, 0);
 	OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, 
hImageList);
-------------cut here--------------don't include this line-------------

Comment 9 Florian Priester CLA 2005-04-06 14:47:56 EDT
(In reply to comment #8)
> (In reply to comment #4)
> > Apparently, the disappearing check box is related to the use of the
> > ILC_COLOR32 flag for ImageList_Create (in Table.setCheckboxImageList)
> > which does not seem to work as expected when visual styles are disabled.
> > Before v3119, ILC_COLOR was used and that's when it last worked.
> 
> That wasn't all. We also removed the flag ILC_MASK from ImageList#COLOR_FLAGS 
> (formely CREATE_FLAGS) and we replaced ImageList_AddMasked by ImageList_Add in 
> Table.setCheckboxImageList.

Yes, I noticed that there had been several changes but I tried to narrow it
down to the one that made the difference between a visible check box and an
invisible one. On my system, that was ILC_COLOR (Table v1.168) vs.
ILC_COLOR32 (later versions). Or rather, ILC_COLOR vs. ImageList.COLOR_FLAGS
which for me evaluated to ILC_COLOR32.

> You can try this patch:
> Index: ImageList.java
> +			if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed()) {

Actually, that is something I had already tried before posting comment #4.
However, it does not fix the problem. The reason for that is that using
OS.GetDeviceCaps (in the 'else' branch) results in the exact same value
(ILC_COLOR32).

> Or this other one:
> Index: Table.java
> +	int flags = ImageList.COLOR_FLAGS | OS.ILC_MASK;

That's better. With that line, the check box is visible again...

> +	OS.ImageList_AddMasked (hImageList, hBitmap, 0);

...until this line is added. Now *all* check boxes have disappeared.
Comment 10 Florian Priester CLA 2005-04-06 14:57:23 EDT
(In reply to comment #8)
> (Does Tree work for you)

Judging from a quick test with Eclipse 3.1M6: Yes.
Comment 11 Florian Priester CLA 2005-04-07 20:53:04 EDT
Created attachment 19673 [details]
Workaround

How about applying this patch until/unless a better solution is found?
Comment 12 Florian Priester CLA 2005-05-03 09:24:26 EDT
Pinging this bug report since it's still a regression and M7 is getting nearer.
I believe that the patch provided in comment #11 will be enough to fix the
problem. It restores the use of ILC_COLOR for unthemed clients while keeping
ImageList.COLOR_FLAGS for all others. I have verified this to work on
my machine for all four combinations of (Classic Theme|XP Theme) and
(with manifest|without manifest). If you can think of a better approach
then that's great but either way, please bring the check boxes back.
Comment 13 Steve Northover CLA 2005-05-03 09:28:13 EDT
Right, FH and SN to get to the bottom of this.  FH, were you ever able to 
recreate this?
Comment 14 Steve Northover CLA 2005-05-03 09:31:47 EDT
Ok, I can make it happen.
Comment 15 Steve Northover CLA 2005-05-03 09:33:42 EDT
FYI: Doesn't happen for Tree.
Comment 16 Steve Northover CLA 2005-05-03 10:22:44 EDT
Ok, I have a fix.  FH to check the code.
Comment 17 Steve Northover CLA 2005-05-03 11:15:44 EDT
Fixed > 20050503

Thanks for pinging me on this very important bug.  Thanks also Florian for your 
good work and interest in this area.