[Gtk-sharp-list] default empty protected constructors (please read this one instead of crapped previous one)

Radek Doulík rodo@ximian.com
12 Jul 2002 16:28:12 -0400


On Pá, 2002-07-12 at 16:16, Mike Kestner wrote:
> On 12 Jul 2002, Radek [ISO-8859-1] Doulík wrote:
> 
> > why do we have constructors like this one?
> > 
> > protected ScrolledWindow() : base(){}
> 
> If a class doesn't have a void ctor, we generate the above so that it can
> be subclassed easily. I know this messes with customization possibilities,
> because at one point I attempted to add a void Window ctor in a .custom
> file.
>  
> > I would like to add new constructor to ScrolledWindow, but I can't do it
> > yet because of mentioned protected one.
> > 
> > public ScrolledWindow () : this (new Adjustment (IntPtr.Zero), new Adjustment (IntPtr.Zero)) {}
> 
> I know I suggested this on IRC last night, but thinking about it further, it
> won't work.  We need null handling to do this right.  I logged a bug for null
> handling already, but you might want to make a note that ScrolledWindow is a 
> good test case.  :)

It works nice if protected constructor is removed.

> 
> Since providing simplified "default" ctors is likely to be a common 
> customization, I'm thinking it might be worth adding a metadata category for
> defining default parameter values for existing ctors.

This will be better way though, but still not as powerfull as
customizing. It will be probably better to just mark class in metadata
for not defining a default protected constructor and provide default
constructor in .custom file. This way we could for example set POLICY
for scrollbars to Automatic in ScrolledWindow constructor.

Cheers
Radek
-- 
Radek Doulík <rodo@ximian.com>
Ximian, Inc.