# include "Ximage.h"

int LoadPtext () {
  
  char *string;
  int N, size;
  double tX, tY, tT, L;
  Layout *layout;
  
  layout = &section[TheSection];
  
  fcntl (sock, F_SETFL, !O_NONBLOCK);  
  
  layout[0].Nptext = MAX (layout[0].Nptext, 0);
  N = layout[0].Nptext;
  layout[0].Nptext++;
  REALLOCATE (layout[0].ptext, Label, layout[0].Nptext);

  KiiScanMessage (sock, "%lf %lf %lf", &tX, &tY, &tT);

  L = layout[0].axis[0].dfx;
  layout[0].ptext[N].x = L * (tX - layout[0].axis[0].min) / (layout[0].axis[0].max - layout[0].axis[0].min) + layout[0].axis[0].fx;

  L = layout[0].axis[1].dfy;
  layout[0].ptext[N].y = L * (tY - layout[0].axis[1].min) / (layout[0].axis[1].max - layout[0].axis[1].min) + layout[0].axis[1].fy;

  layout[0].ptext[N].angle = tT;

  bzero (layout[0].ptext[N].text, LABEL_MAXLEN);

  string = KiiRecvData (sock);
  strcpy (layout[0].ptext[N].text, string);
  free (string);

  fcntl (sock, F_SETFL, O_NONBLOCK);  
  
  string = GetRotFont (&size);
  layout[0].ptext[N].size = size;
  strcpy (layout[0].ptext[N].font, string);

  if (USE_XWINDOW) DrawPtext (layout);
  
  FlushDisplay ();
  
  return (TRUE);
  
}
