/*
 *  TOGGLEBUTTON.C
 */

#include "newlook.h"

extern UWORD RemoveGadget( struct Window *, struct Gadget * );
extern VOID RefreshGList( struct Gadget *, struct Window *, struct Requester *, UWORD );
extern UWORD AddGadget( struct Window *, struct Gadget *, UWORD );

void ToggleButton(struct Window *w, struct Gadget *g)
{ UWORD pos= RemoveGadget(w,g);
  RefreshGList(g,w,0L,1L);
  g->Flags ^= SELECTED;
  if(pos!=0xFFFF) /* 0xFFFF == (-1)  did we really remove the gadget? */
    AddGadget(w,g,pos); /* 0xFFFF == (-1) */
  RefreshGList(g,w,0L,1L);
}
