[Gtk-sharp-list] Gtk# constructors

Mike Kestner mkestner@speakeasy.net
18 Feb 2003 17:43:18 -0600

On Tue, 2003-02-18 at 08:57, Lee Mallabone wrote:

> 1: protected HBox(uint gtype) : base(gtype) {}
> 2: public HBox(IntPtr raw) : base(raw) {}
> 3: protected HBox() : base(){}
> 4: public HBox(bool homogeneous, int spacing)

> Number 4 is the only one an application programmer cares about, I think.

Unless the application programmer wants to subclass HBox.

> Number 3 looks really odd - I followed the class hierarchy up to
> GLib.Object, and its constructor just does:

If I subclass HBox, I have to chain up to an HBox ctor, otherwise the
compiler will assume I want to use a ctor with the same signature, which
may not exist.  If I instantiate an object via PInvoke and assign the
handle in my ctor, I can chain up to #3.

BTW, 1 is for chaining up subclasses that want to instantiate via the
g_object_new() paradigm, and I think 2's purpose has been sufficiently
hashed out without me.  :)

Mike Kestner <mkestner@speakeasy.net>