# include "Ximage.h"

// define the section, but do not create a graph or image 
int DefineSection (int sock) {
  
  int N, MoveSection, bg;
  char name[128];
  double x, y, dx, dy;
  Section *section;

  KiiScanMessage (sock, "%s %lf %lf %lf %lf %d", name, &x, &y, &dx, &dy, &bg);

  MoveSection = FALSE;

  N = GetSectionByName (name);
  if (N < 0) {
    section = AddSection (name, x, y, dx, dy, bg);
    MoveSection = TRUE;
  } else {
    section = GetSectionByNumber (N);
    SetActiveSectionByNumber (N);

    if (section[0].x != x)   MoveSection = TRUE;
    if (section[0].y != y)   MoveSection = TRUE;
    if (section[0].dx != dx) MoveSection = TRUE;
    if (section[0].dy != dy) MoveSection = TRUE;

    section[0].x = x;
    section[0].y = y;
    section[0].dx = dx;
    section[0].dy = dy;
    section[0].bg = bg;
  }

  if (MoveSection) {
    SetSectionSizes (section);
    Refresh ();
  }

  return (TRUE);
}
