comp.lang.ada
 help / color / mirror / Atom feed
From: "Lucretia" <lucretia9@lycos.co.uk>
Subject: Re: Event mechanisms for GUI's
Date: 19 Oct 2006 07:22:09 -0700
Date: 2006-10-19T07:22:09-07:00	[thread overview]
Message-ID: <1161267729.431982.31510@f16g2000cwb.googlegroups.com> (raw)
In-Reply-To: <RDDYg.241018$1i1.47250@attbi_s72>



On Oct 16, 5:11 am, "Jeffrey R. Carter"
<spam.not.jrcar...@acm.not.spam.org> wrote:
> Lucretia wrote:
>
> > So, on creation you specify which events you want via some sort of
> > bitmask?I would think there would be a default set, to which you could add or
> subtract events or sets of events, as well as specifying a complete set
> of events.

The only way I can see of doing this (unless you want to supply some
code to illustrate) is by providing the listener idiom and separating
each listener "handler" into a separate interfaces (Ada 2005) and then
providing a Set_Events_Mask on the component which goes through the bit
mask and checks if there are interfaces set for the particular events:

package Button_Up_Listeners is

  type Button_Up_Listener is interface;

  procedure Button_Up(Component : in Button; Event : in Button_Event);

end Button_Up_Listeners;


package Button_Down_Listeners is

  type Button_Down_Listener is interface;

  procedure Button_Down(Component : in Button; Event : in
Button_Event);

end Button_Down_Listeners;


package Buttons is

  type Button_Events_Mask is (Up, Down, Double_Click, ...);
  for Button_Events_Mask use ...;

  Button_Events_Mask_Error : exception;

  type Button is new Control with private;

  procedure Set_Button_Up_LIstener(Self : in out Button; Listener : in
Button_Up_Listener);
  procedure Set_Button_Down_LIstener(Self : in out Button; Listener :
in Button_Down_Listener);

  -- This raises Button_Events_Mask_Error
  procedure Set_Bit_Mask(Self : in out Button; Mask : in
Button_Events_Mask);

end Buttons;

package My_Button_Listeners is

  type My_Button_Listener is Button_Up_Listener and
Button_Down_Listener;

  ...

end My_Button_Listeners;


procedure Test_Button is

  My_Button : Button;

begin

  My_Button.Set_Button_Up_LIstener(My_Button_Listener);
  My_Button.Set_Bit_Mask(Up or Down); -- raises exception!

end Test_Button;

But there are problems with this:

1) use of multiple interfaces just to provide 1 "event handler" over
the use of 1 listener interface which provides all "event handlers"
which are specified as null procedures so that the user can override
the ones (s)he is interested in.

2) the user may forget to do the test (the Set_Bit_Mask call).

Thanks,
Luke.




  reply	other threads:[~2006-10-19 14:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-26 17:28 Event mechanisms for GUI's Lucretia
2006-09-26 20:39 ` Jeffrey R. Carter
2006-09-26 23:18   ` tmoran
2006-09-27  3:02     ` Jeffrey R. Carter
2006-09-27  4:26       ` tmoran
2006-09-27  5:39         ` Jeffrey R. Carter
2006-09-27  6:21       ` Lucretia
2006-09-27 21:29         ` Jeffrey R. Carter
2006-09-27 23:05           ` Randy Brukardt
2006-09-28  3:47             ` Jeffrey R. Carter
2006-09-28  4:15               ` tmoran
2006-09-29  3:16               ` Randy Brukardt
2006-10-14 19:25               ` Lucretia
2006-10-15  1:22                 ` Jeffrey R. Carter
2006-10-15  2:29                   ` Lucretia
2006-10-16  4:11                     ` Jeffrey R. Carter
2006-10-19 14:22                       ` Lucretia [this message]
2006-10-19 15:04                         ` Dmitry A. Kazakov
2006-10-19 20:18                         ` Jeffrey R. Carter
2006-10-19 21:51                           ` Lucretia
2006-10-19 22:01                             ` Lucretia
2006-10-20  4:48                             ` Jeffrey R. Carter
2006-10-15 13:53                   ` Ed Falis
2006-10-16  4:19                     ` Jeffrey R. Carter
2006-10-14 19:44             ` Lucretia
2006-09-27  8:10 ` Dmitry A. Kazakov
replies disabled

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