[fpc-pascal] Problem with multiple inheritance
memsom at interalpha.co.uk
Fri Nov 3 13:16:42 CET 2006
> How can I work around this? I mean, how can I redesign my idea to make
> it work with FP?
> Note that Qt requires that all methods to receive events, and signals
> be from objects (I cannot use a procedure to receive events).
In Delphi, I'd do it through interfaces. Delphi has this neat little trick
that lets you have a property that implements an interface. Assuming FPC
supports that, if you need to refer to the class that owns the property, you
simply add a property of the correct interface type that the owner
implements and then set it on creation. Having said all that, if you go OTT
with this, there are a number of bugs I found (at least in Delphi 5) that
make A/V's happen quite frequently.
Okay, if that option is not available, use a design pattern, like the
Adaptor or Mediator , or cheat. I wrote a basic wrapper for the Be API in
Free Pascal (not the one that you may have heard of - that was occo, mine
was more like the Kylix Qt wrappers.) But what I found was that I needed to
do things that the BeAPI didn't support. So I wrote a glue library in C++
that took each control and added the features I wanted at the level I needed
them in C++. I then created an "abstract" class tree to represent each
Pascal class, with lots of protected members. I then promoted the methods
and properties I needed as and when I needed them. This strikes me as what
Alternatively, look at the way occo did it for BeOS.
http://www.sf.net/projects/befpc . An older version of my (now lost) code is
Oh, whilst were speaking, please stop mentioning Lazarus every time people
mention Kylix on the B.P.D.Non-tech news group. It's tiresome. All you'll
end up doing is making people realize that Kylix did more than Lazarus does
at the moment in Kylix 1. You're turning more people off than on IMHO.
More information about the fpc-pascal