# include "Ximage.h"

static char *GREY = "greyscale";
static char *PUNS = "Puns";
static char *RAINBOW = "Rainbow";

int greycolors (Graphic *graphic, Layout *layout) {
  char *name;
  name = GREY;
  SetColormap (graphic, layout, name);
  CreateColorbar (layout, graphic);
  Remap (graphic, layout, &layout[0].matrix);
  CreateZoom (layout, graphic, 0, 0); 
  return (TRUE);
}

int puns (Graphic *graphic, Layout *layout) {
  char *name;
  name = PUNS;
  SetColormap (graphic, layout, name);
  CreateColorbar (layout, graphic);
  Remap (graphic, layout, &layout[0].matrix);
  CreateZoom (layout, graphic, 0, 0); 
  return (TRUE);
}

int rainbow (Graphic *graphic, Layout *layout) {
  char *name;
  name = RAINBOW;
  SetColormap (graphic, layout, name);
  CreateColorbar (layout, graphic);
  Remap (graphic, layout, &layout[0].matrix);
  CreateZoom (layout, graphic, 0, 0); 
  return (TRUE);
}

int Recenter (Graphic *graphic, Layout *layout) {

  layout[0].X = 0;
  layout[0].Y = 0;
 
  Remap (graphic, layout, &layout[0].matrix);
  Refresh (graphic, layout, 0);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Rescale (Graphic *graphic, Layout *layout) {

  layout[0].expand = 1;
  Remap (graphic, layout, &layout[0].matrix);
  Refresh (graphic, layout, 0);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int RecenterRescale (Graphic *graphic, Layout *layout) {

  layout[0].X = 0;
  layout[0].Y = 0;
  layout[0].expand = 1;
 
  Remap (graphic, layout, &layout[0].matrix);
  Refresh (graphic, layout, 0);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int ToggleDEG (Graphic *graphic, Layout *layout) {

  DECIMAL_DEG = DECIMAL_DEG ^ TRUE;
  StatusBox (graphic, layout);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

/*********** overlay_button functions ************/
int Overlay0 (Graphic *graphic, Layout *layout) {

  OVERLAY[0] = OVERLAY[0] ^ TRUE;
  Refresh (graphic, layout, 0);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Overlay1 (Graphic *graphic, Layout *layout) {

  OVERLAY[1] = OVERLAY[1] ^ TRUE;
  Refresh (graphic, layout, 0);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Overlay2 (Graphic *graphic, Layout *layout) {

  OVERLAY[2] = OVERLAY[2] ^ TRUE;
  Refresh (graphic, layout, 0);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

int Overlay3 (Graphic *graphic, Layout *layout) {

  OVERLAY[3] = OVERLAY[3] ^ TRUE;
  Refresh (graphic, layout, 0);
  FlushDisplay (graphic[0].display);
  return (TRUE);

}

/* this routine is NOT independent of the number of overlays */


