Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-09

Transparent Custom Drawn Controls

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

I'm writting own drawer for custom drawn controls. But all controls inherit from (TCDControl -> TCustomControl), so background by default is without transparent (I get uniform gray color). I think that non-container controls (like TCDStaticText, TCDButton etc) should inherit from TGraphicControl which has support for transparent background. Custom Drawn Controls have potencial and I really like this idea, but lack of transparency disqualify this package for creating modern and fancy interfaces. For example I even can't drop TCDStaticText on panel which have gradient or some graphic :/

Regards

Reply by email

Paul Ishenin
to Krzysztof
Krzysztof wrote 8 lines
Hi, I'm writting own drawer for custom drawn controls. But all controls inherit from (TCDControl -> TCustomControl), so background by default is without transparent (I get uniform gray color). I think that non-container controls (like TCDStaticText, TCDButton etc) should inherit from TGraphicControl which has support for transparent background.

And has no focus support since TGraphicControl does not have OS handle and as result does not have focus.

Best regards,
Paul Ishenin

Reply by email

Krzysztof
to Paul Ishenin

Hmm. So maybe can I somehow copy fragment of canvas from parent?

For example I have this controls hierarchy:

TForm
|- TPanel filled with gradient
|- TCDStaticText or other CD control

And now, in my custom drawer, before I draw e.g static text, I copy fragment (from position where static text is placed) of parent background (TPanel) to the bitmap and draw it in static text before drawing text. This will give us some kind of fake transparent, but it it is possible then it matches for me.

Reply by email

Paul Ishenin
to Krzysztof
Krzysztof wrote
Hmm. So maybe can I somehow copy fragment of canvas from parent?

Once I needed this too but failed on win32 without layered window style. On other widgetsets this may also be a problem - I remember some of them draw from parent to child and some from child to parent using clipping.

Maybe it is possible to add an option to make TCustomControl transparent with implementation in all backends (by some window flags on win32 or by applying some properties on qt, gtk2) but I don't know whether it is possible everywhere and I'm not going to work on it at the near future.

Best regards,
Paul Ishenin

Reply by email

Krzysztof
to Paul Ishenin

I found another solution. The best thing in Custom Drawn Controls is that all drawing logic is in drawer object. So I am just creating own component TMyCDStaticText which inherit from TGraphicControl and then in Paint method I call GetDefaultDrawer.DrawStaticText(). So with this trick I have transparent label. This same with buttons etc (I don't need focus states in my application ) ... :)

Reply by email