Beispiel #1
0
static t_sc *init_sc(t_x11 *x11,Window Parent,char *rgb)
{
  t_sc   *sc;
  Window w;
  int    i;

  snew(sc,1);
  InitWin(&sc->wd,0,0,400,300,1,"Show Colours");
  sc->wd.self=XCreateSimpleWindow(x11->disp,Parent,sc->wd.x,sc->wd.y,
				  sc->wd.width,sc->wd.height,
				  sc->wd.bwidth,WHITE,BLACK);
  x11->RegisterCallback(x11,sc->wd.self,Parent,scCallBack,sc);
  x11->SetInputMask(x11,sc->wd.self,ButtonPressMask | ExposureMask |
		    StructureNotifyMask);
  InitWin(&sc->but,0,0,sc->wd.width-2,XTextHeight(x11->font)+2,1,"Quit");
  sc->but.self=XCreateSimpleWindow(x11->disp,sc->wd.self,sc->but.x,sc->but.y,
				   sc->but.width,sc->but.height,
				   sc->but.bwidth,BLACK,BLACK);
  x11->RegisterCallback(x11,sc->but.self,sc->but.self,BCallBack,sc);
  x11->SetInputMask(x11,sc->but.self,ButtonPressMask | ExposureMask | 
		    StructureNotifyMask | EnterWindowMask |
		    LeaveWindowMask);

  read_col(x11,sc,rgb);
  fprintf(stderr,"%d colors found\n",sc->ncol);
  fprintf(stderr,"%6s%6s%6s\t\t%-20s\n","Red","Green","Blue","name");
  for(i=0; (i<sc->ncol); i++) {
    sc->col[i].wd.self=w=XCreateSimpleWindow(x11->disp,sc->wd.self,0,0,1,1,0,
					     BLACK,sc->col[i].xc.pixel);
    x11->RegisterCallback(x11,w,sc->wd.self,ColCallBack,&(sc->col[i]));
    x11->SetInputMask(x11,w,ButtonPressMask);
  }
  
  return sc;
}
Beispiel #2
0
/*****************************
 *
 * Routines to create dialog items, all items have an id
 * which you can use to extract info. It is possible to have
 * multiple items with the same id but it may then not be possible
 * to extract information.
 * All routines take the position relative to the parent dlg
 * and the size and border width.
 * If the width and height are set to zero initially, they will
 * be calculated and set by the routine. With the dlgitem manipulation
 * routines listed below, the application can then move the items around
 * on the dlg box, and if wished resize them.
 *
 ****************************/
t_dlgitem *CreateButton(t_x11 *x11,
                        const char *szLab, gmx_bool bDef, t_id id, t_id groupid,
                        int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;
    char      *lab;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+2*OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+2*OFFS_X;
    }
    if (bDef)
    {
        snew(lab, strlen(szLab)+7); /* 6 for >> << and 1 for \0 */
        sprintf(lab, ">> %s <<", szLab);
    }
    else
    {
        lab = strdup(szLab);
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    sfree(lab);
    dlgitem->ID                = id;
    dlgitem->GroupID           = groupid;
    dlgitem->type              = edlgBN;
    dlgitem->u.button.bDefault = bDef;
    dlgitem->WndProc           = WndProcBN;

    return dlgitem;
}
Beispiel #3
0
t_dlgitem *CreateGroupBox(t_x11 *x11,
                          const char *szLab, t_id id,
                          int nitems, t_id items[],
                          int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+2*OFFS_X;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    dlgitem->GroupID           = id;
    dlgitem->ID                = id;
    dlgitem->type              = edlgGB;
    dlgitem->u.groupbox.nitems = nitems;
    snew(dlgitem->u.groupbox.item, nitems);
    memcpy((char *)dlgitem->u.groupbox.item, (char *)items,
           nitems*sizeof(items[0]));
    dlgitem->WndProc = WndProcGB;

    return dlgitem;
}
Beispiel #4
0
t_dlgitem *CreateCheckBox(t_x11 *x11,
                          const char *szLab, gmx_bool bCheckedInitial, t_id id,
                          t_id groupid,
                          int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+OFFS_X+h;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    dlgitem->ID                  = id;
    dlgitem->GroupID             = groupid;
    dlgitem->type                = edlgCB;
    dlgitem->u.checkbox.bChecked = bCheckedInitial;
    dlgitem->WndProc             = WndProcCB;

    return dlgitem;
}
Beispiel #5
0
t_dlgitem *CreateStaticText(t_x11 *x11,
                            int nlines, char * const * lines, t_id id,
                            t_id groupid,
                            int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;
    int        i;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = (XTextHeight(x11->font)+OFFS_Y)*nlines+OFFS_Y;
    }
    if (w == 0)
    {
        for (i = 0; (i < nlines); i++)
        {
            w = max(w, XTextWidth(x11->font, lines[i], strlen(lines[i])));
        }
        w += 2*OFFS_X;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, NULL);
    dlgitem->ID                  = id;
    dlgitem->GroupID             = groupid;
    dlgitem->type                = edlgST;
    dlgitem->u.statictext.nlines = nlines;
    snew(dlgitem->u.statictext.lines, nlines);
    for (i = 0; (i < nlines); i++)
    {
        dlgitem->u.statictext.lines[i] = strdup(lines[i]);
    }
    dlgitem->WndProc = WndProcST;

    return dlgitem;
}
Beispiel #6
0
t_dlgitem *CreateEditText(t_x11 *x11,
			  const char *title,
			  int screenbuf,char *buf, t_id id,t_id groupid,
			  int x0,int y0,int w,int h,int bw)
{
  t_dlgitem *dlgitem;
  t_edittext *et;
  
  dlgitem=newitem(x11);
  if (h==0) h=XTextHeight(x11->font)+OFFS_Y;
  if (w==0) {
    char *test;

    snew(test,screenbuf);
    memset(test,'w',screenbuf);
    w=XTextWidth(x11->font,test,screenbuf)+
      XTextWidth(x11->font,title,strlen(title))+
      2*XCARET+2*OFFS_X;
    sfree(test);
  }
  InitWin(&(dlgitem->win),x0,y0,w,h,bw,title);
  dlgitem->ID=id;
  dlgitem->GroupID=groupid;
  dlgitem->type=edlgET;
  et=&(dlgitem->u.edittext);
  snew(et->buf,STRLEN);
  strcpy(et->buf,buf);
  et->buflen=screenbuf;
  et->strbegin=0;
  et->bChanged=FALSE;
  dlgitem->WndProc=WndProcET;

  return dlgitem;
}
Beispiel #7
0
t_dlgitem *CreateRadioButton(t_x11 *x11,
                             const char *szLab, gmx_bool bSet, t_id id,
                             t_id groupid,
                             int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem(x11);
    if (h == 0)
    {
        h = XTextHeight(x11->font)+OFFS_Y;
    }
    if (w == 0)
    {
        w = XTextWidth(x11->font, szLab, strlen(szLab))+OFFS_X+h;
    }
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, szLab);
    dlgitem->ID                    = id;
    dlgitem->GroupID               = groupid;
    dlgitem->type                  = edlgRB;
    dlgitem->u.radiobutton.bSelect = bSet;
    dlgitem->WndProc               = WndProcRB;

    return dlgitem;
}
Beispiel #8
0
t_manager *init_man(t_x11 *x11, Window Parent,
                    int x, int y, int width, int height,
                    unsigned long fg, unsigned long bg,
                    int ePBC, matrix box,
                    gmx_output_env_t *oenv)
{
    t_manager *man;

    snew(man, 1);
    man->status = nullptr;
    man->bPlus  = true;
    man->bSort  = true;
    man->oenv   = oenv;
    InitWin(&(man->wd), x, y, width, height, 0, "Manager");
    man->wd.self = XCreateSimpleWindow(x11->disp, Parent, man->wd.x, man->wd.y,
                                       man->wd.width, man->wd.height,
                                       man->wd.bwidth, fg, bg);
    x11->RegisterCallback(x11, man->wd.self, Parent, ManCallBack, man);
    x11->SetInputMask(x11, man->wd.self, StructureNotifyMask |
                      ExposureMask | ButtonPressMask);

    /* The order of creating windows is important for the stacking order */
    /* Mol Window */
    man->molw = init_mw(x11, man->wd.self, 0, 0, 1, 1, WHITE, BLUE, ePBC, box);

    /* Title Window */
    InitWin(&(man->title), 0, 0, 1, 1, 0, nullptr);
    man->title.self = XCreateSimpleWindow(x11->disp, man->molw->wd.self,
                                          man->title.x, man->title.y,
                                          man->title.width, man->title.height,
                                          man->title.bwidth, WHITE, BLUE);
    x11->RegisterCallback(x11, man->title.self, man->molw->wd.self,
                          TitleCallBack, &(man->title));
    x11->SetInputMask(x11, man->title.self, ExposureMask | StructureNotifyMask);

    /* Button box */
    man->bbox = init_bbox(x11, man->wd.self, man->wd.self, 1, WHITE, BLUE);

    /* Legend Window */
    man->legw = init_legw(x11, man->wd.self, 0, 0, EWIDTH, LEGHEIGHT, WHITE, BLUE);

    /* Video Box */
    man->vbox = init_vbox(x11, man->molw->wd.self, man->wd.self, WHITE, BLUE);

    return man;
}
Beispiel #9
0
t_butbox *init_bbox(t_x11 *x11, Window Parent, Window SendTo,
                    int width, unsigned long fg, unsigned long bg)
{
    t_butbox          *bbox;
    static const char *lbut[IDBUTNR] = {
        "< X-Rotate >", "< Y-Rotate >", "< Z-Rotate >",
        "< X-Move >", "< Y-Move >", "< Z-Move >", "< Scale >",
    };
    int                i, y0, h0;
    t_mwbut           *but;
    Window             DrawOn;

    snew(bbox, 1);
    bbox->nbut = IDBUTNR;
    snew(bbox->b, bbox->nbut);
    y0 = XTextHeight(x11->font)+2*(AIR+BORDER);

    InitWin(&(bbox->wd), 0, 0, /*width,(y0+AIR)*IDBUTNR+AIR+2*BORDER,*/ 1, 1,
            1, "Button Box");
    width        -= 2*AIR+2*BORDER;
    bbox->wd.self = XCreateSimpleWindow(x11->disp, Parent,
                                        bbox->wd.x, bbox->wd.y, bbox->wd.width,
                                        bbox->wd.height, bbox->wd.bwidth,
                                        fg, bg);
    x11->RegisterCallback(x11, bbox->wd.self, Parent, BBCallBack, bbox);
    x11->SetInputMask(x11, bbox->wd.self, StructureNotifyMask);

    DrawOn = bbox->wd.self;
    h0     = AIR;
    for (i = 0; (i < bbox->nbut); i++)
    {
        but = &(bbox->b[i]);
        InitWin(&but->wd, AIR, h0, width, y0, 1, lbut[i]);
        h0            += y0+AIR;
        but->wd.Parent = SendTo;
        but->ID        = i;
        but->wd.self   = XCreateSimpleWindow(x11->disp, DrawOn,
                                             but->wd.x, but->wd.y,
                                             but->wd.width, but->wd.height,
                                             but->wd.bwidth, bg, bg);
        x11->RegisterCallback(x11, but->wd.self, DrawOn, ButtonCallBack, but);
        x11->SetInputMask(x11, but->wd.self, ExposureMask | ButtonPressMask |
                          EnterLeave);
    }
    return bbox;
}
Beispiel #10
0
//----------------------------------------------------------------------------//
void CTUIBackGround::Show()
{
	if ( !m_pRootWin )
	{
		InitWin();
	}

	m_pRootWin->show();
}
Beispiel #11
0
t_logo *init_logo(t_x11 *x11,Window parent,gmx_bool bQuitOnClick)
{
  static const char *bfname[]= {
    "-b&h-lucida-bold-i-normal-sans-34-240-100-100-p-215-iso8859-1",
    "-b&h-lucida-bold-i-normal-sans-26-190-100-100-p-166-iso8859-1",
    "lucidasans-bolditalic-24",
    "lucidasans-italic-24",
    "10x20",
    "fixed"
    };
#define NBF asize(bfname)
  static const char *sfname[]= {
    "lucidasans-bold-18",
    "10x20",
    "fixed"
    };
#define NSF asize(sfname)
  int    i;
  unsigned long  bg;
  char   *newcol;
  t_logo *logo;

  snew(logo,1);
  logo->bQuitOnClick = bQuitOnClick;
  InitWin(&logo->wd,0,0,360,270,1,"GROMACS");
  bg=LIGHTGREY;
  if ((newcol=getenv("LOGO"))!=NULL)
    GetNamedColor(x11,newcol,&bg);
  logo->wd.self=XCreateSimpleWindow(x11->disp,parent,
				    logo->wd.x, logo->wd.y, 
				    logo->wd.width,logo->wd.height,
				    logo->wd.bwidth,WHITE,bg);
  for (i=0,logo->bigfont=NULL; (i<NBF); i++)
    if ((logo->bigfont=XLoadQueryFont(x11->disp,bfname[i]))!=NULL)
      break;
  if (i==NBF) {
    perror(bfname[i-1]);
    exit(1);
  }
#ifdef DEBUG
  fprintf(stderr,"Big Logofont: %s\n",bfname[i]);
#endif
  for (i=0,logo->smallfont=NULL; (i<NSF); i++)
    if ((logo->smallfont=XLoadQueryFont(x11->disp,sfname[i]))!=NULL)
      break;
  if (i==NSF) {
    perror(sfname[i-1]);
    exit(1);
  }
#ifdef DEBUG
  fprintf(stderr,"Small Logofont: %s\n",sfname[i]);
#endif
  x11->RegisterCallback(x11,logo->wd.self,parent,LogoCallBack,logo);
  x11->SetInputMask(x11,logo->wd.self,ButtonPressMask | ExposureMask);

  return logo;
}
Beispiel #12
0
int
InitScreen(
	void)
{
	InitWin();
#	ifdef HAVE_COLOR
	postinit_colors();
#	endif /* HAVE_COLOR */
	return TRUE;
}
Beispiel #13
0
static t_app *init_app(t_x11 *x11, int argc, char *argv[])
{
    static const char *but_nm[ebutNR] = { "Quit", "Start", "Stop", "Rewind", "Toggle Gly" };
    XSizeHints         hints;
    Pixmap             pm;
    int                th;
    t_app             *app;
    t_windata         *wd;
    int                i, dx;

    snew(app, 1);
    th = XTextHeight(x11->font)+4;
    InitWin(&(app->wd), 0, 0, MAXDEG+6, MAXDEG+6+th+6, 0, "Ramachandran Movie");
    dx           = app->wd.width/ebutNR;
    app->wd.self = XCreateSimpleWindow(x11->disp, x11->root, app->wd.x, app->wd.y,
                                       app->wd.width, app->wd.height,
                                       app->wd.bwidth, x11->fg, x11->bg);
    x11->RegisterCallback(x11, app->wd.self, x11->root, mainCallBack, app);
    x11->SetInputMask(x11, app->wd.self, StructureNotifyMask);
    hints.flags = 0;
    pm          = XCreatePixmapFromBitmapData(x11->disp, x11->root, (char *)rama_bits,
                                              rama_width, rama_height, WHITE, BLACK, 1);
    XSetStandardProperties(x11->disp, app->wd.self, app->wd.text,
                           "Rama", pm, argv, argc, &hints);
    x11->RegisterCallback(x11, app->wd.self, x11->root, appCallBack, app);
    x11->SetInputMask(x11, app->wd.self, ButtonPressMask | ExposureMask |
                      StructureNotifyMask);

    app->xr = init_xrama(x11, app->wd.self, th+6, app);
    for (i = 0; (i < ebutNR); i++)
    {
        wd = &(app->but[i]);
        InitWin(wd, i*dx+2, 2, dx-4, th, 1, but_nm[i]);
        wd->self = XCreateSimpleWindow(x11->disp, app->wd.self,
                                       wd->x, wd->y, wd->width, wd->height,
                                       wd->bwidth, x11->fg, x11->bg);
        x11->RegisterCallback(x11, wd->self, app->wd.self, appCallBack, app);
        x11->SetInputMask(x11, wd->self, ButtonPressMask | ExposureMask);
    }
    return app;
}
Beispiel #14
0
static void Configure(t_xhighway *xhw)
{
  Window self;
  int   i,h,w,dh;
  float dw;

  dh=20;
  h=xhw->main.height;
  w=xhw->main.width;
  dw=((float)(w-2))/NBUT-4;
  for(i=0; (i<NBUT); i++) {
    t_windata *wd=&(xhw->but[i]);

    self=wd->self;
    InitWin(wd,2+i*(dw+4),2,dw,dh,1,but_name[i]);
    wd->self=self;
  }
  self=xhw->win.self;
  InitWin(&xhw->win,2,dh+6,w-6,h-dh-10,1,xhw->main.text);
  xhw->win.self=self;
}
Beispiel #15
0
t_legendwin *init_legw(t_x11 *x11, Window Parent,
                       int x, int y, int width, int height,
                       unsigned long fg, unsigned long bg)
{
    t_legendwin *lw;

    snew(lw, 1);
    InitWin(&lw->wd, x, y, width, height, 1, "Legend Window");
    lw->wd.self = XCreateSimpleWindow(x11->disp, Parent, x, y, 1, 1, 1, fg, bg);
    x11->RegisterCallback(x11, lw->wd.self, Parent, LegWCallBack, lw);
    x11->SetInputMask(x11, lw->wd.self, ExposureMask);

    return lw;
}
Beispiel #16
0
static void read_col(t_x11 *x11,t_sc *sc,char *rgb)
{
  FILE   *fp;
  char   buf[STRLEN],name[STRLEN],*dummy;
  int    i,j;
  int    r,g,b;
  XColor xc,exact;
  t_col  *cols;
  
  if ((fp=fopen(rgb,"r"))==NULL) {
    perror(rgb);
    exit(1);
  }
  do {
    dummy=NULL;
    if (fscanf(fp,"%d%d%d",&r,&g,&b)==3) {
      dummy=fgets2(buf,STRLEN-1,fp);
      if (dummy) {
	trim(buf);
	/* Filter out colours with names of two words */
	sscanf(buf,"%s",name);
	/* Filter out duplicate colours (grey and gray) */
	if (strstr(name,"gray")==0) {
	  if (XAllocNamedColor(x11->disp,x11->cmap,name,&xc,&exact)) {
	    srenew(sc->col,++sc->ncol);
	    sc->col[sc->ncol-1].xc=xc;
#ifdef DEBUG
	    printf("color %3d: %s\n",sc->ncol,buf);
#endif
	    InitWin(&(sc->col[sc->ncol-1].wd),0,0,1,1,0,name);
	  }
	}
      }
    }
  } while (dummy);
  fclose(fp);
  if (sc->ncol)
    qsort(sc->col,sc->ncol,sizeof(sc->col[0]),col_comp);
  /* Now filter out doubles */
  cols=&(sc->col[0]);
  for(i=1,j=0; (i<sc->ncol); i++) {
    if ((cols[i].xc.red   != cols[j].xc.red) ||
	(cols[i].xc.green != cols[j].xc.green) ||
	(cols[i].xc.blue  != cols[j].xc.blue)) {
      j++;
      cols[j]=cols[i];
    }
  }
  sc->ncol=j;
}
Beispiel #17
0
t_dlgitem *CreatePixmap(Pixmap pm, t_id id,
                        t_id /*groupid*/, int x0, int y0, int w, int h, int bw)
{
    t_dlgitem *dlgitem;

    dlgitem = newitem();
    InitWin(&(dlgitem->win), x0, y0, w, h, bw, NULL);
    dlgitem->ID          = id;
    dlgitem->type        = edlgPM;
    dlgitem->u.pixmap.pm = pm;
    dlgitem->WndProc     = DefWndProc;

    return dlgitem;
}
Beispiel #18
0
/*****************************
 *
 * Routine to create the DLG structure, returns NULL on failure
 *
 ****************************/
t_dlg *CreateDlg(t_x11 *x11, Window Parent, const char *title,
		 int x0,int y0,int w,int h,int bw, unsigned long fg, unsigned long bg,
		 DlgCallback *cb,void *data)
{
  t_dlg   *dlg;
  int     x=0,y=0;
  
  snew(dlg,1);
  dlg->x11=x11;
  dlg->cb=cb;
  dlg->data=data;
  if (title)
    dlg->title=strdup(title);
  else
    dlg->title=NULL;
  if (w==0) w=1;
  if (h==0) h=1;
  if (!Parent) {
    Parent=x11->root;
    dlg->xmax=DisplayWidth(x11->disp,x11->screen);
    dlg->ymax=DisplayHeight(x11->disp,x11->screen);
  }
  else {
    Window root;
    unsigned int   dum;

    XGetGeometry(x11->disp,Parent,&root,&x,&y,
		 &(dlg->xmax),&(dlg->ymax),&dum,&dum);
#ifdef DEBUG
    fprintf(x11->console,
	    "Daddy is %d x %d at %d, %d\n",dlg->xmax,dlg->ymax,x,y);
    dlg->x11->Flush(dlg->x11);
#endif
  }
  if (x0) x=x0;
  if (y0) y=y0;
  InitWin(&(dlg->win),x,y,w,h,bw,NULL);
  SetDlgSize(dlg,w,h,x0 || y0);

  dlg->wDad=Parent;
  dlg->fg=x11->fg;
  dlg->bg=x11->bg;
  dlg->nitem=0;
  dlg->dlgitem=NULL;

  DoCreateDlg(dlg);
  return dlg;
}
Beispiel #19
0
t_xhighway *GetXHW(t_x11 *x11, const char *infile)
{
    t_xhighway *xhw;
    int         i, h, dh, w;
    char        progname[STRLEN];

    snew(xhw, 1);
    xhw->ncars = read_input(x11, infile, &(xhw->cars), &xhw->ir);

    h  = xhw->ir.nlane*40;
    dh = 20;
    w  = 752;
    strncpy(progname, Program(), STRLEN-1);
    InitWin(&xhw->main, 0, 0, w, h+dh+7, 1, progname);
    xhw->main.self = XCreateSimpleWindow(x11->disp, x11->root,
                                         xhw->main.x, xhw->main.y,
                                         xhw->main.width, xhw->main.height,
                                         xhw->main.bwidth, WHITE, BLACK);
    x11->RegisterCallback(x11, xhw->main.self, 0, xhwCallBack, xhw);
    x11->SetInputMask(x11, xhw->main.self, ButtonPressMask | ExposureMask |
                      StructureNotifyMask);

    Configure(xhw);

    for (i = 0; (i < NBUT); i++)
    {
        t_windata *wd = &(xhw->but[i]);

        wd->self = XCreateSimpleWindow(x11->disp, xhw->main.self,
                                       wd->x, wd->y,
                                       wd->width, wd->height,
                                       wd->bwidth, WHITE, BLACK);
        x11->RegisterCallback(x11, wd->self, xhw->main.self,
                              butCallBack, xhw);
        x11->SetInputMask(x11, wd->self, ButtonPressMask | ExposureMask |
                          StructureNotifyMask);

    }
    xhw->win.self = XCreateSimpleWindow(x11->disp, xhw->main.self,
                                        xhw->win.x, xhw->win.y,
                                        xhw->win.width, xhw->win.height,
                                        xhw->win.bwidth, WHITE, BLACK);
    x11->RegisterCallback(x11, xhw->win.self, 0, xhwCallBack, xhw);
    x11->SetInputMask(x11, xhw->win.self, ButtonPressMask | ExposureMask |
                      StructureNotifyMask);

    return xhw;
}
Beispiel #20
0
static t_xrama *init_xrama(t_x11 *x11, Window Parent, int y0, t_app *app)
{
    t_xrama *xr;

    snew(xr, 1);

    InitWin(&(app->xrwd), 2, y0, MAXDEG+1, MAXDEG+1, 1, "Ramachandran Movie");
    app->xrwd.self = XCreateSimpleWindow(x11->disp, Parent, app->xrwd.x, app->xrwd.y,
                                         app->xrwd.width, app->xrwd.height,
                                         app->xrwd.bwidth, x11->fg, x11->bg);
    x11->RegisterCallback(x11, app->xrwd.self, Parent, xrCallBack, app);
    x11->SetInputMask(x11, app->xrwd.self, ButtonPressMask | ExposureMask |
                      StructureNotifyMask);

    return xr;
}
Beispiel #21
0
EXPORT_C void CTBaseWin::ConstructL(CTWinBase &aParent)
	{
	TInt ret;
	__ASSERT_DEBUG(aParent.iOwnerWin!=NULL,TbPanic(ETestBasePanicNullOwnerWin));
	iOwnerWin=aParent.iOwnerWin;
	if ((ret=ConstructWin(aParent))==KErrNone)
		{
		//TFontSpec fspec(KTestFontTypefaceName,200);
		//User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont, fspec));
		TFontSpec fspec(KTestFontTypefaceName,17);
		User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInPixels((CFont *&)iFont, fspec));
		AdjustShadow(1);
		InitWin();
		iSize=BaseWin()->Size();
		}
	User::LeaveIfError(ret);
	}
Beispiel #22
0
t_molwin *init_mw(t_x11 *x11,Window Parent,
                  int x,int y,int width,int height,
                  unsigned long fg,unsigned long bg,
                  int ePBC,matrix box)
{
    t_molwin *mw;

    snew(mw,1);
    set_def(mw,ePBC,box);

    InitWin(&mw->wd,x,y,width,height,1,"Mol Window");

    mw->wd.Parent=Parent;
    mw->wd.self=XCreateSimpleWindow(x11->disp,Parent,x,y,width,height,1,fg,bg);
    x11->RegisterCallback(x11,mw->wd.self,Parent,MWCallBack,mw);
    x11->SetInputMask(x11,mw->wd.self,
                      ExposureMask | StructureNotifyMask |
                      ButtonPressMask);
    return mw;
}
Beispiel #23
0
t_pulldown *init_pd(t_x11 *x11, Window Parent, int width,
                    unsigned long fg, unsigned long bg,
                    int nmenu, int *nsub, t_mentry *ent[], const char **title)
{
    t_pulldown *pd;
    int         i;

    snew(pd, 1);
    pd->title = title;
    pd->nmenu = nmenu;
    pd->nsel  = -1;
    snew(pd->m, nmenu);
    snew(pd->xpos, nmenu+1);
    pd->xpos[0] = 5;
    for (i = 1; (i <= nmenu); i++)
    {
        pd->xpos[i] = 20+pd->xpos[i-1]+
            XTextWidth(x11->font, title[i-1], std::strlen(title[i-1]));
    }
    if (pd->xpos[nmenu] > width)
    {
        std::printf("Menu too wide\n");
    }

    InitWin(&(pd->wd), 0, 0, width, XTextHeight(x11->font)+2, 0, "PullDown");
    pd->wd.self = XCreateSimpleWindow(x11->disp, Parent,
                                      pd->wd.x, pd->wd.y,
                                      pd->wd.width, pd->wd.height,
                                      pd->wd.bwidth, fg, bg);
    x11->RegisterCallback(x11, pd->wd.self, Parent, PDCallBack, pd);
    x11->SetInputMask(x11, pd->wd.self, ExposureMask | ButtonPressMask |
                      OwnerGrabButtonMask | ButtonReleaseMask);
    XMapWindow(x11->disp, pd->wd.self);

    for (i = 0; (i < nmenu); i++)
    {
        pd->m[i] = init_menu(x11, Parent, fg, bg, nsub[i], ent[i], 1);
    }

    return pd;
}
Beispiel #24
0
int InitScreen ()
{
#ifndef			INDEX_DAEMON

	char c,*ptr,buf[32];

	/* 
	 * we're going to assume a terminal here... 
	 */

	_clearscreen	= "\033[1;1H\033[J";
	_moveto		= "\033[%d;%dH";	/* not a termcap string! */
	_cleartoeoln	= "\033[K";
	_cleartoeos	= "\033[J";

	_setinverse	= "\033[7m";
	_clearinverse	= "\033[0m";
	_setunderline	= "\033[4m";
	_clearunderline	= "\033[0m";
	_terminalinit	= "\033c";
	_terminalend	= "\033c";
	_keypadlocal	= "";
	_keypadxmit	= "";

	InitWin ();

	_lines = _columns = -1;

	/* 
	 * Get lines and columns from environment settings - useful when
         * you're using something other than an Amiga window 
         */
         
	if (ptr = getenv("LINES")) {
		_lines = atol(ptr);
	}
	if (ptr = getenv("COLUMNS")) {
		_columns = atol(ptr);
	}

	/* 
	 * If that failed, try get a response from the console itself 
	 */

	if (_lines == -1 || _columns == -1) {
		Raw (TRUE);

		tputs ("\2330 q",1,outchar);	/* identify yourself */
		fflush (stdout);

getsize:
		while (ReadCh () != 0x9b) {
			;	/* Look for escape */
		}
		/* get top */
		ptr = buf;
		do {	
			c = *ptr++ = ReadCh ();
		} while (isdigit(c));

		if (c != ';') { 
			goto getsize;
		}
		
		/* get right */
		ptr = buf;
		do {	
			c = *ptr++ = ReadCh ();
		} while (isdigit(c));

		if (c != ';') { 
			goto getsize;
		}
		
		/* get bottom */
		ptr = buf;
		do {	
			c = *ptr++ = ReadCh ();
		} while (isdigit(c));

		if (c != ';') {
			goto getsize;
		}

		*ptr = 0;
		_lines = atol (buf);

		/* get right */
		ptr = buf;
		do {	
			c = *ptr++ = ReadCh ();
		} while (isdigit(c));

		if (c != ' ') {
			goto getsize;
		}
		if (ReadCh () != 'r') { 
			goto getsize;
		}

		*ptr = 0;
		_columns = atol (buf);
	}

	Raw (FALSE);

	return (TRUE);
#else
	return (FALSE);

#endif /* INDEX_DAEMON */
}
Beispiel #25
0
t_butbox *init_vbox(t_x11 *x11, Window Parent, Window SendTo, unsigned long fg, unsigned long bg)
{
    Pixmap             pm;
    unsigned char     *data;
    t_butbox          *vb;
    int                i, ID, x, y0;

    snew(vb, 1);
    vb->nbut = IDNR-IDBUTNR-1;
    snew(vb->b, vb->nbut);

    /* VBox holder */
    y0 = XTextHeight(x11->font)+2*AIR+2;
    InitWin(&vb->wd, 0, 0, vb->nbut*(play_width+AIR)+AIR,
            y0+play_height+2*AIR, 1, "VCR - Control");
    vb->wd.self = XCreateSimpleWindow(x11->disp, Parent,
                                      vb->wd.x, vb->wd.y, vb->wd.width, vb->wd.height,
                                      vb->wd.bwidth, WHITE, BLACK);
    x11->RegisterCallback(x11, vb->wd.self, Parent, VBCallBack, vb);
    x11->SetInputMask(x11, vb->wd.self, ExposureMask);

    x = AIR;
    (void)CWBackPixmap;
    for (i = 0; (i < vb->nbut); i++)
    {
        ID = IDBUTNR+i+1;
        switch (ID)
        {
            case IDREWIND:
                data = &(rewind_bits[0]);
                break;
            case IDSTEP:
                data = play_bits;
                break;
            case IDFF:
                data = ff_bits;
                break;
            case IDSTOP_ANI:
                data = stop_ani_bits;
                break;
            default:
                fprintf(stderr, "Invalid bitmap in init_vbox %d\n", ID);
                exit(1);
        }
        /* Rely on the fact that all bitmaps are equal size */
        pm = XCreatePixmapFromBitmapData(x11->disp, x11->root,
                                         (char *)data, play_width, play_height,
                                         BLACK, LIGHTGREY, x11->depth);
        vb->b[i].ID        = ID;
        vb->b[i].wd.Parent = SendTo;
        vb->b[i].wd.self   =
            XCreateSimpleWindow(x11->disp, vb->wd.self,
                                x, y0+AIR, play_width, play_height, 0, WHITE, BLACK);
        XSetWindowBackgroundPixmap(x11->disp, vb->b[i].wd.self, pm);

        x11->RegisterCallback(x11, vb->b[i].wd.self, vb->wd.self,
                              ButtonCallBack, &(vb->b[i]));
        x11->SetInputMask(x11, vb->b[i].wd.self,
                          ButtonPressMask | StructureNotifyMask);
        x += play_width+AIR;
    }

    return vb;
}
Beispiel #26
0
t_menu *init_menu(t_x11 *x11,Window Parent,unsigned long fg,unsigned long bg,
		  int nent,t_mentry ent[],int ncol)
{
  int       i,mlen,mht,area,ht;
  int       j,k,l;
  int       frows,fcol;
  t_menu    *m;
  t_child   *kid;
  t_windata *w;

  snew(m,1);
  m->nitem=nent;
  m->Parent=Parent;

  /* Calculate dimensions of the menu */
  mlen=0;
  for(i=0; (i<nent); i++)
    mlen=max(mlen,XTextWidth(x11->font,ent[i].str,strlen(ent[i].str)));
  mht=XTextHeight(x11->font);
  /* Now we have the biggest single box, add a border of 2 pixels */
  mlen+=20; /* We need extra space at the left for checkmarks */
  mht+=4;
  /* Calculate the area of the menu */
  area=mlen*mht;
  ht=sqrt(area);
  /* No the number of rows per column, only beyond 8 rows */
  if (ncol == 0) {
    if (nent > 8)
      frows=(1+ht/mht);
    else
      frows=nent;
    fcol=nent/frows;
  }
  else {
    fcol=ncol;
    frows=nent/ncol;
    if (nent % ncol)
      frows++;
  }
  InitWin(&(m->wd),10,10,fcol*mlen,frows*mht,1,"Menu");
  snew(m->item,nent);
  m->wd.self=XCreateSimpleWindow(x11->disp,Parent,
				 m->wd.x, m->wd.y,
				 m->wd.width,m->wd.height,
				 m->wd.bwidth,fg,bg);
  x11->RegisterCallback(x11,m->wd.self,Parent,MenuCallBack,m);
  x11->SetInputMask(x11,m->wd.self,ExposureMask | 
		    OwnerGrabButtonMask | ButtonReleaseMask);

  for(j=l=0; (j<fcol); j++)
    for(k=0; (k<frows) && (l<nent); k++,l++) {
      kid=&(m->item[l]);
      kid->m=&(ent[l]);
      kid->Parent=Parent; 
      w=&(kid->wd);
      InitWin(w,j*mlen,k*mht,mlen-2,mht-2,1,NULL);
      w->self=XCreateSimpleWindow(x11->disp,m->wd.self,
				  w->x,w->y,w->width,w->height,
				  w->bwidth,bg,bg);
      x11->RegisterCallback(x11,w->self,m->wd.self,
			    ChildCallBack,kid);
      x11->SetInputMask(x11,w->self,
			ButtonPressMask | ButtonReleaseMask | 
			OwnerGrabButtonMask | ExposureMask | 
			EnterWindowMask | LeaveWindowMask);
    }

  return m;
}
Beispiel #27
0
static void init_gmx(t_x11 *x11, char *program, int nfile, t_filenm fnm[],
                     const output_env_t oenv)
{
    Pixmap                pm;
    t_gmx                *gmx;
    XSizeHints            hints;
    int                   w0, h0;
    int                   natom, natom_trx;
    t_topology            top;
    int                   ePBC;
    matrix                box;
    t_trxframe            fr;
    t_trxstatus          *status;
    char                  quote[256];

    snew(gmx, 1);
    snew(gmx->wd, 1);

    ePBC = read_tpx_top(ftp2fn(efTPR, nfile, fnm),
                        NULL, box, &natom, NULL, NULL, &top);

    read_first_frame(oenv, &status, ftp2fn(efTRX, nfile, fnm), &fr, TRX_DONT_SKIP);
    close_trx(status);
    natom_trx = fr.natoms;

    /* Creates a simple window */
    w0 = DisplayWidth(x11->disp, x11->screen)-132;
    h0 = DisplayHeight(x11->disp, x11->screen)-140;
    bromacs(quote, 255);
    InitWin(gmx->wd, 0, 0, w0, h0, 3, quote);
    gmx->wd->self = XCreateSimpleWindow(x11->disp, x11->root,
                                        gmx->wd->x, gmx->wd->y,
                                        gmx->wd->width, gmx->wd->height,
                                        gmx->wd->bwidth, WHITE, BLACK);
    pm = XCreatePixmapFromBitmapData(x11->disp, x11->root,
                                     (char *)gromacs_bits, gromacs_width,
                                     gromacs_height,
                                     WHITE, BLACK, 1);
    hints.flags      = PMinSize;
    hints.min_width  = 2*EWIDTH+40;
    hints.min_height = EHEIGHT+LDHEIGHT+LEGHEIGHT+40;
    XSetStandardProperties(x11->disp, gmx->wd->self, gmx->wd->text, program,
                           pm, NULL, 0, &hints);

    x11->RegisterCallback(x11, gmx->wd->self, x11->root, MainCallBack, gmx);
    x11->SetInputMask(x11, gmx->wd->self,
                      ButtonPressMask     | ButtonReleaseMask |
                      OwnerGrabButtonMask | ExposureMask      |
                      StructureNotifyMask);

    /* The order of creating windows is important here! */
    /* Manager */
    gmx->man  = init_man(x11, gmx->wd->self, 0, 0, 1, 1, WHITE, BLACK, ePBC, box, oenv);
    gmx->logo = init_logo(x11, gmx->wd->self, false);

    /* Now put all windows in the proper place */
    move_gmx(x11, gmx, w0, h0, false);

    XMapWindow(x11->disp, gmx->wd->self);
    map_man(x11, gmx->man);

    /* Pull Down menu */
    gmx->pd = init_pd(x11, gmx->wd->self, gmx->wd->width,
                      x11->fg, x11->bg,
                      MSIZE, gmx_pd_size, gmx_pd, MenuTitle);

    /* Dialogs & Filters */

    gmx->filter = init_filter(&(top.atoms), ftp2fn_null(efNDX, nfile, fnm),
                              natom_trx);

    init_dlgs(x11, gmx);

    /* Now do file operations */
    set_file(x11, gmx->man, ftp2fn(efTRX, nfile, fnm), ftp2fn(efTPR, nfile, fnm));

    ShowDlg(gmx->dlgs[edFilter]);
}
Beispiel #28
0
int InitScreen ()
{
#ifndef INDEX_DAEMON

	extern int tgetent();      /* get termcap entry */
	char termname[40], *p;
	
	if ((p = (char *) getenv ("TERM")) == NULL) {
		fprintf (stderr, "%s: TERM variable must be set to use screen capabilities\n", progname);
		return (FALSE);
	}
	if (strcpy (termname, p) == NULL) {
		fprintf (stderr,"%s: Can't get TERM variable\n", progname);
		return (FALSE);
	}
	if (tgetent (_terminal, termname) != 1) {
		fprintf (stderr,"%s: Can't get entry for TERM\n", progname);
		return (FALSE);
	}

	/* load in all those pesky values */
	_clearscreen    = tgetstr ("cl", &ptr);
	_moveto         = tgetstr ("cm", &ptr);
	_cleartoeoln    = tgetstr ("ce", &ptr);
	_cleartoeos     = tgetstr ("cd", &ptr);
	_lines          = tgetnum ("li");
	_columns        = tgetnum ("co");
	_setinverse     = tgetstr ("so", &ptr);
	_clearinverse   = tgetstr ("se", &ptr);
	_setunderline   = tgetstr ("us", &ptr);
	_clearunderline = tgetstr ("ue", &ptr);
	_terminalinit   = tgetstr ("ti", &ptr);
	_terminalend    = tgetstr ("te", &ptr);
	_keypadlocal    = tgetstr ("ke", &ptr);
	_keypadxmit     = tgetstr ("ks", &ptr);

	_hp_glitch = tgetflag ("xs");

	InitWin ();

	if (!_clearscreen) {
		fprintf (stderr,
			"%s: Terminal must have clearscreen (cl) capability\n",progname);
		return (FALSE);
	}
	if (!_moveto) {
		fprintf (stderr,
			"%s: Terminal must have cursor motion (cm)\n", progname);
		return (FALSE);
	}
	if (!_cleartoeoln) {
		fprintf (stderr,
			"%s: Terminal must have clear to end-of-line (ce)\n", progname);
		return (FALSE);
	}
	if (!_cleartoeos) {
		fprintf (stderr,
			"%s: Terminal must have clear to end-of-screen (cd)\n", progname);
		return (FALSE);
	}
	if (_lines == -1)
		_lines = DEFAULT_LINES_ON_TERMINAL;
	if (_columns == -1)
		_columns = DEFAULT_COLUMNS_ON_TERMINAL;
	/* 
	 * kludge to workaround no inverse 
	 */
	if (_setinverse == 0) {
		_setinverse = _setunderline;
		_clearinverse = _clearunderline;
		if (_setinverse == 0)
			draw_arrow_mark = 1;
	}
	return (TRUE);

#else

	return (FALSE);

#endif /* INDEX_DAEMON */
}