comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: [OT] Best way to isolate a GUI?
Date: Thu, 20 Feb 2003 16:34:35 -0500
Date: 2003-02-20T16:34:35-05:00	[thread overview]
Message-ID: <3E5549EB.1050907@cogeco.ca> (raw)
In-Reply-To: v5abnj6u49es24@corp.supernews.com

Randy Brukardt wrote:
> Warren W. Gay VE3WWG wrote in message <3E53CCDF.1090509@cogeco.ca>...
> 
>>Randy Brukardt wrote:
>>
>>>In any case, my point is that there are a lot more kinds of events in
>>>the full-blown GUI than there are in X11 itself. (I should point out
>>>that its been years since I've had any reason to look at X11, so I'm
>>>working from old memories of X.)
>>
>>I won't disagree with that. In fact, to some degree, I think you've
>>managed to successfully present the tagged record approach as a good
>>callback approach for two reasons that I would consider key:
>>
>>  1. Reduces one central "definition" of the event to a base type (or set)
> 
>>  2. Allows easy extendability of the event object as new widgets
>>     are developed.
> 
> Yes, exactly. These are precisely why we used the tagged approach.

It took a little convincing, but I am sold on this now ;-)

>>>>But my point has always been in this
>>>>thread is that there has been no good reason given that event data
>>>>cannot be provided in a callback parameter as a variant record.
>>>
>>>For simple events, I prefer to simply provide the data as parameters to
>>>the action routine (the event handler that you override in an OOP GUI
>>>like Claw). And, if the events are sufficiently different, I'll
>>>provide different routines for them. For example, I certainly see no reason
>>>to share the handler for a keypress and a mouse click. That usually
>>>eliminates the need for complex data structures of any sort.
>>
>>From a "client perspective", I would agree with this. But with my
>>library writer's hat on I don't because that means I have to define
>>different collections of callbacks. Whereas if you define one type
>>of callback interface, say something like:
>>
>>   procedure Callback(W : Widget_Type; Event : Event_Type'Class;
> 
> User_Data_Ref : ...);
> 
>>then you can centralize code to call a callback list, add to and delete
>>from the callback list. All widgets can then be built to use the same
>>resources.
> 
> Remember the ease of writing is WAY down on the list of good things for
> Ada, 

Yes, I agree with this.

> and we certainly followed this approach with Claw. Our goals for
> the interface were (not necessarily in this order):
>    -- Avoid unnecessary overhead in the implementation of the interface;
>    -- Insure that the interface prevents common errors, preferably at compile-time;
>    -- Make the interface easy to use for the client.

I tend to put "overhead" in the lowest category as long as the overhead
is "reasonable"; at least for projects like a UI. I would personally
rate your last two points higher for example, if I were to rate them
(all of them goals that I would agree with).

> Our effort in writing the interface was never an issue. Of course, we
> expect many people to use it, and thus the effort spent in meeting the
> goals will pay off over time.

That's what I prefer to see, for sure : long term goals with long
term payoffs.

>>Ok. You have sold me on tagged types for the event info. However, I
>>still some application for variants within those tagged types ;-)
> 
> Like Marin, I'll never say "never use" something, because that's silly.
> If a variant makes sense in a particular extension, by all means use it.
> But the base item should be a tagged root type of some sort, not a
> massive variant.
> 
> I think we finally agree.
> 
>               Randy.

Yes. In fact, more than this.. 8-O

I liked your idea of taking what I call the "application
context" object and extending it to provide the access to the user data.
By doing this, I was able to eliminate a system.address and a ghastly
generic procedure to convert address to User_Data_Ptr.

The only downside
to this, is that the user must continually "convert" the ACTX_Type to a
User_Data type, to reference members (the ACTX_Type is a controlled limited
type).

     type User_Data is new ACTX_Type with
        record
           Whatever : Boolean;  -- User data member(s)
        end;

     procedure Callback(ACTX : ACTX_Type'Class; ...) is
     begin
        User_Data(ACTX).Whatever := True;
        ...

I suppose if you have many refs to the user data type, you can call
a procedure with the type converted as in:

     Yet_Another_Proc(User_Data(ACTX),...)

where

     procedure Yet_Another_Proc(UD : in out User_Data; ...) is
     begin
        UD.Whatever := ...;

as either an internal or external procedure.

Thanks for the effort of convincing  ;-)

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




  reply	other threads:[~2003-02-20 21:34 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-16 10:19 [OT] Best way to isolate a GUI? Jano
2003-02-16 14:47 ` Ed Falis
2003-02-16 14:49 ` Victor Porton
2003-02-17 20:52   ` Jano
2003-02-16 16:36 ` Robert C. Leif
2003-02-17  8:44   ` Preben Randhol
2003-02-17 16:22     ` Robert C. Leif
2003-02-17 17:30     ` Jeffrey Carter
2003-02-17 17:54       ` Warren W. Gay VE3WWG
2003-02-17 19:06         ` Randy Brukardt
2003-02-18  3:15           ` Warren W. Gay VE3WWG
2003-02-18 16:14             ` Robert C. Leif
2003-02-18 18:10             ` Randy Brukardt
2003-02-18 21:12               ` Warren W. Gay VE3WWG
2003-02-18 23:20                 ` Randy Brukardt
2003-02-19 18:28                   ` Warren W. Gay VE3WWG
2003-02-20 19:39                     ` Randy Brukardt
2003-02-20 21:34                       ` Warren W. Gay VE3WWG [this message]
2003-02-20  7:50                   ` Dale Stanbrough
2003-02-19 12:49                 ` Marin David Condic
2003-02-19 18:35                   ` [OT] Best way to isolate a GUI? (The final concensous?) Warren W. Gay VE3WWG
2003-02-20 12:40                     ` Marin David Condic
2003-02-20 13:13                       ` Dmitry A. Kazakov
2003-02-20 22:01                       ` Warren W. Gay VE3WWG
2003-02-21  1:25                         ` tmoran
2003-02-21  2:08                         ` Marin David Condic
2003-02-21 17:27                           ` Jeffrey Carter
2003-02-22 14:10                             ` Marin David Condic
2003-02-21 18:02                           ` Warren W. Gay VE3WWG
2003-02-22 14:49                             ` Marin David Condic
2003-02-22 22:50                               ` tmoran
2003-02-23  5:18                               ` Robert C. Leif
2003-02-24 18:06                               ` Warren W. Gay VE3WWG
2003-02-25  1:20                                 ` Robert C. Leif
2003-02-25 17:57                                   ` Warren W. Gay VE3WWG
2003-02-25 12:41                                 ` Marin David Condic
2003-02-25 13:32                                   ` Ole-Hjalmar Kristensen
2003-02-25 17:33                                     ` [OT] Best way to isolate a GUI? (The final fronteer?) Warren W. Gay VE3WWG
2003-02-20  8:26                   ` [OT] Best way to isolate a GUI? tmoran
2003-02-20 12:51                     ` Marin David Condic
2003-02-20 18:47                       ` tmoran
2003-02-17 19:31         ` tmoran
2003-02-18  1:37         ` Jeffrey Carter
2003-02-18  3:39           ` Warren W. Gay VE3WWG
2003-02-18 23:36           ` Randy Brukardt
2003-02-18 13:29         ` Marin David Condic
2003-02-18 18:01           ` Warren W. Gay VE3WWG
2003-02-19 13:06             ` Marin David Condic
2003-02-16 17:25 ` achrist
2003-02-16 21:24 ` Bobby D. Bryant
2003-02-16 21:52 ` David Marceau
2003-02-17  0:57 ` Re; " tmoran
2003-02-17  7:25   ` Jano
2003-02-17 14:09     ` Bobby D. Bryant
2003-02-17 21:12       ` Jano
2003-02-18  7:24         ` Jean-Pierre Rosen
2003-02-18 13:08 ` Marin David Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox