コード例 #1
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;
}
コード例 #2
0
ファイル: xdlg.cpp プロジェクト: MelroLeandro/gromacs
void AddDlgItem(t_dlg *dlg, t_dlgitem *item)
{
#define EnterLeaveMask (EnterWindowMask | LeaveWindowMask)
#define UserMask (ButtonPressMask | KeyPressMask)
    static unsigned long InputMask[edlgNR] = {
        ExposureMask | UserMask | EnterLeaveMask, /* edlgBN */
        ExposureMask | UserMask | EnterLeaveMask, /* edlgRB */
        ExposureMask,                             /* edlgGB */
        ExposureMask | UserMask | EnterLeaveMask, /* edlgCB */
        0,                                        /* edlgPM */
        ExposureMask,                             /* edlgST */
        ExposureMask | UserMask | EnterLeaveMask  /* edlgET */
    };

    if (!dlg->win.self)
    {
        DoCreateDlg(dlg);
    }
    srenew(dlg->dlgitem, dlg->nitem+1);
    if (!item)
    {
        gmx_fatal(FARGS, "dlgitem not allocated");
    }
    item->win.self =
        XCreateSimpleWindow(dlg->x11->disp, dlg->win.self, item->win.x, item->win.y,
                            item->win.width, item->win.height,
                            item->win.bwidth, dlg->x11->fg, dlg->x11->bg);
    CheckWindow(item->win.self);

    dlg->x11->RegisterCallback(dlg->x11, item->win.self, dlg->win.self,
                               DlgCB, dlg);
    dlg->x11->SetInputMask(dlg->x11, item->win.self, InputMask[item->type]);

    switch (item->type)
    {
        case edlgPM:
            XSetWindowBackgroundPixmap(dlg->x11->disp, item->win.self, item->u.pixmap.pm);
            break;
        default:
            break;
    }
    dlg->dlgitem[dlg->nitem] = item;

    dlg->nitem++;
}