Пример #1
0
// Initialise sizes for display window
void ARec::InitDrawRD()
{
   const int margin = 4;
   int textheight;
   int nlines;

   textheight = HTextHeight(win,"ABCD");

   x0 = margin; y0 = margin; x1 = width-margin;
   x2 = x0 + HTextWidth(win,"Status") + 2;
   x3 = x2+20;
   x4 = x3+ 2*margin;
   x5 = x4 + HTextWidth(win,"Time") + 2;
   x6 = x5 + HTextWidth(win,"9999.9s") + 2;
   x7 = x6 + HTextWidth(win,"Score") + 2;
   x8 = x7 + 40;
   x9 = x8 + 4*margin;
   x10 = x9 + HTextWidth(win,"HMM") + 4;
   x11 = x10 + HTextWidth(win,"aa-yy+bb") + 4;
   x12 = x11 + HTextWidth(win,"Nact") + 6;
   x13 = x12 + HTextWidth(win,"9999") + 6;
   x14 = x13 + HTextWidth(win,"Mode") + 4;
   y9 = height - margin;
   y8 = y9 - margin;
   y5 = y8 - margin;
   y4 = y5 - textheight - 1;
   y3 = y4 - margin;
   y6 = (int) (y3 - textheight*1.5);
   y1 = y6 - margin;
   y7 = y1 - margin-2;
   HSetFontSize(win,-14);
   textheight = HTextHeight(win,"ABCD");
   rdlyinc = textheight+2;
   HSetFontSize(win,0);
   nlines = (y7-y0) / rdlyinc; --nlines;
   rdly = y7 - nlines*rdlyinc;
   // paint background
   HSetGrey(win,PANELGREY2);
   HFillRectangle(win,0,0,width,height);
   // paint output panel
   HDrawPanel(win,x0,y0,x1,y1,PANELGREY1);
   // paint traceback panel
   HDrawPanel(win,x0,y6,x1,y3,PANELGREY1);
   // write labels
   HSetGrey(win,PANELGREY0);
   HPrintf(win,x0,y5,"Status");
   HPrintf(win,x4,y5,"Time");
   HPrintf(win,x6,y5,"Score");
   HPrintf(win,x9,y5,"HMM");
   HPrintf(win,x11,y5,"NAct");
   HPrintf(win,x13,y5,"Mode");
}
Пример #2
0
// Draw output line in main output box - char by char
void ARec::DrawOutLine(PhraseType k, HTime t, string wrd, string tag)
{
   char buf[1000];

   HSetFontSize(win,-14);
   switch(k){
   case Start_PT:
      ScrollOutBox();
      sprintf(buf,"%4.1f: ",t/1e7);
      rdline = string(buf);
      break;
   case OpenTag_PT:
      rdline = rdline + " (";
      break;
   case CloseTag_PT:  rdline = rdline + " )";
      if (tag != "") rdline = rdline + tag;
      break;
   case Null_PT:
      if (tag != "") rdline = rdline + " <"+tag+">";
      break;
   case Word_PT:
      rdline = rdline + " " + wrd;
      if (tag != "") rdline = rdline + "<"+tag+">";
      break;
   case End_PT:
      HSetColour(win,BLACK);
      HPrintf(win,x0+3,rdly,"%s",rdline.c_str());
      break;
   }
   int len,w = x1-x0-6;
   if (HTextWidth(win,rdline.c_str()) > w) {
      strcpy(buf,rdline.c_str());
      do {
         len = strlen(buf); --len;
         assert(len>5);
         buf[len] = '\0';
      } while (HTextWidth(win,buf) > w);
      HSetColour(win,BLACK);
      HPrintf(win,x0+3,rdly,"%s",buf);
      ScrollOutBox();
      rdline.erase(0,len);
      rdline = "   " + rdline;
   }
   HSetFontSize(win,0);
}
Пример #3
0
/* EXPORT-> MakeXGraf: Connect to the X-server and init globals */
void MakeXGraf(char *wname, int x, int y, int w, int h, int bw)
{
   char sbuf[MAXSTRLEN], *hgraf = "HGraf";
   Window window, parent;
   XSetWindowAttributes setwinattr;
   unsigned long vmask;
   
   if (winCreated)
      HError(6870, "MakeXGraf: Attempt to recreate the graphics window");
   if ((theDisp = XOpenDisplay(NULL)) == NULL)
      HError(6870, "MakeXGraf: cannot connect to X server %s", XDisplayName(NULL));
   InitGlobals();
   InstallFonts();
   InstallColours();
   parent = RootWindow(theDisp, theScreen);
   window = XCreateSimpleWindow(theDisp, parent, x, y, w, h, bw, black, white );
   /* allow for backing up the contents of the window */
   vmask = CWBackingStore;  setwinattr.backing_store = WhenMapped;
   XChangeWindowAttributes(theDisp, window, vmask, &setwinattr);
   /* set the size hints for the window manager */
   hints.flags = PPosition | PSize | PMaxSize | PMinSize;
   hints.y = y;              hints.x = x;
   hints.width  = w;         hints.height = h;
   hints.min_width  = w;     hints.min_height = h;
   hints.max_width  = w;     hints.max_height = h;
   /* compose the name of the window */
   strcpy(sbuf, hgraf);  strcat(sbuf, ": ");  strcat(sbuf, wname);
   XSetStandardProperties(theDisp, window, sbuf, hgraf, None, NULL, 0, &hints);
   /* select events to receive */
   XSelectInput(theDisp, window, ExposureMask | KeyPressMask | ButtonPressMask | 
                ButtonReleaseMask | PointerMotionHintMask | PointerMotionMask);
   XMapWindow(theDisp, theWindow = window);
   InitGCs(); 
   HSetXMode(GCOPY); HSetFontSize(0); HSetLineWidth(0); HSetColour(BLACK);
   /* wait for the first expose event - cannot draw before it has arrived */
   do 
      XNextEvent(theDisp, &report); 
   while (report.type != Expose);
   XSendEvent(theDisp,window,False,ExposureMask,&report);
   /* Create heap for buttons */
   CreateHeap(&btnHeap, "Button heap", MHEAP, sizeof(HButton), 1.0, 100, 100);
   winCreated = TRUE;
}