All Black Checkboxes (workaround)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

All Black Checkboxes (workaround)

Steve Alan Waring
Hi,

In reply to the "All Black Radio Button?" thread from Dec 9 2005
(Google won't let me reply to it directly):

http://groups.google.com.au/group/comp.lang.smalltalk.dolphin/browse_thread/thread/1e4c4334b2a4924c

Specifically in reference to transparent checkboxes with a background
color of Color none, being painted with a solid black background (only
when themes are enabled).

To reproduce it (on an XP machine with themes enabled)
 - Add a checkbox to a containerView.
 - Set the checkbox backcolor to Color none.

The checkbox should then have a black background in both the
ViewComposer and when you show the presenter.

I did some searching and the general consensus seems this is a bug in
Windows XP. I implemented the workaround from:

http://groups.google.com/group/microsoft.public.platformsdk.ui/browse_thread/thread/b34d1b2b5dbae69d

!CheckBox methodsFor!

onColorRequired: aColorEvent
        "Fix for Checkboxes with Color none being drawen with a black
background on WinXP with themes.
        See:
http://groups.google.com/group/microsoft.public.platformsdk.ui/browse_thread/thread/b34d1b2b5dbae69d"

        | canvas back brush |
        back := self basicActualBackcolor.
        canvas := aColorEvent canvas.
        self forecolor ifNotNil: [:fore | canvas forecolor: fore].
        back isDefault ifTrue: [^nil].
        brush := back brush.
        back isNone
                ifTrue:
                        ["Start workaround"
                        self isThemed
                                ifTrue:
                                        [| parentCanvas |
                                        parentCanvas := self parentView canvas.
                                        canvas bitBlt: parentCanvas
                                                rectangle: (self mapRectangle: self clientRectangle to: self
parentView)
                                                to: self clientRectangle origin
                                                rop: SRCCOPY.
                                        parentCanvas free].
                        canvas backgroundMode: TRANSPARENT]
                ifFalse: [canvas backcolor: back].
        canvas brush: brush.
        ^brush asParameter.! !



In the ViewComposer, the checkbox still has the solid black background,
but in a real view they appear as you would expect ... although I have
not done much testing of it.

I needed an additional workaround to fix a problem with focus rectangle
artifacts:

!CheckBox methodsFor!

onKillFocus
        "Fix problem of focusRect artifcat being left when tabbing away from
the receiver.
        It seems we need to invalidate the parent"

        (self isThemed and: [self basicActualBackcolor isNone])
                ifTrue: [self parentView invalidateRect: (self mapRectangle: self
clientRectangle to: self parentView)].
        ^super onKillFocus.! !

If anyone has found a better workaround, please let me know.
Thanks,
Steve
--
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: All Black Checkboxes (workaround)

Tim M
Hi Steve,

> In reply to the "All Black Radio Button?" thread from Dec 9 2005
> (Google won't let me reply to it directly):
>
> http://groups.google.com.au/group/comp.lang.smalltalk.dolphin/browse_t
> hread/thread/1e4c4334b2a4924c


Thanks for sharing this - it has been annoying me for quite a while now.
I hope that OA will incorporate it into the next Dolphin patch (although
for now I am going to put it into Intelli-Dolphin as an extension as a few
people had mentioned it to me too).

Tim


Reply | Threaded
Open this post in threaded view
|

Re: All Black Checkboxes (workaround)

Support at Object Arts
In reply to this post by Steve Alan Waring
"Steve Alan Waring" <[hidden email]> wrote in message
news:[hidden email]...

> Hi,
>
> In reply to the "All Black Radio Button?" thread from Dec 9 2005
> (Google won't let me reply to it directly):
>
> http://groups.google.com.au/group/comp.lang.smalltalk.dolphin/browse_thread/thread/1e4c4334b2a4924c
>
> Specifically in reference to transparent checkboxes with a background
> color of Color none, being painted with a solid black background (only
> when themes are enabled).
> ...

Steve

Thanks for the workaround, but I think I already have a better one. A better
approach seems to be to use ThemeLibrary>>drawThemeParentBackground:&c
method. This appears to be designed for this purpose, and doesn't need the
onKillFocus workaround, and it also works correctly in the view composer as
well. I've only tested on Windows Server 2003 with the Theme engine enabled
though, not actually on XP yet.

Regards

Blair

------------------
!CheckBox methodsFor!

onColorRequired: aColorEvent
 "Private - Workaround XP bug whereby themed checkboxes are drawn against a
solid black
 background when using a null brush."

 | canvas back brush |
 back := self basicActualBackcolor.
 canvas := aColorEvent canvas.
 self forecolor ifNotNil: [:fore | canvas forecolor: fore].
 back isDefault ifTrue: [^nil].
 brush := back brush.
 back isNone
  ifTrue:
   [self isThemed
    ifTrue:
     [ThemeLibrary default
      drawThemeParentBackground: self asParameter
      hdc: canvas asParameter
      prc: nil].
   canvas backgroundMode: TRANSPARENT]
  ifFalse: [canvas backcolor: back].
 canvas brush: brush.
 ^brush asParameter! !
!CheckBox categoriesFor: #onColorRequired:!event handling!private! !


Reply | Threaded
Open this post in threaded view
|

Re: All Black Checkboxes (workaround)

Steve Alan Waring
Support at Object Arts wrote:
> Thanks for the workaround, but I think I already have a better one. A better
> approach seems to be to use ThemeLibrary>>drawThemeParentBackground:&c
> method. This appears to be designed for this purpose, and doesn't need the
> onKillFocus workaround, and it also works correctly in the view composer as
> well. I've only tested on Windows Server 2003 with the Theme engine enabled
> though, not actually on XP yet.

Hi Blair,

Thanks! ... I have just tried it on XP and it looks good. The checkbox
appears with the correct background in the view composer and when I
show my presenter. I also confirmed that I could tab away from a
checkbox without needing the onKillFocus workaround.

Thanks again!
Steve
--
[hidden email]