https://bugs.winehq.org/show_bug.cgi?id=44633
Bug ID: 44633 Summary: Checboxes and Radiobuttons blank out the text area that follows them Product: Wine Version: 3.2 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdi32 Assignee: wine-bugs@winehq.org Reporter: ryampolsky@yahoo.com Distribution: ---
Because it's not possible to control the text color for themed checkboxes and radiobuttons, I have implemented a kludge in my app that works on Windows, but not WINE. I create checkboxes and radiobuttons as two widgets: the button, with a null text string (but sized as if it contained the text so that clicking on the text still activates the button), followed by a static text item for the label, which I draw in black or white depending on the background color.
I process the WM_CTLCOLOR... messages, and set the background mode to TRANSPARENT, but I return a non-null background brush. If I don't do that, the button's focus rectangle doesn't go away when it loses focus. But since the text is null, Windows doesn't draw anything where the text would go. My static text control draws in the same place - resulting in what looks like a normal check/radiobutton, but with the text in the color I want.
This works fine on Windows, and I think it used to work under WINE (but don't quote me - this is a recent feature, and I may have never tested it under a prior version of WINE). In version 3.2 at least, the radiobutton or checkbox seems to be overwriting my static text control - so that I don't see the text at all. I.e., WINE is drawing the full text rectangle, even though it contains a null string. Either Windows only draws the rectangle for the actual 0-sized text string, or it's order of operations allows my static text to remain visible. But in Windows, there's no 'flashing' of the text, so I suspect the background rectangle is being sized to the null string and the static label is never erased and redrawn.
In WINE, when I click the radiobutton, I can see my static text label flash on - but it is immediately overwritten by a blank text rectangle drawn by WINE. Yes, my code is a bit of a kludge, but it works on Windows (and I know of no other way to control the color of check/radiobutton text). It'd be nice if it worked on WINE too, no?
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com --- Could you attach small test program that shows this bug?
https://bugs.winehq.org/show_bug.cgi?id=44633
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|gdi32 |-unknown
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #2 from ryampolsky@yahoo.com --- Created attachment 60629 --> https://bugs.winehq.org/attachment.cgi?id=60629 Trivial test app binary
Okay. I've attached a trivial test app. It creates a red checkbox immediately after creating the main window. The checkbox has no label (null string), but is sized big enough for the "Red Checkbox" label.
Then the main message handler traps WM_CTLCOLORSTATIC, sets the background mode to TRANSPARENT, draws the button label itself with DrawText and then returns NULL-BRUSH.
The "Red Checkbox" label shows up with no theme enabled, but does not show up when there is a theme enabled.
I can send you the source code if you want. But here are the two bits of code that I added to an empty project:
This bit goes in InitInstance:
// Create a checkbox with red text. // Because Windows won't let you control the color of themed radiobutton text, create the button with // null text, and draw the text ourselves in the CTLCOLOR_BTN handler.
// Size the checkbox to the size of the label. hDC = GetDC(hWnd); SetRect(&rc, 0, 0, 10000, 100); DrawText(hDC, L"Red Checkbox", strlen("Red Checkbox"), &rc, DT_CALCRECT); width = rc.right; // text width width += CHECKBOX_BITMAP_FUDGE; // checkbox bitmap width hCheck = CreateWindow(L"Button", L"", WS_CHILD | BS_CHECKBOX, 20, 20, width, 20, hWnd, NULL, hInstance, NULL); ShowWindow(hCheck, SW_NORMAL);
And this bit is in WinProc:
case WM_CTLCOLORBTN: case WM_CTLCOLORSTATIC: SetTextColor((HDC)wParam, RGB(192, 0, 0)); GetClientRect((HWND)lParam, &rc); rc.left += 15; DrawText((HDC)wParam, L"Red Checkbox", strlen("Red Checkbox"), &rc, DT_SINGLELINE | DT_LEFT | DT_BOTTOM | DT_VCENTER); return (LRESULT) GetStockObject(NULL_BRUSH);
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #3 from ryampolsky@yahoo.com --- Created attachment 60630 --> https://bugs.winehq.org/attachment.cgi?id=60630 Trivial app source file
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #4 from ryampolsky@yahoo.com --- ... and by the way, the code here returns NULL_BRUSH on WM_CTLCOLORSTATIC, but in my original Windows program I was returning a background color brush. When I do that in WINE, the checkbox text doesn't show up with or without a theme enabled.
But in Windows it does show up.
So I suspect Windows is clipping the background rectangle to the width of the label text, and WINE is not doing that when a theme is enabled. When no theme is enaabled, WINE may or may not be clipping the text - since it's honoring the NULL_BRUSH, it's hard to tell.
But the reason I was NOT sending a NULL_BRUSH originally was that at one point the focus rectangle on these controls was remaining inverted after the control lost focus. I had originally hoped that NULL_BRUSH would allow themed checkboxes to be drawn over a gradient background, but Windows does not respect NULL_BRUSH when drawing themed check/radio buttons. And since that didn't work, I was playing it safe with a real brush - just in case the focus rectangle problem was still there. Too much information, right> ;-)
https://bugs.winehq.org/show_bug.cgi?id=44633
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dark.shadow4@web.de
--- Comment #5 from Fabian Maurer dark.shadow4@web.de --- Using wine-3.2, and your test program behaves the same as on my win7 VM.
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #6 from ryampolsky@yahoo.com --- (In reply to Fabian Maurer from comment #5)
Using wine-3.2, and your test program behaves the same as on my win7 VM.
Are you saying it behaves correctly in both places? On my real win7 machine it draws the "Red Checkbox" label (in red). On wine-3.2 with no theme, it behaves the same. On wine-3.2 with the Ubuntu-light theme, it draws the checkbox glyph, but not the label.
https://bugs.winehq.org/show_bug.cgi?id=44633
Fabian Maurer dark.shadow4@web.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Component|-unknown |uxtheme Summary|Checboxes and Radiobuttons |Checkboxes and Radiobuttons |blank out the text area |blank out the text area |that follows them |that follows them when | |theming is enabled Ever confirmed|0 |1 Keywords| |download, testcase
--- Comment #7 from Fabian Maurer dark.shadow4@web.de --- Ah, I misread that. When I have a theme enabled in winecfg, I can reproduce the issue. Native uxtheme fixes the problem.
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #8 from ryampolsky@yahoo.com --- Yeah. And if I don't do my trick of drawing the text myself, the theme draws it fine - except that the various themes I've tried draw the text in blue, which I don't like.
Basically, my app allows users to chose colors for various items. And I have one color for 'field labels', which applies to regular static text in front of input boxes as well as pushbutton, checkbox and radiobutton labels. I want all three to draw in the same color - and my check/radio kludge makes this work. Also, my app supports automatically switching to white text when the item is drawn on top of a dark background. None of this works with themes 'out of the box', but all of it works when I draw the text myself. Except on WINE, which, well... I repeat myself ;-)
So, bug?
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #9 from Fabian Maurer dark.shadow4@web.de ---
None of this works with themes 'out of the box', but all of it works when I draw the text myself. Except on WINE, which, well... I repeat myself ;-)
So, bug?
Oh course, as noted, it's a bug in wine's uxtheme.
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #10 from ryampolsky@yahoo.com --- Here's another wrinkle. I just had a user of my app report a problem that looks just like this. Checkbox and Radiobutton text does not appear. And that user is running Windows 7. It turns out that they have the "Windows Classic" theme enabled on their Windows 7 box, and in that mode Windows overwrites my control text just like WINE does with theming enabled.
So the crux of the problem seems to be with the fact that I:
1. Size the checkbox control as if it had the label as text, but give it a null text string. I size the controls as if they had text so that clicking on the manually drawn text will activate them.
2. Draw the label myself to the right of the checkbox glyph (so I can draw it in any color I wish). I do this in response to the WM_CTLCOLORBTN message (maybe that's a problem, but it worked, so I figured it was okay).
In Windows, with theming enabled, the null text does not overwrite my manually drawn text. But in Windows, with the 'classic' or 'high contrast' themes, it does. It seems to draw a blank background rectangle where the text would go - even though I returned NULL_BRUSH as the background brush I want used.
And WINE seems to do the same thing even with a theme enabled. So, WINE isn't working the same as Windows - but what I'm doing isn't quite kosher, I guess. Still, WINE tries to emulate Windows with all of it's quirks and bugs, right?
https://bugs.winehq.org/show_bug.cgi?id=44633
tokktokk fdsfgs@krutt.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |fdsfgs@krutt.org
https://bugs.winehq.org/show_bug.cgi?id=44633
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|uxtheme |comctl32
https://bugs.winehq.org/show_bug.cgi?id=44633
--- Comment #11 from Nikolay Sivov bunglehead@gmail.com --- What theme are you using to test this?