Re: class constrctor code

Bryan Bulten <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
> a) I am still trying to wrap my brain around class
> constructor in wx.NET. I wonder what the following
> code does (as in e.g. Dialog and Button):
> 
> public Button( IntPtr wxObject ): base(wxObject)
> {
> }

The constructors that take the 'IntPtr' are (or will be) used when
constructing an object for which no C# reference is directly available
(basically, in Object::CreateFromObject and Event::CreateFrom.)

For example, when an event is received (in EvtHandler::MarshalEvent),
all that is available is an IntPtr to the C++ wxEvent subclass.  Using
the event type for the IntPtr, the IntPtr is used to create the
appropriate C# class for that event type (in Event::CreateFrom.)

The method of doing this is via a hashtable constructed in Event's
static constructor.  The hashtable links event types to object types.

A similar variation of this is used in Object, except that the wxWindows
RTTI strings are used to construct the hashtable.

I will extend the tutorial that I wrote to include this information the
next chance I get.

> and why it sometimes is "public" and sometimes defined
> as "internal" (e.g. in Dialog).

They _should_ be declared as 'internal', this is probably a bit of a
mess-up on my part, since I probably had the same difficulty as you are
having now.

> b) Am i right that it is the ultimate aim that
> class construction is always done through the
> wxXxxxx_Create interface and not through the
> wxXxxxx_ctor interface (so it should look like
> what e.g. Button currently does).

Yes; doing it this way seems to make life a little easier (less
constructors required in the C wrapper.)

-- 
Bryan Bulten
http://opendev.ods.org/
http://wxnet.sourceforge.net/
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+pGA632WFWIzmzHgRAk4vAJwPbi2fEk6jZ8poK5rNl+WojO08ugCffRyy
zLOCQn4NW2btL6pUB/7SoEw=
=GH3M
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.