# include "Ximage.h"

void UpdateStatusBox (Graphic *graphic, Layout *layout, double x, double y, double z, int mode) {

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

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

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

  if (mode) {
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].white);
    XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
		    layout[0].text_x, layout[0].text_y, ZOOM_X, 6*textpad+7*PAD1);  
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].black);
    XDrawRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
		    layout[0].text_x, layout[0].text_y, ZOOM_X, 6*textpad+7*PAD1);
  
    bzero (line, 100);
    sprintf (line, "(%d x %d) @ %d                                         ", 
	     layout[0].picture.dx, layout[0].picture.dy, layout[0].expand); 
    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
		 layout[0].text_x + PAD1, layout[0].text_y + 4*textpad + 4*PAD1, line, 25);
    
    bzero (line, 100);
    sprintf (line, "%-25s", layout[0].file); 
    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
		 layout[0].text_x + PAD1, layout[0].text_y + 5*textpad + 5*PAD1, line, strlen(line));
    
    bzero (line, 100);
    sprintf (line, "(%s)                                          ", layout[0].buffer_name); 
    XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
		 layout[0].text_x + PAD1, layout[0].text_y + 6*textpad + 6*PAD1, line, 25);
    
  } else {
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].white);
    XFillRectangle (graphic[0].display, graphic[0].window, graphic[0].gc,
		    layout[0].text_x + 1, layout[0].text_y + 1, ZOOM_X - 2, 3*textpad+3*PAD1 +1);  
    XSetForeground (graphic[0].display, graphic[0].gc, graphic[0].black);
  }
  bzero (line, 100);
  sprintf (line, "%25.3f", z);
  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
	       layout[0].text_x + PAD1, layout[0].text_y + textpad + PAD1, line, strlen(line));
  
  bzero (line, 100);
  sprintf (line, "%12.1f %12.1f", x, y);
  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
	       layout[0].text_x + PAD1, layout[0].text_y + 2*textpad + 2*PAD1, line, strlen(line));
  
  bzero (line, 100);
  if (DECIMAL_DEG) {
    sprintf (line, "%12.6f %12.6f", ra, dec); 
  } else {
    hh_hms (line, ra, dec, ':');
  }
  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
	       layout[0].text_x + PAD1, layout[0].text_y + 3*textpad + 3*PAD1, line, strlen(line));
  
 
}
