# include "Ximage.h"

void UpdateStatusBox (Graphic *graphic, KapaImageWidget *image, double x, double y, double z, int mode) {

  int textpad;
  double ra, dec; 
  char line[100];

  XY_to_RD (&ra, &dec, x, y, &image[0].coords);

  textpad = graphic[0].font[0].ascent;

  if (mode) {
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
    XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
		    image[0].text_x, image[0].text_y, image[0].text_dx, image[0].text_dy);  
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
    XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
		    image[0].text_x, image[0].text_y, image[0].text_dx, image[0].text_dy);
  
    bzero (line, 100);
    sprintf (line, "(%d x %d) @ %d                                         ", 
	     image[0].picture.dx, image[0].picture.dy, image[0].expand); 
    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
		 image[0].text_x + PAD1, image[0].text_y + 4*textpad + 4*PAD1, line, 25);
    
    bzero (line, 100);
    sprintf (line, "%-25s", image[0].file); 
    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
		 image[0].text_x + PAD1, image[0].text_y + 5*textpad + 5*PAD1, line, strlen(line));
    
    bzero (line, 100);
    sprintf (line, "(%s)                                          ", image[0].name); 
    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
		 image[0].text_x + PAD1, image[0].text_y + 6*textpad + 6*PAD1, line, 25);
    
  } else {
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].back);
    XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
		    image[0].text_x+1, image[0].text_y+1, image[0].text_dx-2, image[0].text_dy-2);  
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].fore);
  }
  bzero (line, 100);
  sprintf (line, "%22.3f", z);
  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
	       image[0].text_x + PAD1, image[0].text_y + textpad + PAD1, line, strlen(line));
  
  bzero (line, 100);
  sprintf (line, "%10.1f %10.1f", x, y);
  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
	       image[0].text_x + PAD1, image[0].text_y + 2*textpad + 2*PAD1, line, strlen(line));
  
  bzero (line, 100);
  if (image[0].DecimalDegrees) {
    sprintf (line, "%10.6f %10.6f", ra, dec); 
  } else {
    hh_hms (line, ra, dec, ':');
  }
  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
	       image[0].text_x + PAD1, image[0].text_y + 3*textpad + 3*PAD1, line, strlen(line));
}
