[Y-devel] Slider widget done

Jerome Laheurte jerome at gandalf.fraca7.homeunix.net
Wed Mar 10 17:19:23 GMT 2004


On Wed, 10 Mar 2004, Andrew Suffield wrote:

> On Mon, Mar 08, 2004 at 10:16:37PM +0100, Jerome Laheurte wrote:

> >   obj->foobar = "spam";
>
> ...I don't think it's a good idea to pretend that these things are
> lvalues, because they aren't. Furthermore, you don't (can't) provide
> the equivalent "read" behaviour in a sane way.

Yes, I do. In most situations though, it requires an explicit cast,
depending on the compiler's willingness, because it's obviously done
using operator overloading, so it becomes something like

   printf("%s\n", (const char*)obj->text);

(gcc will issue a warning without the cast, anyway)

> > There's also a 'IntegerProperty' class, of course.
>
> Templates, damn you. That's what they're for.

Well, I first tried with templates, but I let it go because I'm not
aware of a way to specify a "transformation function" in a template
(for instance, atol(3) in the case of integer properties).

I choose this approach instead of a more traditionnal get/set method
pair because

1) I'm too used to Python :)

2) That's what's being done elsewhere (in Borland C++ Builder through
proprietary extensions to C++, and in Qt 3.x through a method I don't
know but which is probably very similar to mine).

Anyway, both approaches are better than what we currently have. I
think that mandatory declaration of properties in the class interface
is a Good Thing (tm), no matter how it's enforced, and I look forward
to the day when setProperty() and getProperty() will become protected
or even private.

Cheers
-- 
Jérôme Laheurte <fraca7 at free.fr>
... A solemn, unsmiling, sanctimonious old iceberg who looked like he
was waiting for a vacancy in the Trinity.
                -- Mark Twain



More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved