Esempio n. 1
0
static gmx_bool xrCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
{
    t_app   *app;
    t_xrama *xr;
    char     buf[256];
    int      i;

    (void)XTextHeight(x11->font);
    app = (t_app *)data;
    xr  = app->xr;
    scx = app->xrwd.width/(2.0*M_PI);
    scy = app->xrwd.height/(2.0*M_PI);
    switch (event->type)
    {
        case Expose:
            XClearWindow(x11->disp, app->xrwd.self);
            XDrawLine(x11->disp, app->xrwd.self, x11->gc,
                      SX(0), SY(-M_PI)+1, SX(0), SY(M_PI)-1);
            XDrawLine(x11->disp, app->xrwd.self, x11->gc,
                      SX(-M_PI)+1, SY(0), SX(M_PI)-1, SY(0));
            TextInRect(x11, app->xrwd.self, "Phi", SX(M_PI)-50, SY(0)+4, 46, 20, eXRight, eYTop);
            TextInRect(x11, app->xrwd.self, "Psi", SX(0)+4, 4, 46, 20, eXLeft, eYTop);
            for (i = 0; (i < xr->npp); i++)
            {
                if (app->bShowGly || !app->bIsGly[i])
                {
                    plot_pp(x11, app->xrwd.self, &(xr->pp[i]), xr->dih);
                }
            }
            break;
        case ButtonPress:
            if (label_pp(x11, app->xrwd.self, xr->npp, xr->pp, xr->dih,
                         event->xbutton.x, event->xbutton.y))
            {
                ExposeWin(x11->disp, app->xrwd.self);
            }
            break;
        case ConfigureNotify:
            app->xrwd.width  = event->xconfigure.width;
            app->xrwd.height = event->xconfigure.height;
            break;
    }
    if (app->status == esGo)
    {
        if (!new_data(app->xr))
        {
            app->status = ebStop;
        }
        else
        {
            ExposeWin(x11->disp, app->xrwd.self);
            sprintf(buf, "Rama: t=%.2f", app->xr->t);
            XSetStandardProperties(x11->disp, app->wd.self, buf,
                                   "Rama", 0, NULL, 0, NULL);

        }
    }
    return FALSE;
}
Esempio n. 2
0
static int WndProcBN(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
{
    t_windata *win;
    int        x, w, th;

    if (dlgitem->type != edlgBN)
    {
        gmx_incons("button processing");
    }
    win = &(dlgitem->win);
    w   = XTextWidth(x11->font, win->text, strlen(win->text));
    x   = (win->width-w)/2;
    th  = XTextHeight(x11->font)+OFFS_Y;
    switch (event->type)
    {
        case Expose:
            RectWin(x11->disp, x11->gc, win, x11->fg);
            TextInRect(x11, win->self, win->text, 0, 0, win->width, th, eXCenter, eYCenter);
            break;
        case ButtonPress:
            return BNPRESSED;
        case EnterNotify:
            XDrawLine(x11->disp, win->self, x11->gc, x-1, th, x+w, th);
            break;
        case LeaveNotify:
            XSetForeground(x11->disp, x11->gc, x11->bg);
            XDrawLine(x11->disp, win->self, x11->gc, x-1, th, x+w, th);
            XSetForeground(x11->disp, x11->gc, x11->fg);
            break;
        default:
            return DefWndProc(x11, dlgitem, event);
    }
    return ITEMOK;
}
Esempio n. 3
0
static void DrawLegend(t_x11 *x11, t_windata *Win)
{
#define NLAB 6
#define COLS 3
    static const char *lab[NLAB] = { "C", "O", "H", "S", "N", "P" };
    int                i, i0, dh, dw, w, y, x1, x0;
    unsigned long      cind;
    real               h_2;

    XClearWindow(x11->disp, Win->self);
    w   = Win->width;
    h_2 = Win->height/(2.0*NLAB/COLS);
    dh  = h_2-2;
    dw  = dh;

    for (i = 0; (i < NLAB); i++)
    {
        i0   = i % (NLAB/COLS);
        x0   = (i / (NLAB/COLS))*(Win->width/COLS)+AIR;
        x1   = x0+2*dw+AIR;
        cind = Type2Color(lab[i]);
        XSetForeground(x11->disp, x11->gc, cind);
        y = ((2*i0+1)*h_2);
        XFillRectangle (x11->disp, Win->self, x11->gc, x0, y-dh, 2*dw, 2*dh);
        XSetForeground(x11->disp, x11->gc, WHITE);
        TextInRect(x11, Win->self, lab[i], x1, y-dh, w-x1, 2*dh,
                   eXLeft, eYCenter);
    }
    XSetForeground(x11->disp, x11->gc, x11->fg);
}
Esempio n. 4
0
static int WndProcST(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
{
    t_statictext *st;
    t_windata    *win;
    int           i, dy;

    if (dlgitem->type != edlgST)
    {
        gmx_incons("st processing");
    }
    st  = &(dlgitem->u.statictext);
    win = &(dlgitem->win);

    switch (event->type)
    {
        case Expose:
            dy = XTextHeight(x11->font)+OFFS_Y;
            for (i = 0; (i < st->nlines); i++)
            {
                TextInRect(x11, win->self, st->lines[i],
                           0, OFFS_Y+i*dy, win->width, dy, eXLeft, eYCenter);
            }
            break;
        default:
            return DefWndProc(x11, dlgitem, event);
    }
    return ITEMOK;
}
Esempio n. 5
0
static int WndProcGB(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
{
    t_windata *win;
    int        x, y;

    if (dlgitem->type != edlgGB)
    {
        gmx_incons("gb processing");
    }
    win = &(dlgitem->win);

    x = XTextWidth(x11->font, win->text, strlen(win->text));
    y = XTextHeight(x11->font);
    switch (event->type)
    {
        case Expose:
            XSetForeground(x11->disp, x11->gc, x11->fg);
            XDrawRoundRect(x11->disp, win->self, x11->gc, 0, y/2,
                           win->width-1, win->height-y/2-1);
            XClearArea(x11->disp, win->self, OFFS_X, 0, x+OFFS_X, y, False);
            TextInRect(x11, win->self, win->text, 2*OFFS_X, 0, x, y, eXCenter, eYCenter);
            break;
        case EnterNotify:
        case LeaveNotify:
            break;
        default:
            return DefWndProc(x11, dlgitem, event);
    }
    return ITEMOK;
}
Esempio n. 6
0
static void plot_pp(t_x11 *x11,Window w,t_phipsi *pp,t_dih dih[])
{
  int x0,y0;
  int th=(XTextHeight(x11->font)+6)/2;
  
  x0=SX(dih[pp->iphi].ang);
  y0=SY(dih[pp->ipsi].ang);
  XFillRectangle(x11->disp,w,x11->gc,x0-1,y0-1,4,4);
  /* Draw Label ? */
  if (pp->bShow) 
    TextInRect(x11,w,pp->label,x0+6,y0-th,30,2*th,eXLeft,eYCenter);
}
Esempio n. 7
0
static int WndProcRB(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
{
    t_radiobutton *rb;
    t_windata     *win;
    int            x, y, rad;

    if (dlgitem->type != edlgRB)
    {
        gmx_incons("radiobutton processing");
    }
    rb  = &(dlgitem->u.radiobutton);
    win = &(dlgitem->win);

    rad = win->height/3;
    x   = rad;
    y   = win->height/2;
    switch (event->type)
    {
        case Expose:
            XClearArea(x11->disp, win->self, x-rad, y-rad, x+rad, y+rad, False);
            if (rb->bSelect)
            {
                /* Filled */
                XFillCircle(x11->disp, win->self, x11->gc, x, y, rad);
            }
            XDrawCircle(x11->disp, win->self, x11->gc, x, y, rad);
            x += rad+OFFS_X;
            TextInRect(x11, win->self, win->text, x, 0, win->width-x, win->height,
                       eXLeft, eYCenter);
            break;
        case ButtonPress:
            if (!rb->bSelect)
            {
                return RBPRESSED;
            }
            XBell(x11->disp, 50);
            break;
        case EnterNotify:
        case LeaveNotify:
            break;
        default:
            return DefWndProc(x11, dlgitem, event);
    }
    return ITEMOK;
}
Esempio n. 8
0
static gmx_bool VBCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
    t_butbox  *vbox;
    int        y0;

    if (event->type == Expose)
    {
        vbox = (t_butbox *)data;
        y0   = XTextHeight(x11->font)+2*AIR+1;
        XSetForeground(x11->disp, x11->gc, WHITE);
        XClearArea(x11->disp, vbox->wd.self, 1, 1, vbox->wd.width-2, y0-1, False);
        TextInRect(x11, vbox->wd.self, vbox->wd.text,
                   1, 1, vbox->wd.width-2, y0-1, eXLeft, eYCenter);
        XDrawLine(x11->disp, vbox->wd.self, x11->gc, 0, y0, vbox->wd.width, y0);
        XSetForeground(x11->disp, x11->gc, x11->fg);
    }
    return FALSE;
}
Esempio n. 9
0
gmx_bool ChildCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
    t_child   *child;
    t_mentry  *m;
    t_windata *wd;
    XEvent     letter;

    child = (t_child *)data;
    m     = child->m;
    wd    = &(child->wd);
    switch (event->type)
    {
        case Expose:
            XSetForeground(x11->disp, x11->gc, x11->fg);
            TextInRect(x11, w, m->str, 16, 0, wd->width-16-2, wd->height-2,
                       eXLeft, eYCenter);
            if (m->bChecked)
            {
                int y = x11->font->ascent;
                XDrawLine(x11->disp, w, x11->gc, 2, (y*2)/3, 6, y);
                XDrawLine(x11->disp, w, x11->gc, 3, (y*2)/3, 7, y);
                XDrawLine(x11->disp, w, x11->gc, 7, y, 12, 2);
            }
            break;
        case EnterNotify:
            LightBorder(x11->disp, w, x11->fg);
            break;
        case LeaveNotify:
            LightBorder(x11->disp, w, x11->bg);
            break;
        case ButtonRelease:
            letter.type                 = ClientMessage;
            letter.xclient.display      = x11->disp;
            letter.xclient.window       = m->send_to ? m->send_to : child->Parent;
            letter.xclient.message_type = 0;
            letter.xclient.format       = 32;
            letter.xclient.data.l[0]    = m->nreturn;
            XSendEvent(x11->disp, letter.xclient.window, True, 0, &letter);
            break;
        default:
            break;
    }
    return FALSE;
}
Esempio n. 10
0
static int WndProcCB(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
{
    t_checkbox *cb;
    t_windata  *win;
    int         x, y, w, h;

    if (dlgitem->type != edlgCB)
    {
        gmx_incons("check box processing");
    }
    cb  = &(dlgitem->u.checkbox);
    win = &(dlgitem->win);

    x = 0;
    y = win->height/7;
    w = 5*y;
    h = 5*y;
    switch (event->type)
    {
        case Expose:
            XSetForeground(x11->disp, x11->gc, x11->fg);
            XClearArea(x11->disp, win->self, x, y, w, h, False);
            XDrawRectangle(x11->disp, win->self, x11->gc, x, y, w, h);
            if (cb->bChecked)
            {
                XDrawLine(x11->disp, win->self, x11->gc, x, y, x+w, y+h);
                XDrawLine(x11->disp, win->self, x11->gc, x+w, y, x, y+h);
            }
            x = w+OFFS_X;
            TextInRect(x11, win->self, win->text, x, 0, win->width-x, win->height,
                       eXLeft, eYCenter);
            break;
        case ButtonPress:
            cb->bChecked = !cb->bChecked;
            return CBPRESSED;
        case EnterNotify:
        case LeaveNotify:
            break;
        default:
            return DefWndProc(x11, dlgitem, event);
    }
    return ITEMOK;
}
Esempio n. 11
0
static int WndProcET(t_x11 *x11, t_dlgitem *dlgitem, XEvent *event)
{
    t_edittext *et;
    t_windata  *win;
    KeySym      keysym;
    char        c[BUFSIZE+1], *bp;
    char        scrbuf[STRLEN];
    int         i, xp, xtitle, ewidth;

    if (dlgitem->type != edlgET)
    {
        gmx_incons("st processing");
    }
    et  = &(dlgitem->u.edittext);
    win = &(dlgitem->win);

    /* Copy string part that is visible into screen buffer */
    for (i = 0; (i < et->buflen); i++)
    {
        scrbuf[i] = et->buf[i+et->strbegin];
    }
    scrbuf[i] = '\0';

    switch (event->type)
    {
        case Expose:
            XSetForeground(x11->disp, x11->gc, x11->fg);
            xtitle = XTextWidth(x11->font, win->text, strlen(win->text));
            ewidth = win->width-xtitle;
            TextInRect(x11, win->self, win->text,
                       0, 0, xtitle-1, win->height, eXLeft, eYCenter);
            XClearArea(x11->disp, win->self, xtitle, 0, ewidth+XCARET, win->height, False);
            TextInRect(x11, win->self, scrbuf,
                       xtitle+XCARET, 0, ewidth, win->height, eXLeft, eYCenter);
#ifdef DEBUG
            printf("Expose\n");
#endif
            if (win->bFocus)
            {
                ShowCaret(x11, dlgitem);
            }
            break;
        case ButtonPress:
            /* Calculate new position for caret */
            et->pos = strlen(et->buf);
            bp      = strdup(et->buf);
            xp      = event->xbutton.x-XTextWidth(x11->font, win->text, strlen(win->text))-
                XCARET;
            while ((et->pos > 0) && (XTextWidth(x11->font, bp, strlen(bp)) > xp))
            {
                et->pos--;
                bp[et->pos] = '\0';
            }
            sfree(bp);
            et->bChanged = TRUE;
            return ETCHANGED;
        case KeyPress:
            /* Check for HelpKey */
            if (HelpPressed(event))
            {
                return DefWndProc(x11, dlgitem, event);
            }
            XLookupString(&(event->xkey), c, BUFSIZE, &keysym, NULL);
#ifdef DEBUG
            printf("Keysym: %x\n", keysym);
#endif
            switch (keysym)
            {
                case XK_Delete:
                    if (my_delete(et->buf, &(et->pos)))
                    {
                        et->bChanged = TRUE;
                        return ETCHANGED;
                    }
                    else
                    {
                        XBell(x11->disp, 50);
                    }
                    break;
                case XK_BackSpace:
                    if (my_backspace(et->buf, &(et->pos)))
                    {
                        et->bChanged = TRUE;
                        return ETCHANGED;
                    }
                    else
                    {
                        XBell(x11->disp, 50);
                    }
                    break;
                case XK_KP_Enter:
                case XK_Return:
                    return ENTERPRESSED;
                case XK_Home:
                    et->pos      = 0;
                    et->strbegin = 0;
                    et->bChanged = TRUE;
                    return ETCHANGED;
                case XK_End:
                    if (strlen(et->buf) <= et->buflen)
                    {
                        et->pos = strlen(et->buf);
                    }
                    else
                    {
                        et->pos      = et->buflen;
                        et->strbegin = strlen(et->buf)-et->buflen;
                    }
                    et->bChanged = TRUE;
                    return ETCHANGED;
                case XK_Left:
                    et->pos      = max(0, et->pos-1);
                    et->strbegin = min(et->strbegin, et->pos);
                    et->bChanged = TRUE;
                    return ETCHANGED;
                case XK_Right:
                    if ((et->pos < et->buflen) && (et->strbegin+et->buflen > strlen(et->buf)))
                    {
                        et->pos++;
                    }
                    else if ((et->buflen   < strlen(et->buf)) &&
                             (et->strbegin < strlen(et->buf)-et->buflen))
                    {
                        et->strbegin++;
                    }
                    else
                    {
                        break;
                    }
                    et->bChanged = TRUE;
                    return ETCHANGED;
                default:
                    if (keysym < 256)
                    {
                        if (insert(et->buf, c[0], &(et->pos)))
                        {
                            et->bChanged = TRUE;
                            return ETCHANGED;
                        }
                    }
                    XBell(x11->disp, 50);
                    break;
            }
            break;
        case LeaveNotify:
            win->bFocus = FALSE;
            HideCaret(x11, dlgitem);
            if (et->bChanged)
            {
                et->bChanged = FALSE;
            }
            break;
        default:
            return DefWndProc(x11, dlgitem, event);
    }
    return ITEMOK;
}
Esempio n. 12
0
void DrawLoad(t_x11 *x11,t_windata *Win,int nloads,int *loadinfo)
{
  static char *Strings[] = { "Unbalance","Single Node","Your Ad Here ?"};
  int  i,y0,bwidth,boff,bar,bmax,bmin,ym,yh;
  int  *lb;
  real bav,bscale;
  char maxstr[6];

  return;
  
  XClearWindow(x11->disp, Win->self);
  y0=XTextHeight(x11->font)+AIR;
  yh=(Win->height-y0)/2;
  ym=y0+yh;
  XSetForeground(x11->disp,x11->gc,WHITE);
  XDrawLine(x11->disp,Win->self,x11->gc,0,y0,Win->width,y0);
    
  if (nloads >= 2) {
    TextInRect(x11,Win->self,Strings[0],AIR,0,Win->width-2*AIR,y0,
	       eXLeft,eYCenter);
    if (loadinfo[0] == 0) {
      nloads--;
      lb=&loadinfo[1];
    }
    else {
      lb=loadinfo;
      if (loadinfo[nloads-1] == 0) 
	nloads--;
    }
    bwidth = (Win->width) / nloads;
    boff   = (Win->width % nloads)/2;
    bav    = 0.0; 
    
    bmax=bmin=lb[0];
    
    for (i=1; (i<nloads); i++) {
      bmax = max (bmax,lb[i]);
      bmin = min (bmin,lb[i]);
      bav += lb[i];
    }
    bav/=nloads;
    bscale = (yh-2)/max(fabs(bmax-bav),fabs(bav-bmin));
    sprintf(maxstr,"(%d%%)",(int)(100.0*(bmax-bav)/bav));
    TextInRect(x11,Win->self,maxstr,AIR,0,Win->width-2*AIR,y0,
	       eXRight,eYCenter);

    XDrawLine(x11->disp,Win->self,x11->gc,0,ym,Win->width,ym);
    if (bmax-bmin) {
      for(i=0; i<nloads; i++) {
	bar=(lb[i]-bav)*bscale;
	if (bar != 0) {
	  if (bar > 0)
	    XFillRectangle(x11->disp,Win->self,x11->gc,
			   (i*bwidth)+boff+1,ym-bar+1,bwidth-2,bar);
	  else
	    XFillRectangle(x11->disp,Win->self,x11->gc,
			   (i*bwidth)+boff+1,ym,bwidth-2,-bar);
	}
      }
      
    }
  }
  else {
    TextInRect(x11,Win->self,Strings[1],AIR,0,Win->width,y0,eXLeft,eYCenter);
    TextInRect(x11,Win->self,Strings[2],AIR,y0,Win->width,
	       Win->height-y0,eXLeft,eYCenter);
  }
  XSetForeground(x11->disp,x11->gc,x11->fg);
}
Esempio n. 13
0
void TextInWin(t_x11 *x11, t_windata *win,
               const char *s, eXPos eX, eYPos eY)
{
    TextInRect(x11, win->self, s, 0, 0, win->width, win->height, eX, eY);
}