[AD] GUI system

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


Could the check box procedure be modified so that the check box be to the left of the text instead of to the right ?
I would propose using d1 (unless anybody stores something in it; then again, having a procedure d_leftcheck_proc.

Here is my modified d_check_proc, using d1:
/* d_check_proc:
 *  Who needs C++ after all? This is derived from d_button_proc, 
 *  but overrides the drawing routine to provide a check box.
 *  If d1 is set, the check box is to the left of the text, otherwise it
*   is to the right.
 */
int d_check_proc(int msg, DIALOG *d, int c)
{
   int x;
   int fg;

   if (msg==MSG_DRAW) {
      fg = (d->flags & D_DISABLED) ? gui_mg_color : d->fg;
      text_mode(d->bg);
      x = d->x + (d->d1 ? 0 : gui_textout(screen, d->dp, d->x, d->y+(d->h-(text_height(font)-gui_font_baseline))/2, fg, FALSE) + text_height(font)/2);
      rectfill(screen, x+1, d->y+1, x+d->h-1, d->y+d->h-1, d->bg);
      rect(screen, x, d->y, x+d->h, d->y+d->h, fg);
      if (d->d1) 
         gui_textout(screen, d->dp, x + d->h + text_height(font)/2, d->y+(d->h-(text_height(font)-gui_font_baseline))/2, fg, FALSE);
      if (d->flags & D_SELECTED) {
	 line(screen, x, d->y, x+d->h, d->y+d->h, fg);
	 line(screen, x, d->y+d->h, x+d->h, d->y, fg); 
      }
      if (d->flags & D_GOTFOCUS)
	 dotted_rect(x+1, d->y+1, x+d->h-1, d->y+d->h-1, fg, d->bg);
      return D_O_K;
   } 

   return d_button_proc(msg, d, 0);
}


Also, would it be possible to split D_DISABLED into something like D_INACTIVE and D_GREYEDOUT.
What I would like to do is a self hiding/unhiding button. my code looks like this:

int d_mybutton_proc(...) {
   DIALOG *di = (DIALOG*)d->dp2;
   int r=0;
   if (di->flags & D_SELECTED) {
       d->flags&=~D_DISABLED; r=1;
   }
   else {
        d->flags|=D_DISABLED; r=1;
   }
   int ret = d_button_proc(r?MSG_DRAW:msg, d, c);
   if (ret == D_CLOSE) {
    //...
   }
   return D_O_K;
}

The problem is if I use D_DISABLED, the button doesn't get messaged anymore so it stops working...

Thanks in advanced.







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