isTransparent not working in D6

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

isTransparent not working in D6

Joseph Frippiat
I created a RoundRectView and it draws itself with:

!RoundRectView methodsFor!

onPaintRequired: aPaintEvent
        "Private - Handler for paint event. Show the shape"

        | canvas |
        canvas := aPaintEvent canvas.
        canvas pen: (Pen
                                withStyle: 0
                                width: 2
                                color: Color black).
        canvas brush: Brush transparent.
        canvas rectangle: (1 @ 1 corner: self width @ self height) round: 40 @
40! !
!RoundRectView categoriesFor: #onPaintRequired:!event handling!private! !


I created a RoundRectPresenter for it and I added the view with:

RoundRectPresenter addView: RoundRectView asResource: 'Default view'.


I don't know why but in the View Composer, when I add a
"RoundRectPresenter.Default View" to a view, I can not make it
transparent even if I set the "isTransparent" aspect at true ...

Thanks,

Joseph


Reply | Threaded
Open this post in threaded view
|

Re: isTransparent not working in D6

Ian Bartholomew-21
Joseph,

> I don't know why but in the View Composer, when I add a
> "RoundRectPresenter.Default View" to a view, I can not make it transparent
> even if I set the "isTransparent" aspect at true ...

Seems to work here?

I added the code you gave.
In the VC I created a new Shell and set it's backcolor to green.
I dropped a RoundRectPresenter.Default view on the shell and it drew itself
in white.
I set it's #isTransparent aspect to true and it then redrew itself in green.

--
Ian

Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: isTransparent not working in D6

Joseph Frippiat
In reply to this post by Joseph Frippiat
Ian Bartholomew wrote:

> Seems to work here?
>
> I added the code you gave.
> In the VC I created a new Shell and set it's backcolor to green.
> I dropped a RoundRectPresenter.Default view on the shell and it drew itself
> in white.
> I set it's #isTransparent aspect to true and it then redrew itself in green.
>

Ian,

Put a second one on the first one (partially), make it transparent, its
background will become green also but you will not see the first one
through it ...

Thanks,

Joseph


Reply | Threaded
Open this post in threaded view
|

Re: isTransparent not working in D6

Udo Schneider
In reply to this post by Joseph Frippiat
Joseph Frippiat wrote:
> I don't know why but in the View Composer, when I add a
> "RoundRectPresenter.Default View" to a view, I can not make it
> transparent even if I set the "isTransparent" aspect at true ...
Welcome to the wonderfull world of windows ;-)

By default windows erases the background of each view with it's windows
class color before sending WM_PAINT which leads to onPaintRequired: . To
prevent Windows from erasing the background you can simply add the
following method to your View class:

onEraseRequired: aColorEvent
        ^true

You can even do your own "erasing" here ;-) But please keep in mind to
not return 0/nil/or false from this methods. If you do the default
windows behaviour kicks in (blanking the view).

If you return something else then 0 or true windows thinks you took care
of eveytrhing and keeps quiet.

Hope this helps.

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: isTransparent not working in D6

Joseph Frippiat
Udo Schneider wrote:

> Hope this helps.

It does.

Thanks,

Joseph