comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: [OT] Best way to isolate a GUI?
Date: Tue, 18 Feb 2003 17:36:15 -0600
Date: 2003-02-18T17:36:15-06:00	[thread overview]
Message-ID: <v55go0qoiu5ga9@corp.supernews.com> (raw)
In-Reply-To: 3E518EA0.1080702@acm.org

Jeffrey Carter wrote in message <3E518EA0.1080702@acm.org>...
>> It might be easier to start with a tagged object, where methods can
>> be inherited and overriden instead. That way all events can just
>> do nothing, while you override the events you are interested in.
>> But this takes us back to a model similar to callbacks anyways, but
>> instead of registering a callback, you register a tagged record
>> to receive callbacks.
>
>This is the approach taken by CLAW. A widget is represented by a tagged
>type, with primitive operations that are called automatically when
>certain events occur. There are default versions of these operations.
To
>create a widget with specific behavior, you have to extend the type and
>override the appropriate operations. This can be useful when you want
to
>have data associated with a widget, as you can define the data as part
>of the extension, give the widget values when you create it, and check
>the values in the operations. But when all you want is to define the
>application's behavior when the user clicks a button, it seems like
>overkill. Consider a window with lots of buttons, different behavior
>when each button is clicked, and little or nothing else in the way of
>user input. This calls for many extensions and many overridings of the
>appropriate operation. It differs from callbacks in not requiring
>operations to be registered with the windowing system, but similar in
>that the windowing system controls your application.


That's not quite right. In Claw (as in MFC, but not quite as in
Windows), notifications are passed first to the control item, then to
the parent window of the control. In most cases, you handle
notifications in the parent window in order to avoid the need to
override so many items. The result isn't quite so pretty, but its a lot
easier to maintain (because there are far fewer packages and types).
This is also convinient for handling the data, which is usually shared
between multiple controls:

A typically handler would look like:

     procedure When_Child_Notify (Window  : in out My_Dialog;
                                 Code    : in
Claw.Notification_Code_Type;
                                 Data    : in
Claw.Notification_Data_Type'Class
                                 Control : in out
Claw.Root_Control_Type'Class;
                                 Unknown_Command : in out Boolean;
                                 Result_Value : in out
Claw.Win32.LResult) is
        use type Claw.Notification_Code_Type;
        use type Claw.Root_Control_Type;
    begin
        if Code = Claw.Buttons.Button_Clicked then
            if Control = Window.Button_1 then
                -- Do whatever.
                Unknown_Command := False;
            elsif Control = Window.Button_2 then
                -- Do whatever.
                Unknown_Command := False;
            else
                 Unknown_Command := True;
            end if;
        else
            Unknown_Command := True;
        end if;
        if Unknown_Command then -- Call the parent routine for default
processing:
               Claw.Dialog.Modal.When_Child_Notify (
                    Claw.Dialog.Modal.Modal_Dialog_Type(Window),
                    Code, Data, Control, Unknown_Command, Result_Value);
        end if;
   end When_Child_Notify;

(Note that calling the parent routine is harder to write and more likely
to break in Ada 95 than it really ought to be, because you have to
identify the parent type in it.  If the parent type changes, this call
may be wrong. I hope that the upcoming Amendment will address this
problem.)

           Randy.





  parent reply	other threads:[~2003-02-18 23:36 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
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 [this message]
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