# include "Ximage.h" 
# include "buttons.h"
# define BUTTON_WIDTH 28
# define BUTTON_HEIGHT 28

void PositionPictures (Layout *layout, Graphic *graphic) {

  layout[0].cmapbar.dx = graphic[0].dx - 2*PAD1; 
  layout[0].cmapbar.dy = COLORPAD;
  layout[0].cmapbar.x = PAD1;
  layout[0].cmapbar.y = PAD1;

  layout[0].zoom.dx = ZOOM_X; 
  layout[0].zoom.dy = ZOOM_Y;
  layout[0].zoom.x = graphic[0].dx - PAD1 - ZOOM_X;
  layout[0].zoom.y = layout[0].cmapbar.y + layout[0].cmapbar.dy + PAD2;

  layout[0].picture.dx = layout[0].zoom.x - 2*PAD1 - 25; 
  layout[0].picture.dy = graphic[0].dy - 2*PAD1 - PAD2 - COLORPAD - 25;
  layout[0].picture.x = PAD1 + 25;
  layout[0].picture.y = PAD1 + PAD2 + COLORPAD;

  /** everything below is tied in x-dir to the zoom box **/
  layout[0].text_x = layout[0].zoom.x;
  layout[0].text_y = layout[0].zoom.y + layout[0].zoom.dy + PAD2;

  /*  layout[0].PS_button.y = graphic[0].dy - BUTTON_HEIGHT - PAD1; */
  layout[0].PS_button.x = layout[0].zoom.x + 5;
  layout[0].PS_button.y = 2*ZOOM_Y;
  layout[0].PS_button.dx = BUTTON_WIDTH;
  layout[0].PS_button.dy = BUTTON_HEIGHT;
  layout[0].PS_button.text = FALSE;
  layout[0].PS_button.width = PS_width;
  layout[0].PS_button.height = PS_height;
  layout[0].PS_button.bitmap = PS_bits;
  layout[0].PS_button.function_1 = PSit;
  layout[0].PS_button.function_2 = PSit;
  layout[0].PS_button.function_3 = PSit;

  /** everything below is tied to the PS_button in y-dir **/
  layout[0].grey_button.x = layout[0].PS_button.x + layout[0].PS_button.dx + PAD1;
  layout[0].grey_button.y = layout[0].PS_button.y;
  layout[0].grey_button.dx = BUTTON_WIDTH;
  layout[0].grey_button.dy = BUTTON_HEIGHT;
  layout[0].grey_button.text = FALSE;
  layout[0].grey_button.width = grey_width;
  layout[0].grey_button.height = grey_height;
  layout[0].grey_button.bitmap = grey_bits;
  layout[0].grey_button.function_1 = greycolors;
  layout[0].grey_button.function_2 = greycolors;
  layout[0].grey_button.function_3 = greycolors;

  layout[0].rainbow_button.x = layout[0].grey_button.x + layout[0].grey_button.dx + PAD1;
  layout[0].rainbow_button.y = layout[0].PS_button.y;
  layout[0].rainbow_button.dx = BUTTON_WIDTH;
  layout[0].rainbow_button.dy = BUTTON_HEIGHT;
  layout[0].rainbow_button.text = FALSE;
  layout[0].rainbow_button.width = rainbow_width;
  layout[0].rainbow_button.height = rainbow_height;
  layout[0].rainbow_button.bitmap = rainbow_bits;
  layout[0].rainbow_button.function_1 = rainbow;
  layout[0].rainbow_button.function_2 = rainbow;
  layout[0].rainbow_button.function_3 = rainbow;

  layout[0].puns_button.x = layout[0].rainbow_button.x + layout[0].rainbow_button.dx + PAD1;
  layout[0].puns_button.y = layout[0].PS_button.y;
  layout[0].puns_button.dx = BUTTON_WIDTH;
  layout[0].puns_button.dy = BUTTON_HEIGHT;
  layout[0].puns_button.text = FALSE;
  layout[0].puns_button.width = puns_width;
  layout[0].puns_button.height = puns_height;
  layout[0].puns_button.bitmap = puns_bits;
  layout[0].puns_button.function_1 = puns;
  layout[0].puns_button.function_2 = puns;
  layout[0].puns_button.function_3 = puns;

  layout[0].recenter_button.x = layout[0].puns_button.x + layout[0].puns_button.dx + PAD1;
  layout[0].recenter_button.y = layout[0].PS_button.y;
  layout[0].recenter_button.dx = BUTTON_WIDTH;
  layout[0].recenter_button.dy = BUTTON_HEIGHT;
  layout[0].recenter_button.text = FALSE;
  layout[0].recenter_button.width = recenter_width;
  layout[0].recenter_button.height = recenter_height;
  layout[0].recenter_button.bitmap = recenter_bits;
  layout[0].recenter_button.function_1 = Recenter;
  layout[0].recenter_button.function_2 = RecenterRescale;
  layout[0].recenter_button.function_3 = Rescale;

  layout[0].overlay_button[0].x = layout[0].zoom.x + 5;
  layout[0].overlay_button[0].y = layout[0].PS_button.y - BUTTON_HEIGHT - PAD1;
  layout[0].overlay_button[0].dx = BUTTON_WIDTH;
  layout[0].overlay_button[0].dy = BUTTON_HEIGHT;
  layout[0].overlay_button[0].text = FALSE;
  layout[0].overlay_button[0].width = red_width;
  layout[0].overlay_button[0].height = red_height;
  layout[0].overlay_button[0].bitmap = red_bits;
  layout[0].overlay_button[0].function_1 = Overlay0;
  layout[0].overlay_button[0].function_2 = Overlay0;
  layout[0].overlay_button[0].function_3 = Overlay0;
		   	   
  layout[0].overlay_button[1].x = layout[0].overlay_button[0].x + layout[0].overlay_button[0].dx + PAD1;
  layout[0].overlay_button[1].y = layout[0].PS_button.y - BUTTON_HEIGHT - PAD1;
  layout[0].overlay_button[1].dx = BUTTON_WIDTH;
  layout[0].overlay_button[1].dy = BUTTON_HEIGHT;
  layout[0].overlay_button[1].text = FALSE;
  layout[0].overlay_button[1].width = green_width;
  layout[0].overlay_button[1].height = green_height;
  layout[0].overlay_button[1].bitmap = green_bits;
  layout[0].overlay_button[1].function_1 = Overlay1;
  layout[0].overlay_button[1].function_2 = Overlay1;
  layout[0].overlay_button[1].function_3 = Overlay1;

  layout[0].overlay_button[2].x = layout[0].overlay_button[1].x + layout[0].overlay_button[1].dx + PAD1;
  layout[0].overlay_button[2].y = layout[0].PS_button.y - BUTTON_HEIGHT - PAD1;
  layout[0].overlay_button[2].dx = BUTTON_WIDTH;
  layout[0].overlay_button[2].dy = BUTTON_HEIGHT;
  layout[0].overlay_button[2].text = FALSE;
  layout[0].overlay_button[2].width = blue_width;
  layout[0].overlay_button[2].height = blue_height;
  layout[0].overlay_button[2].bitmap = blue_bits;
  layout[0].overlay_button[2].function_1 = Overlay2;
  layout[0].overlay_button[2].function_2 = Overlay2;
  layout[0].overlay_button[2].function_3 = Overlay2;
		   	   
  layout[0].overlay_button[3].x = layout[0].overlay_button[2].x + layout[0].overlay_button[2].dx + PAD1;
  layout[0].overlay_button[3].y = layout[0].PS_button.y - BUTTON_HEIGHT - PAD1;
  layout[0].overlay_button[3].dx = BUTTON_WIDTH;
  layout[0].overlay_button[3].dy = BUTTON_HEIGHT;
  layout[0].overlay_button[3].text = FALSE;
  layout[0].overlay_button[3].width = yellow_width;
  layout[0].overlay_button[3].height = yellow_height;
  layout[0].overlay_button[3].bitmap = yellow_bits;
  layout[0].overlay_button[3].function_1 = Overlay3;
  layout[0].overlay_button[3].function_2 = Overlay3;
  layout[0].overlay_button[3].function_3 = Overlay3;

  layout[0].hms_button.x = layout[0].overlay_button[3].x + layout[0].overlay_button[3].dx + PAD1;
  layout[0].hms_button.y = layout[0].PS_button.y - BUTTON_HEIGHT - PAD1;
  layout[0].hms_button.dx = BUTTON_WIDTH;
  layout[0].hms_button.dy = BUTTON_HEIGHT;
  layout[0].hms_button.text = FALSE;
  layout[0].hms_button.width = hms_width;
  layout[0].hms_button.height = hms_height;
  layout[0].hms_button.bitmap = hms_bits;
  layout[0].hms_button.function_1 = ToggleDEG;
  layout[0].hms_button.function_2 = ToggleDEG;
  layout[0].hms_button.function_3 = ToggleDEG;

}


/* this routine is dependent on the number of Overlays */
