Re: [AD] Filtered d_edit_proc() patch

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Evert Glebbeek a écrit :
> > The attached patch modifies d_edit_proc() so that you
> > can create fields that only accept numbers, capital
> > letters, etc. To do so, just write a filter callback
> > and set a pointer to it in the edit proc's dp2 field.
>
> Nice! I like this, and I don' think it would break existing code (existing
> addons may be a different story though). What do others think about this?
> Otherwise, d_edit_proc_ex() anyone? ;)

It could break any user proc that "inherits" from d_edit_proc:

   int my_edit_proc(int msg, DIALOG* d, int c)
   {
      BITMAP* background = d->dp2;
      if (msg == MSG_DRAW) {
         blit(background, screen, ...);
         textprintf(screen, d->dp, ...);
         return D_O_K;
      }
      return d_edit_proc(msg, d, c);
   }

The program will die a painful death when d_edit_proc tries to execute the 
bitmap in dp2 :-)

My personal opinion is that this would be better off in an add-on. One could 
easily be made with lots of improved procs like that. They could also be 
gathered into allegro.cc's code snippets section. However, I don't really 
mind if it goes in the library as d_edit_proc_ex. And I'm not using the GUI 
anymore anyway ;-p

> > The function is of the form:
> >    int edit_callback(int c, void *dp3);
>
> Any reason you're passing it dp3 and not, say, dp1?

The most flexible would be to pass the whole object. The user can then pick 
whatever info she needs.

    int edit_callback(int c, DIALOG* d);

-- 
Julien Cugnière




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/