# X11 includes/libraries are only set in the ngmx subdirectory!
if(NOT X11_FOUND)
message(WARNING "X11 include files and/or libraries were not found. Will not build the GROMACS X11-binaries, such as ngmx")
+ else()
+ set(HAVE_X11 1)
+ include_directories(${X11_INCLUDE_DIR})
endif()
endif(GMX_X11)
add_subdirectory(gromacs)
add_subdirectory(programs)
-if (NOT GMX_FAHCORE AND NOT GMX_BUILD_MDRUN_ONLY)
- add_subdirectory(ngmx)
-endif()
if (NOT GMX_FAHCORE)
- add_subdirectory(contrib)
+ add_subdirectory(contrib)
endif()
/* Define for GetSystemInfo() */
#cmakedefine HAVE_SYSTEM_INFO
+/* Define for X-Windows */
+#cmakedefine HAVE_X11
+
/* Enable x86 gcc inline assembly */
#cmakedefine GMX_X86_GCC_INLINE_ASM
#endif
/* This macro calculates the size of a array */
-#define asize(a) (sizeof(a)/sizeof((a)[0]))
+#define asize(a) ((int)(sizeof(a)/sizeof((a)[0])))
#endif /* _macros_h */
+++ /dev/null
-if(X11_FOUND)
-
-set(NGMX_COMMON_SOURCE
- xutil.c xmb.c x11.c
- xdlghi.c fgrid.c xdlgitem.c
- popup.c pulldown.c xdlg.c
- manager.c buttons.c nmol.c
- nleg.c dialogs.c logo.c
- filter.c molps.c)
-
-include_directories(${X11_INCLUDE_DIR})
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-
-# List of programs with single corresponding *.c source file,
-# used to create build rules automatically.
-#
-set(NGMX_PROGRAMS
- ngmx g_xrama)
-
-foreach(PROG ${NGMX_PROGRAMS})
- add_executable(${PROG} ${PROG}.cpp ${NGMX_COMMON_SOURCE})
- target_link_libraries(${PROG} libgromacs ${GMX_EXTRA_LIBRARIES})
- gmx_add_man_page(${PROG})
- set_target_properties(${PROG} PROPERTIES OUTPUT_NAME "${PROG}${GMX_BINARY_SUFFIX}")
-endforeach(PROG)
-
-install(TARGETS ${NGMX_PROGRAMS}
- COMPONENT ngmx
- RUNTIME DESTINATION ${BIN_INSTALL_DIR})
-
-endif(X11_FOUND)
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- *
- * And Hey:
- * Gyas ROwers Mature At Cryogenic Speed
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <math.h>
-#include <smalloc.h>
-#include <sysstuff.h>
-#include <string2.h>
-#include <Xstuff.h>
-#include "xutil.h"
-#include "futil.h"
-
-typedef struct {
- XColor xc;
- t_windata wd;
-} t_col;
-
-typedef struct {
- t_windata wd;
- t_windata but;
- int ncol;
- t_col *col;
-} t_sc;
-
-static gmx_bool ColCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
-{
- t_col *col;
- XColor *xc;
- int r, g, b;
- t_windata *wd;
-
- col = (t_col *)data;
- xc = &(col->xc);
- wd = &(col->wd);
- switch (event->type)
- {
- case ButtonPress:
- r = xc->red >> 8;
- g = xc->green >> 8;
- b = xc->blue >> 8;
- printf("%6d%6d%6d\t\t%-20s\n", r, g, b, wd->text);
- break;
- }
- return FALSE;
-}
-
-static gmx_bool BCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
-{
- t_sc *sc;
-
- sc = (t_sc *)data;
- switch (event->type)
- {
- case Expose:
- XSetForeground(x11->disp, x11->gc, sc->col[sc->ncol-1].xc.pixel);
- TextInWin(x11, &sc->but, sc->but.text, eXCenter, eYCenter);
- break;
- case ConfigureNotify:
- sc->but.width = event->xconfigure.width;
- sc->but.height = event->xconfigure.height;
- break;
- case EnterNotify:
- LightBorder(x11->disp, sc->but.self, sc->col[sc->ncol-1].xc.pixel);
- break;
- case LeaveNotify:
- LightBorder(x11->disp, sc->but.self, sc->col[0].xc.pixel);
- break;
- case ButtonPress:
- x11->UnRegisterCallback(x11, sc->wd.self);
- x11->UnRegisterCallback(x11, sc->but.self);
- return TRUE;
- }
- return FALSE;
-}
-
-static gmx_bool scCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
-{
- t_sc *sc;
- int i;
- int nx, ny, X, Y, Dx, Dy, th;
- float x, y, dx, dy;
-
- th = XTextHeight(x11->font)+6;
- sc = (t_sc *)data;
- switch (event->type)
- {
- case ConfigureNotify:
- x = sc->wd.width = event->xconfigure.width;
- y = sc->wd.height = event->xconfigure.height-th;
- if ((x >= 100) && (y >= 100))
- {
-#ifdef DEBUG
- printf("Disp: %x, But: %x, Font: %x x: %d, th: %d\n",
- x11->disp, sc->but.self, x11->font, (int)x, th);
-#endif
- XResizeWindow(x11->disp, sc->but.self, (int)x-4, th-4);
- nx = sqrt(sc->ncol);
- ny = sc->ncol/nx;
- while (nx*ny < sc->ncol)
- {
- ny++;
- }
- dx = ((float)x) / nx;
- dy = ((float)y) / ny;
- for (i = 0; (i < sc->ncol); i++)
- {
- X = x = (i%nx) * dx;
- Y = y = (i/nx) * dy;
- Dx = (int)(x+dx)-X;
- Dy = (int)(y+dy)-Y;
- XMoveWindow(x11->disp, sc->col[i].wd.self, X, th+Y);
- XResizeWindow(x11->disp, sc->col[i].wd.self, Dx, Dy);
- }
- }
- break;
- }
- return FALSE;
-}
-
-static int col_comp(const void *c1, const void *c2)
-{
- XColor *x1, *x2;
- int dr, dg;
- int diff;
-
- x1 = &(((t_col *)c1)->xc);
- x2 = &(((t_col *)c2)->xc);
-
- /* sort on intensity */
- diff = (x1->red+x1->green+x1->blue)-(x2->red+x2->green+x2->blue);
-
- if (diff == 0)
- {
- if ((dr = (x1->red-x2->red)) != 0)
- {
- return dr;
- }
- if ((dg = (x1->green-x2->green)) != 0)
- {
- return dg;
- }
- return x1->blue-x2->blue;
- }
- else
- {
- return diff;
- }
-}
-
-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;
-}
-
-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;
-}
-
-int
-main(int argc, char *argv[])
-{
- t_x11 *x11;
- t_sc *sc;
- char *fn;
-
- x11 = GetX11(&argc, argv);
- if (argc > 1)
- {
- fn = argv[1];
- }
- else
- {
- fn = "/usr/lib/X11/rgb.txt";
- }
- if (!gmx_fexist(fn))
- {
- fprintf(stderr, "Usage: %s rgb.txt\n", argv[0]);
- fprintf(stderr, "rgb.txt is usually somewhere in your X windows directories.\n");
- exit(1);
- }
- sc = init_sc(x11, x11->root, fn);
- XMapWindow(x11->disp, sc->wd.self);
- XMapSubwindows(x11->disp, sc->wd.self);
- x11->MainLoop(x11);
- x11->CleanUp(x11);
-
- return 0;
-}
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- *
- * And Hey:
- * Gyas ROwers Mature At Cryogenic Speed
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-#include "macros.h"
-#include "Xstuff.h"
-#include "xutil.h"
-#include "futil.h"
-#include "x11.h"
-#include "smalloc.h"
-#include "statutil.h"
-#include "rama.bm"
-#include "nrama.h"
-
-#include "gromacs/commandline/cmdlinemodulemanager.h"
-
-#define MAXDEG 360
-
-enum {
- ebQuit, ebStart, ebStop, ebRewind, ebGly, ebutNR
-};
-
-static real scx, scy;
-#define SX(x) ((int)(((x)+M_PI)*scx))
-#define SY(y) ((int)((M_PI-(y))*scy))
-
-enum {
- esStop, esGo, esNR
-};
-
-typedef struct {
- int status;
- gmx_bool bShowGly;
- gmx_bool *bIsGly;
- t_windata wd;
- t_windata xrwd;
- t_xrama *xr;
- t_windata but[ebutNR];
-} t_app;
-
-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);
- }
-}
-
-static gmx_bool label_pp(t_x11 *x11, Window w, int npp, t_phipsi pp[],
- t_dih dih[], int mx, int my)
-{
- int d, md, x0, y0;
- int i, imin;
-
- imin = -1;
- md = 16;
- for (i = 0; (i < npp); i++)
- {
- x0 = SX(dih[pp[i].iphi].ang);
- y0 = SY(dih[pp[i].ipsi].ang);
- d = (mx-x0)*(mx-x0)+(my-y0)*(my-y0);
- if (d < md)
- {
- md = d;
- imin = i;
- }
- }
- if (imin != -1)
- {
- pp[imin].bShow = !pp[imin].bShow;
- return TRUE;
- }
- return FALSE;
-}
-
-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;
-}
-
-static gmx_bool appCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
-{
- t_app *app;
- int win;
-
- app = (t_app *)data;
- for (win = 0; (win < ebutNR); win++)
- {
- if (app->but[win].self == w)
- {
- break;
- }
- }
- if (win == ebutNR)
- {
- return FALSE;
- }
-
- switch (event->type)
- {
- case Expose:
- TextInWin(x11, &(app->but[win]), app->but[win].text, eXCenter, eYCenter);
- break;
- case ButtonPress:
- switch (win)
- {
- case ebQuit:
- exit(1);
- case ebStart:
- app->status = esGo;
- ExposeWin(x11->disp, app->xrwd.self);
- break;
- case ebStop:
- app->status = esStop;
- break;
- case ebRewind:
- rewind_trj(app->xr->traj);
- break;
- case ebGly:
- app->bShowGly = !app->bShowGly;
- ExposeWin(x11->disp, app->xrwd.self);
- break;
- default:
- XBell(x11->disp, 50);
- break;
- }
- break;
- }
- return FALSE;
-}
-
-static void size_app(t_x11 *x11, t_app *app)
-{
- int i, dx, th;
-
- th = XTextHeight(x11->font)+4;
- dx = app->wd.width/ebutNR;
- for (i = 0; (i < ebutNR); i++)
- {
- app->but[i].width = dx-4;
- app->but[i].height = th+4;
- XMoveResizeWindow(x11->disp, app->but[i].self, i*dx+2, 2, dx-4, th+4);
- }
- XMoveResizeWindow(x11->disp, app->xrwd.self, 2, th+10,
- app->wd.width-6, app->wd.height-th-10-4);
-}
-
-static gmx_bool mainCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
-{
- t_app *app;
- int wt, ht;
-
- app = (t_app *)data;
- switch (event->type)
- {
- case ConfigureNotify:
- wt = event->xconfigure.width;
- ht = event->xconfigure.height;
- if ((app->wd.width != wt) || (app->wd.height != ht))
- {
- fprintf(stderr, "New wxh = %dx%d\n", wt, ht);
- app->wd.width = wt;
- app->wd.height = ht;
- size_app(x11, app);
- }
- break;
- }
- return FALSE;
-}
-
-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;
-}
-
-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;
-}
-
-static void mk_gly(t_app *app)
-{
- int i;
-
- snew(app->bIsGly, app->xr->npp);
- for (i = 0; (i < app->xr->npp); i++)
- {
- if (strstr(app->xr->pp[i].label, "GLY") != NULL)
- {
- app->bIsGly[i] = TRUE;
- }
- }
-}
-
-int gmx_xrama(int argc, char *argv[])
-{
- const char *desc[] = {
- "[TT]g_xrama[tt] shows a Ramachandran movie, that is, it shows",
- "the Phi/Psi angles as a function of time in an X-Window.[PAR]"
- "Static Phi/Psi plots for printing can be made with [TT]g_rama[tt].[PAR]",
- "Some of the more common X command line options can be used:[BR]",
- "[TT]-bg[tt], [TT]-fg[tt] change colors, [TT]-font fontname[tt], changes the font."
- };
-
- output_env_t oenv;
- t_x11 *x11;
- t_app *app;
- t_filenm fnm[] = {
- { efTRX, "-f", NULL, ffREAD },
- { efTPX, NULL, NULL, ffREAD }
- };
-#define NFILE asize(fnm)
-
- if (!parse_common_args(&argc, argv, PCA_CAN_TIME, NFILE, fnm,
- 0, NULL, asize(desc), desc, 0, NULL, &oenv))
- {
- return 0;
- }
-
-
- if ((x11 = GetX11(&argc, argv)) == NULL)
- {
- fprintf(stderr, "Can't open display, set your DISPLAY environment variable\n");
- exit(1);
- }
- XSetForeground(x11->disp, x11->gc, x11->fg);
- app = init_app(x11, argc, argv);
-
- init_rama(oenv, ftp2fn(efTRX, NFILE, fnm), ftp2fn(efTPX, NFILE, fnm),
- app->xr, 3);
- mk_gly(app);
-
- XMapWindow(x11->disp, app->wd.self);
- XMapSubwindows(x11->disp, app->wd.self);
- x11->MainLoop(x11);
- x11->CleanUp(x11);
-
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- return gmx::CommandLineModuleManager::runAsMainCMain(argc, argv, &gmx_xrama);
-}
+++ /dev/null
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 1991-2001
- * BIOSON Research Institute, Dept. of Biophysical Chemistry
- * University of Groningen, The Netherlands
- * Copyright (c) 2012, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-
-#define rama_width 48
-#define rama_height 48
-static unsigned char rama_bits[] = {
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x80, 0x00, 0x00, 0x00,
- 0x80, 0x0d, 0x80, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x18, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00,
- 0x18, 0x33, 0x80, 0x00, 0x00, 0x00, 0x18, 0x30, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, 0x00, 0x03, 0x00,
- 0x00, 0x63, 0x80, 0x00, 0x00, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00};
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- *
- * And Hey:
- * Gyas ROwers Mature At Cryogenic Speed
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <xdlghi.h>
-
-int main(int argc, char *argv[])
-{
- t_x11 *x11;
- t_dlg *dlg;
-
- if ((x11 = GetX11(&argc, argv)) == NULL)
- {
- fprintf(stderr, "No X!\n");
- exit(1);
- }
- if (argc > 1)
- {
- dlg = ReadDlg(x11, 0, x11->title, x11->fg, x11->bg, argv[1], 100, 100, TRUE,
- TRUE, NULL, NULL);
- ShowDlg(dlg);
- x11->MainLoop(x11);
- }
- else
- {
- fprintf(stderr, "Usage: %s [ X options ] infile\n", argv[0]);
- }
-
- x11->CleanUp(x11);
-
- return 0;
-}
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
- *
- * And Hey:
- * Gyas ROwers Mature At Cryogenic Speed
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "sysstuff.h"
-#include "smalloc.h"
-#include "x11.h"
-#include "string2.h"
-#include "macros.h"
-#include "fgrid.h"
-#include "futil.h"
-#include "xdlg.h"
-#include "xdlghi.h"
-
-typedef struct {
- int nopt, nAppl;
- char **name;
- char **description;
- char **dlgfile;
- t_dlg *dlg;
- t_dlg *appl;
-} t_data;
-
-static void ApplCallback(t_x11 *x11, int dlg_mess, int item_id,
- char *set, void *dta)
-{
- t_data *data;
- t_dlg *dlg;
- t_dlgitem *item;
- int i;
- char doit[1024];
-
- data = (t_data *)dta;
- dlg = data->appl;
-
- fprintf(stderr, "item_id: %d (%s)\n", item_id, set);
- if (gmx_strcasecmp(set, "OK") == 0)
- {
- /* Doit */
- sprintf(doit,
- "xterm -geometry +100+100 -n %s"
- " -title \"GROMACS: %s\" -e nice %s ",
- data->name[data->nAppl],
- data->name[data->nAppl],
- data->name[data->nAppl]);
- for (i = 0; (i < dlg->nitem); i++)
- {
- item = dlg->dlgitem[i];
- switch (item->type)
- {
- case edlgRB:
- strcat(doit, item->set);
- strcat(doit, " ");
- break;
- case edlgCB:
- if (item->u.checkbox.bChecked)
- {
- strcat(doit, item->set);
- }
- strcat(doit, " ");
- break;
- case edlgET:
- if (strlen(item->u.edittext.buf) > 0)
- {
- strcat(doit, item->set);
- strcat(doit, " ");
- strcat(doit, item->u.edittext.buf);
- strcat(doit, " ");
- }
- break;
- default:
- fprintf(stderr, "Type: %d\n", item->type);
- }
- }
- strcat(doit, " &");
- fprintf(stderr, "Going to exec: '%s'\n", doit);
-
-#ifdef GMX_NO_SYSTEM
- printf("Warning-- No calls to system(3) supported on this platform.");
- printf("Warning-- Skipping execution of 'system(\"%s\")'.", buf);
-#else
- system(doit);
-#endif
-
- HideDlg(data->appl);
- }
- else if (gmx_strcasecmp(set, "Cancel") == 0)
- {
- data->nAppl = -1;
- HideDlg(data->appl);
- }
-}
-
-static void Callback(t_x11 *x11, int dlg_mess, int item_id,
- char *set, void *dta)
-{
- t_data *data = (t_data *)dta;
-
- if (item_id == data->nopt)
- {
- fprintf(stderr, "Doei...\n");
- exit(0);
- }
- else
- {
- fprintf(stderr, "%d: %s\n", item_id, data->description[item_id]);
- if (data->nAppl != -1)
- {
- HideDlg(data->appl);
- }
- data->nAppl = item_id;
- data->appl = ReadDlg(x11, 0, data->name[item_id],
- BLACK, LIGHTGREY, data->dlgfile[item_id],
- 50, 50, FALSE, FALSE, ApplCallback, data);
- ShowDlg(data->appl);
- }
-}
-
-static void read_opts(t_data *data)
-{
- FILE *in;
- char fn[STRLEN], buf[STRLEN];
- int i, n;
-
- sprintf(fn, "xstat.dat");
- in = libopen(fn);
- fscanf(in, "%d", &n);
- data->nopt = n;
- snew(data->name, data->nopt);
- snew(data->description, data->nopt);
- snew(data->dlgfile, data->nopt);
-
- for (i = 0; (i < data->nopt); i++)
- {
- ReadQuoteString(fn, in, buf);
- data->name[i] = strdup(buf);
- ReadQuoteString(fn, in, buf);
- data->description[i] = strdup(buf);
- ReadQuoteString(fn, in, buf);
- data->dlgfile[i] = strdup(buf);
- }
- ffclose(in);
-}
-
-static void add_opts(t_x11 *x11, t_data *data)
-{
- t_dlgitem *but;
- int i, y0, w;
-
- y0 = OFFS_Y;
- for (i = 0; (i < data->nopt); i++)
- {
- but = CreateButton(x11, data->description[i], FALSE,
- (t_id)i, (t_id)0,
- OFFS_X, y0, 0, 0, 1);
- AddDlgItem(data->dlg, but);
- y0 += but->win.height+OFFS_Y;
- }
- but = CreateButton(x11, "Quit", TRUE, (t_id)data->nopt, (t_id)0,
- OFFS_X, y0, 0, 0, 1);
- AddDlgItem(data->dlg, but);
- y0 += but->win.height+OFFS_Y;
-
- w = 0;
- for (i = 0; (i <= data->nopt); i++)
- {
- w = max(w, QueryDlgItemW(data->dlg, i));
- }
- w += 2*OFFS_X;
- for (i = 0; (i <= data->nopt); i++)
- {
- SetDlgItemSize(data->dlg, i, w, 0);
- }
- SetDlgSize(data->dlg, w+2*OFFS_X, y0, TRUE);
-}
-
-int
-main(int argc, char *argv[])
-{
- t_x11 *x11;
- t_data data;
-
- /* Initiate X and data */
- if ((x11 = GetX11(&argc, argv)) == NULL)
- {
- fprintf(stderr, "Can't open DISPLAY\n");
- exit(1);
- }
- read_opts(&data);
- data.dlg = CreateDlg(x11, 0, argv[0], 0, 0, 0, 0, 0, BLACK, LIGHTGREY, Callback, &data);
- add_opts(x11, &data);
- data.nAppl = -1;
-
- ShowDlg(data.dlg);
- x11->MainLoop(x11);
- HideDlg(data.dlg);
-}
include_directories(${CMAKE_SOURCE_DIR}/src/gromacs/gmxpreprocess)
file(GLOB MDRUN_SOURCES mdrun/*.c mdrun/*.cpp)
+if(X11_FOUND)
+ file(GLOB VIEW_SOURCES view/*.cpp)
+else()
+ file(GLOB VIEW_SOURCES view/view.cpp)
+endif(X11_FOUND)
if(GMX_FAHCORE)
add_library(fahcore ${MDRUN_SOURCES})
install(TARGETS mdrun DESTINATION ${BIN_INSTALL_DIR} COMPONENT mdrun)
else()
file(GLOB GMX_EXECUTABLE_SOURCES gmx/*.c gmx/*.cpp)
- add_executable(gmx ${GMX_EXECUTABLE_SOURCES} ${MDRUN_SOURCES})
- target_link_libraries(gmx
- ${GMX_EXTRA_LIBRARIES} libgromacs ${GMX_EXE_LINKER_FLAGS})
+ add_executable(gmx ${GMX_EXECUTABLE_SOURCES} ${MDRUN_SOURCES} ${VIEW_SOURCES})
+ if(X11_FOUND)
+ target_link_libraries(gmx
+ ${GMX_EXTRA_LIBRARIES} libgromacs ${GMX_EXE_LINKER_FLAGS} ${X11_LIBRARIES})
+ else()
+ target_link_libraries(gmx
+ ${GMX_EXTRA_LIBRARIES} libgromacs ${GMX_EXE_LINKER_FLAGS})
+ endif(X11_FOUND)
set_target_properties(gmx PROPERTIES
OUTPUT_NAME "gmx${GMX_BINARY_SUFFIX}"
COMPILE_FLAGS "${OpenMP_C_FLAGS}")
#include "gromacs/gmxana/gmx_ana.h"
+#include "../view/view.h"
#include "../mdrun/mdrun_main.h"
extern "C"
"Perform weighted histogram analysis after umbrella sampling");
registerModule(manager, &gmx_wheel, "wheel",
"Plot helical wheels");
+ registerModule(manager, &gmx_view, "view",
+ "View a trajectory on an X-Windows terminal");
// TODO: Also include binaries from other directories than src/tools/:
// "g_xrama|Show animated Ramachandran plots");
// "mdrun|finds a potential energy minimum and calculates the Hessian");
// "mdrun|with -rerun (re)calculates energies for trajectory frames");
- // "ngmx|Display a trajectory");
}
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#include <string.h>
#include <smalloc.h>
#include <macros.h>
-#include <x11.h>
-#include <xutil.h>
+#include "x11.h"
+#include "xutil.h"
#include "buttons.h"
#include "stop_ani.bm"
#include "play.bm"
{
int x0, y0;
int i, bw;
- real idb, bh;
+ real idb, bh, one = 1.0;
t_windata *wd;
- bw = max(1, bbox->wd.width-2*(AIR+BORDER));
+ bw = std::max(1, bbox->wd.width-2*(AIR+BORDER));
idb = bbox->nbut;
bh = (bbox->wd.height-AIR*(bbox->nbut+1));
bh /= idb;
- bh = max(bh, 1.0);
+ bh = std::max(bh, one);
x0 = AIR;
y0 = AIR;
}
}
-static gmx_bool BBCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool BBCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_butbox *bbox;
bbox->wd.height = event->xconfigure.height;
move_bbox(x11, bbox);
}
- return FALSE;
+ return false;
}
-static gmx_bool VBCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool VBCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_butbox *vbox;
int y0;
XDrawLine(x11->disp, vbox->wd.self, x11->gc, 0, y0, vbox->wd.width, y0);
XSetForeground(x11->disp, x11->gc, x11->fg);
}
- return FALSE;
+ return false;
}
void set_vbtime(t_x11 *x11, t_butbox *vbox, char *text)
ExposeWin(x11->disp, vbox->wd.self);
}
-static gmx_bool ButtonCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool ButtonCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
XEvent letter;
t_mwbut *but;
default:
break;
}
- return FALSE;
+ return false;
}
t_butbox *init_vbox(t_x11 *x11, Window Parent, Window SendTo, unsigned long fg, unsigned long bg)
#ifndef _buttons_h
#define _buttons_h
-#include <xutil.h>
+#include "xutil.h"
enum {
IDROTX, IDROTY, IDROTZ, IDTRANSX, IDTRANSY, IDTRANSZ, IDZOOM, IDBUTNR,
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
static t_dlg *about_mb(t_x11 *x11, t_gmx *gmx)
{
- char *lines[] = {
+ const char *lines[] = {
" G R O M A C S",
" Machine for Simulating Chemistry",
- " Copyright (c) 1992-2000",
- " Dept. of Biophysical Chemistry",
- " University of Groningen"
+ " Copyright (c) 1992-2013",
+ " Berk Hess, David van der Spoel, Erik Lindahl",
+ " and many collaborators!"
};
return MessageBox(x11, gmx->wd->self, gmx->wd->text,
static t_dlg *quit_mb(t_x11 *x11, t_gmx *gmx)
{
- char *lines[] = {
+ const char *lines[] = {
" Do you really want to Quit ?"
};
static t_dlg *help_mb(t_x11 *x11, t_gmx *gmx)
{
- char *lines[] = {
+ const char *lines[] = {
" Help will soon be added"
};
static t_dlg *ni_mb(t_x11 *x11, t_gmx *gmx)
{
- char *lines[] = {
+ const char *lines[] = {
" This feature has not been",
" implemented yet."
};
static void ExportCB(t_x11 *x11, int dlg_mess, int item_id,
char *set, void *data)
{
- gmx_bool bOk;
+ bool bOk;
t_gmx *gmx;
t_dlg *dlg;
{
static int ebond = -1;
static int ebox = -1;
- gmx_bool bOk, bBond = FALSE;
+ bool bOk, bBond = false;
int nskip, nwait;
t_gmx *gmx;
+ char *endptr;
gmx = (t_gmx *)data;
if (ebond == -1)
if (item_id <= eBNR)
{
ebond = item_id-1;
- bBond = FALSE;
+ bBond = false;
}
else if (item_id <= eBNR+esbNR+1)
{
ebox = item_id-eBNR-2;
- bBond = TRUE;
+ bBond = true;
}
else
{
case ebDPlus:
DO_NOT(gmx->man->bPlus);
#ifdef DEBUG
- fprintf(stderr, "gmx->man->bPlus=%s\n", gmx_bool_names[gmx->man->bPlus]);
+ fprintf(stderr, "gmx->man->bPlus=%s\n",
+ gmx->man->bPlus ? "true" : "false");
#endif
break;
- /*case ebSBox:
- set_box_type(x11,gmx->man->molw,ebond);
- break;*/
case ebRMPBC:
toggle_pbc(gmx->man);
break;
case ebCue:
DO_NOT(gmx->man->bSort);
#ifdef DEBUG
- fprintf(stderr, "gmx->man->bSort=%s\n", gmx_bool_names[gmx->man->bSort]);
+ fprintf(stderr, "gmx->man->bSort=%s\n",
+ gmx->man->bSort ? "true" : "false");
#endif
break;
case ebSkip:
- sscanf(set, "%d", &nskip);
+ nskip = strtol(set, &endptr, 10);
+ if (endptr != set)
+ {
#ifdef DEBUG
- fprintf(stderr, "nskip: %d frames\n", nskip);
+ fprintf(stderr, "nskip: %d frames\n", nskip);
#endif
- if (nskip >= 0)
- {
- gmx->man->nSkip = nskip;
+ if (nskip >= 0)
+ {
+ gmx->man->nSkip = nskip;
+ }
}
break;
case ebWait:
- sscanf(set, "%d", &nwait);
+ nwait = strtol(set, &endptr, 10);
+ if (endptr != set)
+ {
#ifdef DEBUG
- fprintf(stderr, "wait: %d ms\n", nwait);
+ fprintf(stderr, "wait: %d ms\n", nwait);
#endif
- if (nwait >= 0)
- {
- gmx->man->nWait = nwait;
+ if (nwait >= 0)
+ {
+ gmx->man->nWait = nwait;
+ }
}
default:
#ifdef DEBUG
esFUNCT = 1, esBSHOW, esINFIL, esINDEXFIL, esLSQ, esSHOW, esPLOTFIL
};
-static gmx_bool in_set(int i, int n, int set[])
+static bool in_set(int i, int n, int set[])
{
int j;
for (j = 0; (j < n); j++)
{
if (set[j] == i)
{
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
typedef t_dlg *t_mmb (t_x11 *x11, t_gmx *gmx);
typedef struct {
- eDialogs ed;
const char *dlgfile;
DlgCallback *cb;
} t_dlginit;
-typedef struct {
- eMBoxes ed;
- t_mmb *mmb;
- DlgCallback *cb;
-} t_mbinit;
-
void init_dlgs(t_x11 *x11, t_gmx *gmx)
{
static t_dlginit di[] = {
- { edExport, "export.dlg", ExportCB },
- { edBonds, "bonds.dlg", BondsCB }
+ { "export.dlg", ExportCB },
+ { "bonds.dlg", BondsCB }
};
- static t_mbinit mi[emNR] = {
- { emQuit, quit_mb, QuitCB },
- { emHelp, help_mb, MBCallback },
- { emAbout, about_mb, MBCallback },
- { emNotImplemented, ni_mb, MBCallback }
- };
- int i;
+ static t_mmb *mi[emNR] = { quit_mb, help_mb, about_mb, ni_mb };
+ unsigned int i;
snew(gmx->dlgs, edNR);
for (i = 0; (i < asize(di)); i++)
{
gmx->dlgs[i] = ReadDlg(x11, gmx->wd->self, di[i].dlgfile,
- x11->fg, x11->bg, di[i].dlgfile,
- 0, 0, TRUE, FALSE, di[i].cb, gmx);
+ di[i].dlgfile,
+ 0, 0, true, false, di[i].cb, gmx);
}
gmx->dlgs[edFilter] = select_filter(x11, gmx);
snew(gmx->mboxes, emNR);
for (i = 0; (i < emNR); i++)
{
- gmx->mboxes[i] = mi[i].mmb(x11, gmx);
+ gmx->mboxes[i] = mi[i](x11, gmx);
}
gmx->which_mb = -1;
}
#include "logo.h"
typedef struct {
- gmx_bool bMapped;
+ bool bMapped;
t_dlg *dlg;
} t_dialogs;
-typedef enum {
+enum eDialogs {
edExport, edBonds, edFilter, edNR
-} eDialogs;
+};
-typedef enum {
+enum eMBoxes {
emQuit, emHelp, emAbout, emNotImplemented, emNR
-} eMBoxes;
+};
-typedef enum {
+enum eExport {
eExpGromos, eExpPDB, eExpNR
-} eExport;
+};
typedef struct {
char confout[256]; /* Export file */
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
break;
}
fprintf(stderr, " in file %s\n", infile);
- fprintf(stderr, "C-File: %s, line: %d\n", file, line);
+ fprintf(stderr, "source file: %s, line: %d\n", file, line);
exit(1);
}
#define ReadDlgErr(in, er, es) ReadDlgError(in, er, es, __FILE__, __LINE__)
-static void GetBuf(FILE *in, char *buf)
-{
- int rc;
-
- rc = fscanf(in, "%s", buf);
-}
-
static void ReadAccOpen(const char *infile, FILE *in)
{
char buf[STRLEN];
- GetBuf(in, buf);
+ fscanf(in, "%4s", buf);
if (strcmp(buf, "{") != 0)
{
ReadDlgErr(infile, eACCOEXP, buf);
{
char buf[STRLEN];
- GetBuf(in, buf);
+ fscanf(in, "%4s", buf);
if (strcmp(buf, "}") != 0)
{
ReadDlgErr(infile, eACCCEXP, buf);
buf[i] = '\0';
}
-static gmx_bool bNotAccClose(const char *buf)
+static bool bNotAccClose(const char *buf)
{
return (strcmp(buf, "}") != 0);
}
{
/* Special case */
edlg = edlgBN;
- fitem->bDef = TRUE;
+ fitem->bDef = true;
}
if (edlg == edlgNR+1)
{
{
FILE *in;
char buf[STRLEN];
- char *gmxlib;
- char newinfile[STRLEN];
t_fgrid *fgrid;
t_fgroup *fgroup;
int gridx, gridy;
in = libopen(infile);
- GetBuf(in, buf);
+ fscanf(in, "%6s", buf);
if (strcmp(buf, "grid") != 0)
{
ReadDlgErr(infile, eGRIDEXP, buf);
}
fgrid = NewFGrid();
- if ((fscanf(in, "%d%d", &gridx, &gridy)) != 2)
+ if ((fscanf(in, "%5d%5d", &gridx, &gridy)) != 2)
{
ReadDlgErr(infile, eNOVALS, "grid w,h");
}
fgrid->w = gridx;
fgrid->h = gridy;
ReadAccOpen(infile, in);
- GetBuf(in, buf);
+ fscanf(in, "%15s", buf);
while (bNotAccClose(buf))
{
if (strcmp(buf, "group") == 0)
fgroup = AddFGridFGroup(fgrid);
ReadQuoteString(infile, in, buf);
fgroup->name = strdup(buf);
- if ((fscanf(in, "%d%d%d%d", &fgroup->x, &fgroup->y, &fgroup->w, &fgroup->h)) != 4)
+ if ((fscanf(in, "%5d%5d%5d%5d", &fgroup->x, &fgroup->y, &fgroup->w, &fgroup->h)) != 4)
{
ReadDlgErr(infile, eNOVALS, "group x,y,w,h");
}
ReadDlgErr(infile, eTOOHIGH, buf);
}
ReadAccOpen(infile, in);
- GetBuf(in, buf);
+ fscanf(in, "%15s", buf);
while (bNotAccClose(buf))
{
AddFGroupFItem(fgroup, ScanFItem(infile, in, buf));
- GetBuf(in, buf);
+ fscanf(in, "%15s", buf);
}
}
else if (strcmp(buf, "simple") == 0)
{
fsimple = AddFGridFSimple(fgrid);
- if ((fscanf(in, "%d%d%d%d", &fsimple->x, &fsimple->y, &fsimple->w, &fsimple->h)) != 4)
+ if ((fscanf(in, "%5d%5d%5d%5d", &fsimple->x, &fsimple->y, &fsimple->w, &fsimple->h)) != 4)
{
ReadDlgErr(infile, eNOVALS, "simple x,y,w,h");
}
ReadDlgErr(infile, eTOOHIGH, "simple");
}
ReadAccOpen(infile, in);
- GetBuf(in, buf);
+ fscanf(in, "%15s", buf);
fsimple->fitem = ScanFItem(infile, in, buf);
ReadAccClose(infile, in);
}
- GetBuf(in, buf);
+ fscanf(in, "%15s", buf);
}
ffclose(in);
#define _fgrid_h
#include <typedefs.h>
-#include <xdlg.h>
+#include "xdlgitem.h"
typedef struct {
edlgitem edlg;
- gmx_bool bDef;
+ bool bDef;
int nname;
char **name;
char *set, *get, *def, *help;
eTOOWIDE, eTOOHIGH, eQUOTE, eNOVALS
} eDLGERR;
-extern void ReadDlgErr(const char *infile, eDLGERR err, const char *s);
+void ReadDlgErr(const char *infile, eDLGERR err, const char *s);
-extern t_fgrid *FGridFromFile(const char *infile);
+t_fgrid *FGridFromFile(const char *infile);
-extern void DoneFGrid(t_fgrid *fgrid);
+void DoneFGrid(t_fgrid *fgrid);
-extern void DumpFGrid(t_fgrid *fgrid);
+void DumpFGrid(t_fgrid *fgrid);
-extern void ReadQuoteString(const char *infile, FILE *in, char *buf);
+void ReadQuoteString(const char *infile, FILE *in, char *buf);
#endif /* _fgrid_h */
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
{
snew(f->grps, 1);
snew(f->grps->index, 1);
- analyse(atoms, f->grps, &f->grpnames, FALSE, FALSE);
+ analyse(atoms, f->grps, &f->grpnames, false, false);
}
snew(f->bDisable, f->grps->nr);
for (g = 0; g < f->grps->nr; g++)
case DLG_SET:
if (set)
{
- if (sscanf(set, "%d", &nset) == 1)
+ if (sscanf(set, "%10d", &nset) == 1)
{
f->bShow[nset] = !f->bShow[nset];
}
len = strlen(title);
for (i = 0; (i < (int)gmx->filter->grps->nr); i++)
{
- len = max(len, (int)strlen(gmx->filter->grpnames[i]));
+ len = std::max(len, (int)strlen(gmx->filter->grpnames[i]));
}
len += 2;
fprintf(tmp, "}\n\n}\n");
fclose(tmp);
- dlg = ReadDlg(x11, gmx->wd->self, title, x11->fg, x11->bg, tmpfile,
- 0, 0, TRUE, FALSE, FilterCB, gmx);
+ dlg = ReadDlg(x11, gmx->wd->self, title, tmpfile,
+ 0, 0, true, false, FilterCB, gmx);
remove(tmpfile);
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#endif
#include "sysstuff.h"
+#include "macros.h"
#include "xutil.h"
#include "Xstuff.h"
#include "smalloc.h"
-#include "macros.h"
#include "copyrite.h"
#include "logo.h"
XUnmapWindow(x11->disp, logo->wd.self);
}
-static gmx_bool LogoCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool LogoCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
/* Assume window is 100x110 */
- static gmx_bool bFirst = TRUE;
+ static bool bFirst = true;
#define CSIZE 9
#define NSIZE 8
#define OSIZE 9
{ 40, YOFFS+22, CSIZE, &LIGHTGREEN },
{ 40, YOFFS+34, CSIZE, &LIGHTGREEN },
{ 50, YOFFS+12, CSIZE, &LIGHTGREEN },
- { 50, YOFFS, OSIZE, &LIGHTRED },
+ { 50, YOFFS, OSIZE, &LIGHTRED },
{ 60, YOFFS+22, NSIZE, &LIGHTCYAN },
{ 60, YOFFS+32, HSIZE, &WHITE },
{ 70, YOFFS+12, CSIZE, &LIGHTGREEN },
static t_mess Mess[] = {
{ "GROMACS", 0, 20, NULL },
{ NULL, 16, 9, NULL },
- { "Copyright (c) 1991-2010", COFFS+ 2, 9, NULL },
+ { "Copyright (c) 1991-2013", COFFS+ 2, 9, NULL },
{ "D.v.d.Spoel, E.Lindahl, B.Hess", COFFS+11, 9, NULL },
{ "& Groningen University ", COFFS+20, 9, NULL },
{ "click to dismiss", COFFS+31, 8, NULL }
Mess[i].fnt = (i == 0) ? logo->bigfont : (i == NMESS-1) ? x11->font :
logo->smallfont;
}
- bFirst = FALSE;
+ bFirst = false;
}
switch (event->type)
{
}
XSetForeground(x11->disp, x11->gc, BLACK);
XDrawRectangle(x11->disp, wd->self, x11->gc, 2, 2, wd->width-5, wd->height-5);
- for (i = 0; (i < asize(Mess)); i++)
+ for (i = 0; (i < NMESS); i++)
{
SpecialTextInRect(x11, Mess[i].fnt, wd->self, Mess[i].text,
0, Mess[i].y, wd->width, Mess[i].h,
break;
}
- return FALSE;
+ return false;
}
-t_logo *init_logo(t_x11 *x11, Window parent, gmx_bool bQuitOnClick)
+t_logo *init_logo(t_x11 *x11, Window parent, bool bQuitOnClick)
{
static const char *bfname[] = {
"-b&h-lucida-bold-i-normal-sans-34-240-100-100-p-215-iso8859-1",
"fixed"
};
#define NSF asize(sfname)
- int i;
+ unsigned int i;
unsigned long bg;
char *newcol;
t_logo *logo;
#ifndef _logo_h
#define _logo_h
-#include <x11.h>
-#include <xutil.h>
+#include "x11.h"
+#include "xutil.h"
typedef struct {
XFontStruct *bigfont;
XFontStruct *smallfont;
t_windata wd;
- gmx_bool bQuitOnClick;
+ bool bQuitOnClick;
} t_logo;
extern void show_logo(t_x11 *x11, t_logo *logo);
extern void hide_logo(t_x11 *x11, t_logo *logo);
-extern t_logo *init_logo(t_x11 *x11, Window parent, gmx_bool bQuitOnClick);
+extern t_logo *init_logo(t_x11 *x11, Window parent, bool bQuitOnClick);
extern void done_logo(t_x11 *x11, t_logo *logo);
}
static void add_bonds(t_manager *man, t_functype func[],
- t_ilist *b, gmx_bool bB[])
+ t_ilist *b, bool bB[])
{
- gmx_bool *bH = man->bHydro;
+ bool *bH = man->bHydro;
t_iatom *ia;
t_iatom type, ai, aj, ak;
int i, delta, ftype;
{
aj = ia[2];
ak = ia[3];
- bB[ai] = bB[aj] = bB[ak] = TRUE;
+ bB[ai] = bB[aj] = bB[ak] = true;
add_object(man, eOHBond, ai, aj);
add_object(man, eOHBond, ai, ak);
}
#ifdef DEBUG
fprintf(stderr, "Adding bond from %d to %d\n", ai, aj);
#endif
- bB[ai] = bB[aj] = TRUE;
+ bB[ai] = bB[aj] = true;
if (!(bH[ai] == bH[aj]))
{
add_object(man, eOHBond, ai, aj);
}
}
-static void add_bpl(t_manager *man, t_idef *idef, gmx_bool bB[])
+static void add_bpl(t_manager *man, t_idef *idef, bool bB[])
{
int ftype;
return NO_ATID;
}
-static void do_label(t_x11 *x11, t_manager *man, int x, int y, gmx_bool bSet)
+static void do_label(t_x11 *x11, t_manager *man, int x, int y, bool bSet)
{
atom_id ai;
unsigned long col;
if (bSet && !man->bLabel[ai])
{
col = WHITE;
- man->bLabel[ai] = TRUE;
+ man->bLabel[ai] = true;
}
else if (!bSet && man->bLabel[ai])
{
col = BLUE;
- man->bLabel[ai] = FALSE;
+ man->bLabel[ai] = false;
}
else
{
static void show_label(t_x11 *x11, t_manager *man, int x, int y)
{
- do_label(x11, man, x, y, TRUE);
+ do_label(x11, man, x, y, true);
}
static void hide_label(t_x11 *x11, t_manager *man, int x, int y)
{
- do_label(x11, man, x, y, FALSE);
+ do_label(x11, man, x, y, false);
}
void set_file(t_x11 *x11, t_manager *man, const char *trajectory,
char buf[256], quote[256];
t_tpxheader sh;
t_atoms *at;
- gmx_bool *bB;
- int i, idum;
+ bool *bB;
+ int i;
- read_tpxheader(status, &sh, TRUE, NULL, NULL);
+ read_tpxheader(status, &sh, true, NULL, NULL);
snew(man->ix, sh.natoms);
snew(man->zz, sh.natoms);
snew(man->col, sh.natoms);
snew(man->bVis, sh.natoms);
for (i = 0; (i < sh.natoms); i++)
{
- man->bVis[i] = FALSE;
+ man->bVis[i] = false;
}
- man->bPbc = FALSE;
+ man->bPbc = false;
snew(man->szLab, sh.natoms);
snew(man->bHydro, sh.natoms);
snew(bB, sh.natoms);
read_tpx_top(status, NULL, man->box, &man->natom, NULL, NULL, NULL, &man->top);
- man->gpbc = gmx_rmpbc_init(&man->top.idef, -1, man->natom, man->box);
+ man->gpbc = gmx_rmpbc_init(&man->top.idef, -1, man->natom);
man->natom =
read_first_x(man->oenv, &man->status, trajectory, &(man->time), &(man->x),
XSendEvent(x11->disp, letter.xclient.window, True, 0, &letter);
}
-gmx_bool ReadMonfile(char *fn, int *nbars, int *bars)
-{
- FILE *fp;
- if ((fp = fopen(fn, "r")) == NULL)
- {
- return(FALSE);
- }
- else
- {
- for ((*nbars) = 0; fscanf(fp, "%d", &bars[*nbars]) > 0; (*nbars)++)
- {
- ;
- }
- fclose(fp);
- return (TRUE);
- }
-}
-
static void reset_mols(t_block *mols, matrix box, rvec x[])
{
int i, m0, m1, j, m;
}
}
-static gmx_bool step_man(t_manager *man, int *nat)
+static bool step_man(t_manager *man, int *nat)
{
static int ncount = 0;
- static gmx_bool bWarn = FALSE;
- gmx_bool bEof;
- int dum;
+ static bool bWarn = false;
+ bool bEof;
const char *warn;
if (!man->natom)
fprintf(stderr, "Not initiated yet!");
exit(1);
}
- bEof = read_next_x(man->oenv, man->status, &man->time, man->natom, man->x, man->box);
+ bEof = read_next_x(man->oenv, man->status, &man->time, man->x, man->box);
*nat = man->natom;
if (ncount == man->nSkip)
{
if (warn && !bWarn)
{
fprintf(stderr, "\n%s\n", warn);
- bWarn = TRUE;
+ bWarn = true;
}
break;
case esbRect:
static void HandleClient(t_x11 *x11, t_manager *man, long data[])
{
- int ID, button, x, y;
- gmx_bool bPos;
- real fac;
+ int ID, button, x, y;
+ bool bPos;
+ real fac;
ID = data[0];
button = data[1];
if (man->status)
{
rewind_trj(man->status);
- read_next_x(man->oenv, man->status, &(man->time), man->natom, man->x,
+ read_next_x(man->oenv, man->status, &(man->time), man->x,
man->box);
- man->bEof = FALSE;
+ man->bEof = false;
draw_mol(x11, man);
}
break;
nat = 0;
if (!step_man(man, &nat))
{
- man->bEof = TRUE;
- man->bStop = TRUE;
+ man->bEof = true;
+ man->bStop = true;
}
else
{
break;
}
case IDFF:
- man->bStop = FALSE;
+ man->bStop = false;
break;
case IDSTOP_ANI:
- man->bStop = TRUE;
+ man->bStop = true;
break;
case IDDRAWMOL:
draw_mol(x11, man);
}
}
-static gmx_bool TitleCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool TitleCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_windata *wd;
wd->height = event->xconfigure.height;
break;
}
- return FALSE;
+ return false;
}
-static gmx_bool ManCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool ManCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_manager *man;
int width, height;
default:
break;
}
- return FALSE;
+ return false;
}
void no_labels(t_x11 *x11, t_manager *man)
for (i = 0; (i < man->natom); i++)
{
- man->bLabel[i] = FALSE;
+ man->bLabel[i] = false;
}
draw_mol(x11, man);
}
show_but(x11, man->bbox);
}
-gmx_bool toggle_animate (t_x11 *x11, t_manager *man)
+bool toggle_animate (t_x11 *x11, t_manager *man)
{
if (man->status)
{
man->bAnimate = !man->bAnimate;
- man->bStop = TRUE;
- man->bEof = FALSE;
+ man->bStop = true;
+ man->bEof = false;
if (man->bAnimate)
{
show_but(x11, man->vbox);
return man->bAnimate;
}
-gmx_bool toggle_pbc (t_manager *man)
+bool toggle_pbc (t_manager *man)
{
man->bPbc = !man->bPbc;
snew(man, 1);
man->status = NULL;
- man->bPlus = TRUE;
- man->bSort = TRUE;
+ 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,
for (i = 0; (i < man->natom); i++)
{
- man->bVis[i] = FALSE;
+ man->bVis[i] = false;
}
for (i = 0; (i < filter->grps->nr); i++)
{
{
for (j = filter->grps->index[i]; (j < filter->grps->index[i+1]); j++)
{
- man->bVis[filter->grps->a[j]] = TRUE;
+ man->bVis[filter->grps->a[j]] = true;
}
}
}
#define LDHEIGHT 0
#define LEGHEIGHT 60
-typedef enum {
+enum eObject {
eOSingle, eOBond, eOHBond, eONR
-} eObject;
+};
-typedef enum {
+enum eVisible {
eVNormal, eVSpecial, eVHidden, evNR
-} eVisible;
+};
-enum {
+enum eBwidth {
eBThin, eBFat, eBVeryFat, eBSpheres, eBNR
};
-enum {
+enum esBox {
esbNone, esbRect, esbTri, esbTrunc, esbNR
};
typedef struct {
t_windata wd; /* Mol window structure */
- gmx_bool bShowHydrogen; /* Show Hydrogens? */
+ bool bShowHydrogen; /* Show Hydrogens? */
int bond_type; /* Show one of the above bondtypes */
int ePBC; /* PBC type */
int boxtype; /* Rectangular, Tric, TruncOct (display)*/
typedef struct {
t_blocka *grps; /* Blocks with atom numbers */
char **grpnames; /* The names of the groups */
- gmx_bool *bDisable; /* Group indexes out of natoms in TRX */
- gmx_bool *bShow; /* Show a group ? */
+ bool *bDisable; /* Group indexes out of natoms in TRX */
+ bool *bShow; /* Show a group ? */
} t_filter;
/*
matrix box; /* The box */
int nobj; /* The number of objects */
t_object *obj; /* The objects on screen */
- gmx_bool *bHydro; /* TRUE for hydrogen atoms */
- gmx_bool *bLabel; /* Show a label on atom i? */
+ bool *bHydro; /* true for hydrogen atoms */
+ bool *bLabel; /* Show a label on atom i? */
char **szLab; /* Array of pointers to labels */
unsigned long *col; /* The colour of the atoms */
int *size; /* The size of the atoms */
real *vdw; /* The VDWaals radius of the atoms */
- gmx_bool *bVis; /* visibility of atoms */
- gmx_bool bPbc; /* Remove Periodic boundary */
- gmx_bool bAnimate; /* Animation going on? */
- gmx_bool bEof; /* End of file reached? */
- gmx_bool bStop; /* Stopped by user? */
- gmx_bool bSort; /* Sort the coordinates */
- gmx_bool bPlus; /* Draw plus for single atom */
+ bool *bVis; /* visibility of atoms */
+ bool bPbc; /* Remove Periodic boundary */
+ bool bAnimate; /* Animation going on? */
+ bool bEof; /* End of file reached? */
+ bool bStop; /* Stopped by user? */
+ bool bSort; /* Sort the coordinates */
+ bool bPlus; /* Draw plus for single atom */
int nSkip; /* Skip n steps after each frame */
int nWait; /* Wait n ms after each frame */
gmx_rmpbc_t gpbc; /* For removing peridiocity */
extern void move_man(t_x11 *x11, t_manager *man, int width, int height);
-extern gmx_bool toggle_animate (t_x11 *x11, t_manager *man);
+extern bool toggle_animate (t_x11 *x11, t_manager *man);
-extern gmx_bool toggle_pbc (t_manager *man);
+extern bool toggle_pbc (t_manager *man);
extern void no_labels(t_x11 *x11, t_manager *man);
/* Turn off all labels */
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
}
}
-static gmx_bool local_pbc_dx(rvec x1, rvec x2)
+static bool local_pbc_dx(rvec x1, rvec x2)
{
int i;
real dx;
dx = x1[i]-x2[i];
if (dx > gl_hbox[i])
{
- return FALSE;
+ return false;
}
else if (dx <= gl_mhbox[i])
{
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
static void ps_draw_bond(t_psdata ps,
atom_id ai, atom_id aj, iv2 vec2[],
- rvec x[], char **atomnm[], int size[], gmx_bool bBalls)
+ rvec x[], char **atomnm[], int size[], bool bBalls)
{
char *ic, *jc;
int xi, yi, xj, yj;
}
void ps_draw_objects(t_psdata ps, int nobj, t_object objs[], iv2 vec2[], rvec x[],
- char **atomnm[], int size[], gmx_bool bShowHydro, int bond_type,
- gmx_bool bPlus)
+ char **atomnm[], int size[], bool bShowHydro, int bond_type,
+ bool bPlus)
{
- gmx_bool bBalls;
+ bool bBalls;
int i;
t_object *obj;
- bBalls = FALSE;
+ bBalls = false;
for (i = 0; (i < nobj); i++)
{
obj = &(objs[i]);
void ps_draw_mol(t_psdata ps, t_manager *man)
{
- static char tstr[2][20];
- static int ntime = 0;
t_windata *win;
t_3dview *view;
t_molwin *mw;
/* Start drawing
XClearWindow(x11->disp,win->self); */
- /* Draw Time
- sprintf(tstr[ntime],"Time: %.3 ps",man->time);
- if (strcmp(tstr[ntime],tstr[1-ntime]) != 0) {
- set_vbtime(x11,man->vbox,tstr[ntime]);
- ntime=1-ntime;
- }*/
-
if (mw->boxtype != esbNone)
{
draw_box(ps, view, man->box, x0, y0, sx, sy);
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
int search_ac(const char *type)
{
- int i, nb, mij, best, besti;
+ unsigned int i, nb, mij, best, besti;
best = 0;
besti = 0;
- if (type)
+ if (NULL != type)
{
for (i = 0; (i < NAC); i++)
{
- mij = min((int)strlen(type), (int)strlen(ac[i].tp));
+ mij = std::min((int)strlen(type), (int)strlen(ac[i].tp));
for (nb = 0; (nb < mij); nb++)
{
if (type[nb] != ac[i].tp[nb])
XSetForeground(x11->disp, x11->gc, x11->fg);
}
-static gmx_bool LegWCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool LegWCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_legendwin *lw;
default:
break;
}
- return FALSE;
+ return false;
}
t_legendwin *init_legw(t_x11 *x11, Window Parent,
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#define MSIZE 4
-static gmx_bool MWCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool MWCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_molwin *mw;
Window To;
default:
break;
}
- return FALSE;
+ return false;
}
void set_def (t_molwin *mw, int ePBC, matrix box)
{
- mw->bShowHydrogen = TRUE;
+ mw->bShowHydrogen = true;
mw->bond_type = eBFat;
mw->ePBC = ePBC;
mw->boxtype = esbRect;
XMapWindow(x11->disp, mw->wd.self);
}
-gmx_bool toggle_hydrogen(t_x11 *x11, t_molwin *mw)
+bool toggle_hydrogen(t_x11 *x11, t_molwin *mw)
{
mw->bShowHydrogen = !mw->bShowHydrogen;
ExposeWin(x11->disp, mw->wd.self);
static void draw_atom(Display *disp, Window w, GC gc,
atom_id ai, iv2 vec2[], unsigned long col[], int size[],
- gmx_bool bBall, gmx_bool bPlus)
+ bool bBall, bool bPlus)
{
int xi, yi;
}
}
-static gmx_bool local_pbc_dx(rvec x1, rvec x2)
+static bool local_pbc_dx(rvec x1, rvec x2)
{
int i;
real dx;
dx = x1[i]-x2[i];
if (dx > gl_hbox[i])
{
- return FALSE;
+ return false;
}
else if (dx <= gl_mhbox[i])
{
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
static void draw_bond(Display *disp, Window w, GC gc,
atom_id ai, atom_id aj, iv2 vec2[],
- rvec x[], unsigned long col[], int size[], gmx_bool bBalls)
+ rvec x[], unsigned long col[], int size[], bool bBalls)
{
unsigned long ic, jc;
int xi, yi, xj, yj;
if (bBalls)
{
- draw_atom(disp, w, gc, ai, vec2, col, size, TRUE, FALSE);
- draw_atom(disp, w, gc, aj, vec2, col, size, TRUE, FALSE);
+ draw_atom(disp, w, gc, ai, vec2, col, size, true, false);
+ draw_atom(disp, w, gc, aj, vec2, col, size, true, false);
}
else
{
{
if (obj->eV != eVHidden)
{
- man->bVis[obj->ai] = TRUE;
+ man->bVis[obj->ai] = true;
switch (obj->eO)
{
case eOBond:
case eOHBond:
- man->bVis[obj->aj] = TRUE;
+ man->bVis[obj->aj] = true;
break;
default:
break;
{
int i, nobj, nvis, nhide;
atom_id ai;
- gmx_bool bAdd, *bVis;
+ bool bAdd, *bVis;
t_object *obj;
t_object *newobj;
void draw_objects(Display *disp, Window w, GC gc, int nobj,
t_object objs[], iv2 vec2[], rvec x[],
- unsigned long col[], int size[], gmx_bool bShowHydro, int bond_type,
- gmx_bool bPlus)
+ unsigned long col[], int size[], bool bShowHydro, int bond_type,
+ bool bPlus)
{
- gmx_bool bBalls;
+ bool bBalls;
int i;
t_object *obj;
- bBalls = FALSE;
+ bBalls = false;
switch (bond_type)
{
case eBThin:
XSetLineAttributes(disp, gc, 5, LineSolid, CapNotLast, JoinRound);
break;
case eBSpheres:
- bBalls = TRUE;
- bPlus = FALSE;
+ bBalls = true;
+ bPlus = false;
break;
default:
gmx_fatal(FARGS, "Invalid bond_type selected: %d\n", bond_type);
extern int filter_vis(t_manager *man);
extern void set_sizes(t_manager *man, real sx, real sy);
-extern gmx_bool toggle_hydrogen(t_x11 *x11, t_molwin *mw);
+extern bool toggle_hydrogen(t_x11 *x11, t_molwin *mw);
/* Toggle the state of the hydrogen drawing,
* return the current state
*/
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#include <math.h>
#include <macros.h>
#include <smalloc.h>
-#include <x11.h>
-#include <xutil.h>
+#include "x11.h"
+#include "xutil.h"
#include "popup.h"
-gmx_bool ChildCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+bool ChildCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_child *child;
t_mentry *m;
default:
break;
}
- return FALSE;
+ return false;
}
-gmx_bool MenuCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+bool MenuCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_menu *m;
default:
break;
}
- return FALSE;
+ return false;
}
t_menu *init_menu(t_x11 *x11, Window Parent, unsigned long fg, unsigned long bg,
mlen = 0;
for (i = 0; (i < nent); i++)
{
- mlen = max(mlen, XTextWidth(x11->font, ent[i].str, strlen(ent[i].str)));
+ mlen = std::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 */
return m;
}
-void show_menu(t_x11 *x11, t_menu *m, int x, int y, gmx_bool bGrab)
+void show_menu(t_x11 *x11, t_menu *m, int x, int y, bool bGrab)
{
XMoveWindow(x11->disp, m->wd.self, x, y);
m->bGrabbed = bGrab;
XUnmapWindow(x11->disp, m->wd.self);
}
-void check_menu_item(t_menu *m, int nreturn, gmx_bool bStatus)
+void check_menu_item(t_menu *m, int nreturn, bool bStatus)
{
int i;
typedef struct {
Window send_to; /* Window to send messages to */
int nreturn; /* Value returned when entry is selected */
- gmx_bool bChecked; /* Indicate whether menu item is check-marked */
+ bool bChecked; /* Indicate whether menu item is check-marked */
const char *str; /* Text for menu entry */
} t_mentry;
Window Parent; /* The parent of the menu */
int nitem; /* The number of menu items */
t_child *item; /* Array of child windows */
- gmx_bool bGrabbed; /* Did this menu grab the pointer? */
+ bool bGrabbed; /* Did this menu grab the pointer? */
} t_menu;
extern t_menu *init_menu(t_x11 *x11, Window Parent, unsigned long fg, unsigned long bg,
* has to be shown, call show_menu.
*/
-extern void show_menu(t_x11 *x11, t_menu *m, int x, int y, gmx_bool bGrab);
+extern void show_menu(t_x11 *x11, t_menu *m, int x, int y, bool bGrab);
/* Show the menu in m at (x,y)
* This will popup the menu, and when a button is released in the
* menu send a ClientMessage to the Parent window of the menu
extern void hide_menu(t_x11 *x11, t_menu *m);
/* Unmaps the window for m, hides the window */
-extern void check_menu_item(t_menu *m, int nreturn, gmx_bool bStatus);
+extern void check_menu_item(t_menu *m, int nreturn, bool bStatus);
/* Set the bChecked field in the menu item with return code
* nreturn to bStatus. This function must always be called when
* the bChecked flag has to changed.
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#include <string.h>
#include <smalloc.h>
-#include <x11.h>
#include <macros.h>
+#include "x11.h"
#include "popup.h"
#include "pulldown.h"
-static gmx_bool PDCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool PDCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_pulldown *pd;
int i, x, x1, y, nsel;
;
}
pd->nsel = nsel;
- x1 = max(0, min(pd_width(pd)-menu_width(pd->m[nsel]), pd->xpos[nsel]));
- show_menu(x11, pd->m[nsel], x1, y+1, FALSE);
+ x1 = std::max(0, std::min(pd_width(pd)-menu_width(pd->m[nsel]), pd->xpos[nsel]));
+ show_menu(x11, pd->m[nsel], x1, y+1, false);
}
break;
case ButtonRelease:
default:
break;
}
- return FALSE;
+ return false;
}
-t_pulldown *init_pd(t_x11 *x11, Window Parent, int width, int height,
+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)
{
pd->nsel = -1;
}
-void check_pd_item(t_pulldown *pd, int nreturn, gmx_bool bStatus)
+void check_pd_item(t_pulldown *pd, int nreturn, bool bStatus)
{
int i;
w = 0;
for (i = 0; (i < pd->nmenu); i++)
{
- w = max(w, menu_width(pd->m[i]));
+ w = std::max(w, menu_width(pd->m[i]));
}
- w = max(w, pd->xpos[pd->nmenu]);
+ w = std::max(w, pd->xpos[pd->nmenu]);
return w;
}
h = 0;
for (i = 0; (i < pd->nmenu); i++)
{
- h = max(h, menu_height(pd->m[i]));
+ h = std::max(h, menu_height(pd->m[i]));
}
return h;
const char **title;
} t_pulldown;
-extern t_pulldown *init_pd(t_x11 *x11, Window Parent, int width, int height,
+extern 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);
extern void hide_pd(t_x11 *x11, t_pulldown *pd);
/* Hides any menu that is still on the screen when it shouldn't */
-extern void check_pd_item(t_pulldown *pd, int nreturn, gmx_bool bStatus);
+extern void check_pd_item(t_pulldown *pd, int nreturn, bool bStatus);
/* Set the bChecked field in the pd item with return code
* nreturn to bStatus. This function must always be called when
* the bChecked flag has to changed.
#include <config.h>
#endif
+#include <stdio.h>
#include <ctype.h>
#include <string.h>
-
#include "sysstuff.h"
#include "macros.h"
#include "smalloc.h"
#include "typedefs.h"
#include "string2.h"
#include "statutil.h"
-#include "Xstuff.h"
-#include "gromacs.bm"
#include "copyrite.h"
#include "confio.h"
+#include "tpxio.h"
+
+#ifdef HAVE_X11
+
+#include "Xstuff.h"
+#include "gromacs.bm"
+#include "xutil.h"
#include "dialogs.h"
#include "writeps.h"
#include "molps.h"
#include "nmol.h"
-#include "tpxio.h"
-
-#include "gromacs/commandline/cmdlinemodulemanager.h"
/* Forward declarations: I Don't want all that init shit here */
void init_gmx(t_x11 *x11, char *program, int nfile, t_filenm fnm[],
{
t_psdata ps;
- ps = ps_open("ngmx.ps", 0, 0, man->molw->wd.width, man->molw->wd.height);
+ ps = ps_open("view.ps", 0, 0, man->molw->wd.width, man->molw->wd.height);
ps_draw_mol(ps, man);
ps_close(ps);
}
}
static void move_gmx(t_x11 *x11, t_gmx *gmx, int width, int height,
- gmx_bool bSizePD)
+ bool bSizePD)
{
int y0, wl, hl;
#ifdef DEBUG
XMoveWindow(x11->disp, gmx->logo->wd.self, (width-wl)/2, (height-y0-hl)/2);
}
-static gmx_bool HandleClient(t_x11 *x11, int ID, t_gmx *gmx)
+static bool HandleClient(t_x11 *x11, int ID, t_gmx *gmx)
{
t_pulldown *pd;
break;
case IDTERM:
done_gmx(x11, gmx);
- return TRUE;
+ return true;
/* Edit Menu */
case IDEDITTOP:
default:
break;
}
- return FALSE;
+ return false;
}
-static gmx_bool MainCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool MainCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_gmx *gmx;
int nsel, width, height;
- gmx_bool result;
+ bool result;
- result = FALSE;
+ result = false;
gmx = (t_gmx *)data;
switch (event->type)
{
height = event->xconfigure.height;
if ((width != gmx->wd->width) || (height != gmx->wd->height))
{
- move_gmx(x11, gmx, width, height, TRUE);
+ move_gmx(x11, gmx, width, height, true);
}
break;
case ClientMessage:
}
return result;
}
+//! HAVE_X11
+#endif
-int gmx_ngmx(int argc, char *argv[])
+int gmx_view(int argc, char *argv[])
{
const char *desc[] = {
- "[TT]ngmx[tt] is the GROMACS trajectory viewer. This program reads a",
+ "[TT]view[tt] is the GROMACS trajectory viewer. This program reads a",
"trajectory file, a run input file and an index file and plots a",
"3D structure of your molecule on your standard X Window",
"screen. No need for a high end graphics workstation, it even",
};
output_env_t oenv;
- t_x11 *x11;
t_filenm fnm[] = {
{ efTRX, "-f", NULL, ffREAD },
{ efTPX, NULL, NULL, ffREAD },
};
#define NFILE asize(fnm)
- if (!parse_common_args(&argc, argv, PCA_CAN_TIME, NFILE, fnm,
- 0, NULL, asize(desc), desc, asize(bugs), bugs, &oenv))
+ if (parse_common_args(&argc, argv, PCA_CAN_TIME, NFILE, fnm,
+ 0, NULL, asize(desc), desc, asize(bugs), bugs, &oenv))
{
- return 0;
- }
-
- if ((x11 = GetX11(&argc, argv)) == NULL)
- {
- fprintf(stderr, "Can't connect to X Server.\n"
- "Check your DISPLAY environment variable\n");
- exit(1);
+#ifndef HAVE_X11
+ fprintf(stderr, "Compiled without X-Windows - can not run viewer.\n");
+#else
+ t_x11 *x11;
+
+ if ((x11 = GetX11(&argc, argv)) == NULL)
+ {
+ fprintf(stderr, "Can't connect to X Server.\n"
+ "Check your DISPLAY environment variable\n");
+ }
+ else
+ {
+ init_gmx(x11, argv[0], NFILE, fnm, oenv);
+ x11->MainLoop(x11);
+ x11->CleanUp(x11);
+ }
+#endif
}
- init_gmx(x11, argv[0], NFILE, fnm, oenv);
-
- x11->MainLoop(x11);
- x11->CleanUp(x11);
-
return 0;
}
-int main(int argc, char *argv[])
-{
- return gmx::CommandLineModuleManager::runAsMainCMain(argc, argv, &gmx_ngmx);
-}
-
+#ifdef HAVE_X11
static t_mentry FileMenu[] = {
- { 0, IDEXPORT, FALSE, "Export..." },
- { 0, IDDUMPWIN, FALSE, "Print" },
- { 0, IDQUIT, FALSE, "Quit" }
+ { 0, IDEXPORT, false, "Export..." },
+ { 0, IDDUMPWIN, false, "Print" },
+ { 0, IDQUIT, false, "Quit" }
};
static t_mentry DispMenu[] = {
- { 0, IDFILTER, FALSE, "Filter..." },
- { 0, IDANIMATE, FALSE, "Animate" },
- { 0, IDLABELSOFF, FALSE, "Labels Off"},
- { 0, IDRESETVIEW, FALSE, "Reset View"},
- { 0, IDBONDOPTS, FALSE, "Options..."}
+ { 0, IDFILTER, false, "Filter..." },
+ { 0, IDANIMATE, false, "Animate" },
+ { 0, IDLABELSOFF, false, "Labels Off"},
+ { 0, IDRESETVIEW, false, "Reset View"},
+ { 0, IDBONDOPTS, false, "Options..."}
};
static t_mentry HelpMenu[] = {
- { 0, IDHELP, FALSE, "Help" },
- { 0, IDABOUT, FALSE, "About Gromacs..." }
+ { 0, IDHELP, false, "Help" },
+ { 0, IDABOUT, false, "About Gromacs..." }
};
static t_mentry *gmx_pd[] = { FileMenu, DispMenu, HelpMenu };
/* 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);
+ gmx->logo = init_logo(x11, gmx->wd->self, false);
/* Now put all windows in the proper place */
- move_gmx(x11, gmx, w0, h0, FALSE);
+ 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,
- XTextHeight(x11->font), x11->fg, x11->bg,
+ x11->fg, x11->bg,
MSIZE, gmx_pd_size, gmx_pd, MenuTitle);
/* Dialogs & Filters */
/* Now do file shit */
set_file(x11, gmx->man, ftp2fn(efTRX, nfile, fnm), ftp2fn(efTPX, nfile, fnm));
- /*show_logo(x11,gmx->logo);*/
-
ShowDlg(gmx->dlgs[edFilter]);
}
+
+//! HAVE_X11
+#endif
*
* GROningen MAchine for Chemical Simulations
*
- * VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
* For more info, check our website at http://www.gromacs.org
*
* And Hey:
- * Gyas ROwers Mature At Cryogenic Speed
+ * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "logo.h"
+#ifndef _view_h
+#define _view_h
int
-main(int argc, char *argv[])
-{
- t_x11 *x11;
- t_logo *logo;
-
- if ((x11 = GetX11(&argc, argv)) == NULL)
- {
- fprintf(stderr, "No X!\n");
- exit(1);
- }
- logo = init_logo(x11, x11->root, TRUE);
- show_logo(x11, logo);
- x11->MainLoop(x11);
+gmx_view(int argc, char *argv[]);
- x11->CleanUp(x11);
- return 0;
-}
+#endif
+/* _view_h */
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#include <config.h>
#endif
+#include <string.h>
#include "typedefs.h"
-#include <Xstuff.h>
-#include <x11.h>
#include "sysstuff.h"
-#include <string.h>
#include "smalloc.h"
#include "string2.h"
+#include "Xstuff.h"
+#include "x11.h"
/* These colours will be mapped to black on a monochrome screen */
unsigned long BLACK, BLUE, GREEN, CYAN, RED, BROWN, GREY, DARKGREY;
"9x15", "6x13", "fixed"
};
#define MAXNAMES (sizeof(fontnames)/sizeof(fontnames[0]))
- int i;
+ unsigned int i;
XFontStruct *font;
int count;
char **fontlist;
- gmx_bool bFont = FALSE;
+ bool bFont = false;
if (name)
{
- bFont = (gmx_bool) ((font = XLQF(err, disp, name)) != NULL);
+ bFont = ((font = XLQF(err, disp, name)) != NULL);
}
else
{
for (i = 0; (!bFont && (i < MAXNAMES)); i++)
{
- bFont = (gmx_bool) ((font = XLQF(err, disp, fontnames[i])) != NULL);
+ bFont = ((font = XLQF(err, disp, fontnames[i])) != NULL);
}
if (!bFont)
fontlist = XListFonts(disp, "?", 1, &count);
if (count != 0)
{
- bFont = (gmx_bool) ((font = XLQF(err, disp, fontlist[0])) != NULL);
+ bFont = ((font = XLQF(err, disp, fontlist[0])) != NULL);
}
}
if (!bFont)
return curs;
}
-typedef struct {
- Window w;
- gmx_bool b;
-} t_peek;
-
-static Bool TestEvent(Display *disp, XEvent *event, char *arg)
-{
- t_peek *tp;
-
- fprintf(stderr, "TestEvent\n");
- tp = (t_peek *)arg;
- if ((event->xany.window == tp->w) && (event->type == ConfigureNotify))
- {
- tp->b = TRUE;
- return True;
- }
- return False;
-}
-
static void MainLoop(t_x11 *x11)
{
- gmx_bool bReturn;
+ bool bReturn;
XEvent event;
t_wlist *curs;
Window w;
- for (bReturn = FALSE; (!bReturn); )
+ for (bReturn = false; (!bReturn); )
{
if (x11->wlist)
{
curs = GetWList(x11, w);
if (!curs)
{
- bReturn = TRUE;
+ bReturn = true;
}
if (!bReturn)
{
XCloseDisplay(x11->disp);
}
-static void Xrm(int *argc, char *argv[])
-{
- /*
- static XrmOptionDescRec opTable[] = {
- {"-background", "*background",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-bd", "*borderColor",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-bg", "*background",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-borderwidth", "*TopLevelShell.borderwidth",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-bordercolor", "*borderColor",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-bw", "*TopLevelShell.borderColor",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-display", ".display",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-fg", "*foreground",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-fn", "*font",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-font", "*font",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-foreground", "*foreground",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-geometry", ".TopLevelShell.geometry",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-iconic", ".TopLevelShell.iconic",
- XrmoptionNoArg, (caddr_t) "on"},
- {"-name", ".name",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-reverse", "*reverseVideo",
- XrmoptionNoArg, (caddr_t) "on"},
- {"-rv", "*reverseVideo",
- XrmoptionNoArg, (caddr_t) "on"},
- {"-synchronous", ".synchronous",
- XrmoptionNoArg, (caddr_t) "on"},
- {"-title", ".TopLevelShell.title",
- XrmoptionSepArg, (caddr_t) NULL},
- {"-xrm", NULL,
- XrmoptionSepArg, (caddr_t) NULL},
- };
- #define TABLELENGTH (sizeof(opTable)/sizeof(opTable[0]))
- XrmInitialize();*/
-}
-
static void Flush(t_x11 *x11)
{
fflush(x11->console);
char *display;
char *fontname;
char *title, *FG = NULL, *BG = NULL;
- gmx_bool bVerbose = FALSE;
+ bool bVerbose = false;
int i;
title = strdup(argv[0]);
title = strdup(argv[++i]);
break;
case 'v':
- bVerbose = TRUE;
+ bVerbose = true;
break;
default:
ARGV[ARGC++] = argv[i];
if (x11->depth > 1)
{
/* Not B & W, Look what kind of screen we've got... */
- for (i = 0; (i < NCLASS); i++)
+ for (i = 0; (i < (int)NCLASS); i++)
{
if (!XMatchVisualInfo(x11->disp, x11->screen, x11->depth,
v_class[i], &v_info))
extern unsigned long LIGHTBLUE, LIGHTGREY, LIGHTGREEN, LIGHTCYAN,
LIGHTRED, VIOLET, YELLOW, WHITE;
-typedef enum {
- ecbOK
-} ecbReturn;
-
#define CBARGS (struct t_x11 *x11, XEvent *event, Window w, void *data)
-/* Callback function. Return FALSE to continue, TRUE to exit */
+/* Callback function. Return false to continue, true to exit */
typedef struct t_x11 {
Display *disp;
void (*GetNamedColor)(struct t_x11 *x11, const char *name, unsigned long *col);
void (*MainLoop)(struct t_x11 *x11);
void (*RegisterCallback)(struct t_x11 *x11, Window w, Window Parent,
- gmx_bool cb CBARGS, void *data);
+ bool cb CBARGS, void *data);
void (*UnRegisterCallback)(struct t_x11 *x11, Window w);
void (*SetInputMask)(struct t_x11 *x11, Window w, unsigned long mask);
unsigned long (*GetInputMask)(struct t_x11 *x11, Window w);
void (*Flush)(struct t_x11 *x11);
} t_x11;
-typedef gmx_bool CallBack CBARGS;
+typedef bool CallBack CBARGS;
typedef struct t_wlist {
Window w; /* The window itself */
* events. It is up to the window to destroy itself. The MainLoop
* routine exits when there are no more windows to manage, i.e. when
* all routines have called UnRegisterCallback, OR when one Callback
- * routine returns non-zero (TRUE).
+ * routine returns non-zero (true).
* 5. Call x11->CleanUp. This closes the display, and frees all
* memory allocated by x11 before.
*/
* Routines to manipulate items on a dialog box
*
****************************/
-gmx_bool QueryDlgItemSize(t_dlg *dlg, t_id id, int *w, int *h)
+bool QueryDlgItemSize(t_dlg *dlg, t_id id, int *w, int *h)
{
t_dlgitem *dlgitem;
{
*w = dlgitem->win.width;
*h = dlgitem->win.height;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-gmx_bool QueryDlgItemPos(t_dlg *dlg, t_id id, int *x0, int *y0)
+bool QueryDlgItemPos(t_dlg *dlg, t_id id, int *x0, int *y0)
{
t_dlgitem *dlgitem;
{
*x0 = dlgitem->win.x;
*y0 = dlgitem->win.y;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
int QueryDlgItemX(t_dlg *dlg, t_id id)
return 0;
}
-gmx_bool SetDlgItemSize(t_dlg *dlg, t_id id, int w, int h)
+bool SetDlgItemSize(t_dlg *dlg, t_id id, int w, int h)
{
t_dlgitem *dlgitem;
#ifdef DEBUG
}
}
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-gmx_bool SetDlgItemPos(t_dlg *dlg, t_id id, int x0, int y0)
+bool SetDlgItemPos(t_dlg *dlg, t_id id, int x0, int y0)
{
t_dlgitem *dlgitem;
int old_x, old_y;
}
}
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/*****************************
* after dlg is exec'ed
*
****************************/
-gmx_bool IsCBChecked(t_dlg *dlg, t_id id)
+bool IsCBChecked(t_dlg *dlg, t_id id)
{
t_dlgitem *dlgitem;
}
}
- return FALSE;
+ return false;
}
t_id RBSelected(t_dlg *dlg, int gid)
{
PushMouse(dlg->x11->disp, dlgitem->win.self,
dlgitem->win.width/2, dlgitem->win.height/2);
- dlg->bPop = TRUE;
+ dlg->bPop = true;
break;
}
}
- dlg->bGrab = FALSE;
+ dlg->bGrab = false;
}
void HideDlg(t_dlg *dlg)
void NoHelp(t_dlg *dlg)
{
- char **lines = NULL;
-
- snew(lines, 2);
- lines[0] = strdup("Error");
- lines[1] = strdup("No help for this item");
+ const char *lines[2] = {
+ "Error",
+ "No help for this item"
+ };
MessageBox(dlg->x11, dlg->wDad, "No Help", 2, lines,
MB_OK | MB_ICONSTOP | MB_APPLMODAL, NULL, NULL);
- sfree(lines[0]);
- sfree (lines[1]);
- sfree(lines);
}
void HelpDlg(t_dlg *dlg)
{
- char *lines[] = {
+ const char *lines[] = {
"Place the cursor over one of the items",
"and press the F1 key to get more help.",
"First press the OK button."
void HelpNow(t_dlg *dlg, t_dlgitem *dlgitem)
{
char buf[80];
- gmx_bool bCont = TRUE;
+ bool bCont = true;
int i, nlines = 0;
char **lines = NULL;
}
while (bCont);
MessageBox(dlg->x11, dlg->wDad, "Help",
- nlines, lines, MB_OK | MB_ICONINFORMATION | MB_APPLMODAL, NULL, NULL);
+ nlines, lines,
+ MB_OK | MB_ICONINFORMATION | MB_APPLMODAL, NULL, NULL);
for (i = 0; (i < nlines); i++)
{
sfree(lines[i]);
if (dlg->bGrab)
{
XUngrabPointer(dlg->x11->disp, CurrentTime);
- dlg->bGrab = FALSE;
+ dlg->bGrab = false;
}
HideDlg(dlg);
if (dlg->flags & DLG_FREEONBUTTON)
}
}
-static gmx_bool DlgCB(t_x11 *x11, XEvent *event, Window w, void *data)
+static bool DlgCB(t_x11 *x11, XEvent *event, Window w, void *data)
{
t_dlg *dlg = (t_dlg *)data;
int i, nWndProc;
if (tid != -1)
{
t_dlgitem *dit = FindItem(dlg, tid);
- dit->u.radiobutton.bSelect = FALSE;
+ dit->u.radiobutton.bSelect = false;
ExposeWin(x11->disp, dit->win.self);
}
else
{
gmx_fatal(FARGS, "No RB Selected initially!\n");
}
- dlgitem->u.radiobutton.bSelect = TRUE;
+ dlgitem->u.radiobutton.bSelect = true;
ExposeWin(x11->disp, dlgitem->win.self);
if (dlg->cb)
{
break;
}
}
- return FALSE;
+ return false;
}
/*****************************
*
****************************/
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,
+ int x0, int y0, int w, int h, int bw,
DlgCallback *cb, void *data)
{
t_dlg *dlg;
return dlg;
}
-void SetDlgSize(t_dlg *dlg, int w, int h, gmx_bool bAutoPosition)
+void SetDlgSize(t_dlg *dlg, int w, int h, bool bAutoPosition)
{
if (bAutoPosition)
{
#ifndef _xdlg_h
#define _xdlg_h
-#include <xdlgitem.h>
+#include "xdlgitem.h"
#define DLG_SHOW (1<<0)
#define DLG_HIDE (1<<1)
unsigned int xmax, ymax; /* Dimensions of parent window */
unsigned long flags; /* Flags for display */
unsigned long fg, bg; /* The colours */
- gmx_bool bPop; /* Should we pop the mouse back */
- gmx_bool bGrab; /* Have we grabbed the mouse ? */
+ bool bPop; /* Should we pop the mouse back */
+ bool bGrab; /* Have we grabbed the mouse ? */
int nitem; /* The number of items */
t_dlgitem **dlgitem; /* The array of item pointers */
DlgCallback *cb; /* User call back function */
*
****************************/
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,
+ int x0, int y0, int w, int h, int bw,
DlgCallback *cb, void *data);
/*****************************
/*****************************
*
* Routines to manipulate items on a dialog box
- * They return TRUE on succes, FALSE otherwise
- * FALSE will mean most of the time, that item id was not found
+ * They return true on succes, false otherwise
+ * false will mean most of the time, that item id was not found
*
****************************/
-gmx_bool QueryDlgItemSize(t_dlg *dlg, t_id id, int *w, int *h);
+bool QueryDlgItemSize(t_dlg *dlg, t_id id, int *w, int *h);
-gmx_bool QueryDlgItemPos(t_dlg *dlg, t_id id, int *x0, int *y0);
+bool QueryDlgItemPos(t_dlg *dlg, t_id id, int *x0, int *y0);
int QueryDlgItemX(t_dlg *dlg, t_id id);
int QueryDlgItemH(t_dlg *dlg, t_id id);
-gmx_bool SetDlgItemSize(t_dlg *dlg, t_id id, int w, int h);
+bool SetDlgItemSize(t_dlg *dlg, t_id id, int w, int h);
-gmx_bool SetDlgItemPos(t_dlg *dlg, t_id id, int x0, int y0);
+bool SetDlgItemPos(t_dlg *dlg, t_id id, int x0, int y0);
-void SetDlgSize(t_dlg *dlg, int w, int h, gmx_bool bAutoPosition);
+void SetDlgSize(t_dlg *dlg, int w, int h, bool bAutoPosition);
/*****************************
*
* after dlg is exec'ed
*
****************************/
-gmx_bool IsCBChecked(t_dlg *dlg, t_id id);
+bool IsCBChecked(t_dlg *dlg, t_id id);
t_id RBSelected(t_dlg *dlg, int gid);
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#include "sysstuff.h"
#include "smalloc.h"
#include "macros.h"
+#include "xutil.h"
#include "xdlghi.h"
#include "fgrid.h"
dlgitem[i+1] = CreateRadioButton(x11, szRB[i], (i == nSelect),
rb[i], GroupID, x, y, 0, 0, 0);
y += dlgitem[i+1]->win.height+OFFS_Y;
- w = max(w, dlgitem[i+1]->win.width);
+ w = std::max(w, dlgitem[i+1]->win.width);
}
for (i = 0; (i < nrb); i++)
{
t_id *ids;
edlgitem edlg;
char *name;
- gmx_bool bBool;
+ bool bBool;
Pixmap pm;
int nlines, buflen;
char *buf, **lines;
break;
case edlgPM:
pm = va_arg(ap, Pixmap);
- dlgitem[i+1] = CreatePixmap(x11, pm, ids[i], GroupID, x, y, 0, 0, 0);
+ dlgitem[i+1] = CreatePixmap(pm, ids[i], GroupID, x, y, 0, 0, 0);
break;
case edlgST:
nlines = va_arg(ap, int);
gmx_fatal(FARGS, "Invalid dlgitem type: %d\n", edlg);
}
y += dlgitem[i+1]->win.height+OFFS_Y;
- w = max(w, dlgitem[i+1]->win.width);
+ w = std::max(w, dlgitem[i+1]->win.width);
}
va_end(ap);
sfree(dlgitem[0]->u.groupbox.item);
}
static void AddDlgItemGroups(t_dlg *dlg, int gridx, int gridy,
- t_dlgitemlist **grid, gmx_bool bAutoPosition)
+ t_dlgitemlist **grid, bool bAutoPosition)
{
t_dlgitemlist *item;
int x1, y1, w1, h1;
AddDlgItems(dlg, item->nitem, item->list);
dw = item->w;
dh = item->h;
- w = max(w, ((float) QueryDlgItemW(dlg, item->list[0]->ID))/dw);
- h = max(h, ((float) QueryDlgItemH(dlg, item->list[0]->ID))/dh);
+ w = std::max(w, ((float) QueryDlgItemW(dlg, item->list[0]->ID))/dw);
+ h = std::max(h, ((float) QueryDlgItemH(dlg, item->list[0]->ID))/dh);
}
}
}
static void AddListFItem(t_x11 *x11, t_dlgitemlist *list,
t_fitem *fitem, t_id GroupID, t_id *ID,
- int x, int *y, int *w, gmx_bool bUseMon)
+ int x, int *y, int *w, bool bUseMon)
{
int i, iSel, slen;
char buf[STRLEN];
CreateRadioButton(x11, fitem->name[i], (iSel == i),
(*ID)++, GroupID, x, (*y), 0, 0, 0));
(*y) += list->list[list->nitem-1]->win.height+OFFS_Y;
- (*w) = max((*w), list->list[list->nitem-1]->win.width);
+ (*w) = std::max((*w), list->list[list->nitem-1]->win.width);
SetDlgitemOpts(list->list[list->nitem-1], bUseMon,
fitem->set, fitem->get, fitem->help);
}
break;
case edlgCB:
{
- gmx_bool bCheck;
+ bool bCheck;
bCheck = gmx_strcasecmp(fitem->def, "TRUE") == 0;
AddListItem(list, CreateCheckBox(x11, fitem->name[0], bCheck,
}
case edlgST:
AddListItem(list,
- CreateStaticText(x11, fitem->nname, fitem->name, (*ID)++,
+ CreateStaticText(x11, fitem->nname,
+ fitem->name, (*ID)++,
GroupID, x, (*y), 0, 0, 0));
break;
case edlgET:
if (fitem->edlg != edlgRB)
{
(*y) += list->list[list->nitem-1]->win.height+OFFS_Y;
- (*w) = max((*w), list->list[list->nitem-1]->win.width);
+ (*w) = std::max((*w), list->list[list->nitem-1]->win.width);
}
}
static void AddListFGroup(t_x11 *x11, t_dlgitemlist **grid,
- t_fgroup *fgroup, t_id *ID, gmx_bool bUseMon)
+ t_fgroup *fgroup, t_id *ID, bool bUseMon)
{
int i;
t_id GroupID, *ids;
AddListFItem(x11, item, fgroup->fitem[i], GroupID, ID, x, &y, &w, bUseMon);
}
- w = max(w, item->list[0]->win.width+4*OFFS_X);
+ w = std::max(w, item->list[0]->win.width+4*OFFS_X);
sfree(item->list[0]->u.groupbox.item);
sfree(item->list[0]->win.text);
snew(ids, item->nitem);
}
static void AddListFSimple(t_x11 *x11, t_dlgitemlist **grid,
- t_fsimple *fsimple, t_id *ID, gmx_bool bUseMon)
+ t_fsimple *fsimple, t_id *ID, bool bUseMon)
{
t_dlgitemlist *item;
int x, y, w;
}
t_dlg *ReadDlg(t_x11 *x11, Window Parent, const char *title,
- unsigned long fg, unsigned long bg, const char *infile,
- int x0, int y0, gmx_bool bAutoPosition, gmx_bool bUseMon,
+ const char *infile,
+ int x0, int y0, bool bAutoPosition, bool bUseMon,
DlgCallback *cb, void *data)
{
t_fgrid *fgrid;
t_id ID;
fgrid = FGridFromFile(infile);
- dlg = CreateDlg(x11, Parent, title, x0, y0, 0, 0, 0, fg, bg, cb, data);
+ dlg = CreateDlg(x11, Parent, title, x0, y0, 0, 0, 0, cb, data);
grid = NewDlgitemList(fgrid->w, fgrid->h);
ID = 0;
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
*/
extern t_dlg *ReadDlg(t_x11 *x11, Window Parent, const char *title,
- unsigned long fg, unsigned long bg, const char *infile,
- int x0, int y0, gmx_bool bAutoPosition, gmx_bool bUseMon,
+ const char *infile,
+ int x0, int y0, bool bAutoPosition, bool bUseMon,
DlgCallback *cb, void *data);
/* Read a dialog box from a template file */
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#define BUFSIZE 16
-t_dlgitem *newitem(t_x11 *x11)
+static t_dlgitem *newitem(void)
{
t_dlgitem *item;
}
break;
case EnterNotify:
- dlgitem->win.bFocus = TRUE;
+ dlgitem->win.bFocus = true;
ShowCaret(x11, dlgitem);
/* LightBorder(x11->disp,dlgitem->win.self,x11->fg); */
break;
case LeaveNotify:
- dlgitem->win.bFocus = FALSE;
+ dlgitem->win.bFocus = false;
HideCaret(x11, dlgitem);
/* LightBorder(x11->disp,dlgitem->win.self,x11->bg); */
break;
return ITEMOK;
}
-static gmx_bool insert(char *s, char c, int *pos)
+static bool insert(char *s, char c, int *pos)
{
int i, sl;
}
s[*pos] = c;
(*pos)++;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-static gmx_bool my_backspace(char *s, int *pos)
+static bool my_backspace(char *s, int *pos)
{
int i, sl;
{
s[i] = s[i+1];
}
- (*pos) = max(0, (*pos)-1);
- return TRUE;
+ (*pos) = std::max(0, (*pos)-1);
+ return true;
}
- return FALSE;
+ return false;
}
-static gmx_bool my_delete(char *s, int *pos)
+static bool my_delete(char *s, int *pos)
{
int i, sl;
{
s[i] = s[i+1];
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
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;
+ t_edittext *et;
+ t_windata *win;
+ KeySym keysym;
+ char c[BUFSIZE+1], *bp;
+ char scrbuf[STRLEN];
+ int i;
+ int xp, xtitle, ewidth;
if (dlgitem->type != edlgET)
{
bp[et->pos] = '\0';
}
sfree(bp);
- et->bChanged = TRUE;
+ et->bChanged = true;
return ETCHANGED;
case KeyPress:
/* Check for HelpKey */
case XK_Delete:
if (my_delete(et->buf, &(et->pos)))
{
- et->bChanged = TRUE;
+ et->bChanged = true;
return ETCHANGED;
}
else
case XK_BackSpace:
if (my_backspace(et->buf, &(et->pos)))
{
- et->bChanged = TRUE;
+ et->bChanged = true;
return ETCHANGED;
}
else
case XK_Home:
et->pos = 0;
et->strbegin = 0;
- et->bChanged = TRUE;
+ et->bChanged = true;
return ETCHANGED;
case XK_End:
- if (strlen(et->buf) <= et->buflen)
+ if (strlen(et->buf) <= (unsigned int)et->buflen)
{
et->pos = strlen(et->buf);
}
et->pos = et->buflen;
et->strbegin = strlen(et->buf)-et->buflen;
}
- et->bChanged = TRUE;
+ 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;
+ et->pos = std::max(0, et->pos-1);
+ et->strbegin = std::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)))
+ if ((et->pos < et->buflen) &&
+ (et->strbegin+et->buflen > (int)strlen(et->buf)))
{
et->pos++;
}
- else if ((et->buflen < strlen(et->buf)) &&
- (et->strbegin < strlen(et->buf)-et->buflen))
+ else if ((et->buflen < (int)strlen(et->buf)) &&
+ (et->strbegin < (int)strlen(et->buf)-et->buflen))
{
et->strbegin++;
}
{
break;
}
- et->bChanged = TRUE;
+ et->bChanged = true;
return ETCHANGED;
default:
if (keysym < 256)
{
if (insert(et->buf, c[0], &(et->pos)))
{
- et->bChanged = TRUE;
+ et->bChanged = true;
return ETCHANGED;
}
}
}
break;
case LeaveNotify:
- win->bFocus = FALSE;
+ win->bFocus = false;
HideCaret(x11, dlgitem);
if (et->bChanged)
{
- et->bChanged = FALSE;
+ et->bChanged = false;
}
break;
default:
*
****************************/
t_dlgitem *CreateButton(t_x11 *x11,
- const char *szLab, gmx_bool bDef, t_id id, t_id groupid,
+ const char *szLab, 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);
+ dlgitem = newitem();
if (h == 0)
{
h = XTextHeight(x11->font)+2*OFFS_Y;
}
t_dlgitem *CreateRadioButton(t_x11 *x11,
- const char *szLab, gmx_bool bSet, t_id id,
+ const char *szLab, bool bSet, t_id id,
t_id groupid,
int x0, int y0, int w, int h, int bw)
{
t_dlgitem *dlgitem;
- dlgitem = newitem(x11);
+ dlgitem = newitem();
if (h == 0)
{
h = XTextHeight(x11->font)+OFFS_Y;
{
t_dlgitem *dlgitem;
- dlgitem = newitem(x11);
+ dlgitem = newitem();
if (h == 0)
{
h = XTextHeight(x11->font)+OFFS_Y;
}
t_dlgitem *CreateCheckBox(t_x11 *x11,
- const char *szLab, gmx_bool bCheckedInitial, t_id id,
+ const char *szLab, bool bCheckedInitial, t_id id,
t_id groupid,
int x0, int y0, int w, int h, int bw)
{
t_dlgitem *dlgitem;
- dlgitem = newitem(x11);
+ dlgitem = newitem();
if (h == 0)
{
h = XTextHeight(x11->font)+OFFS_Y;
return dlgitem;
}
-t_dlgitem *CreatePixmap(t_x11 *x11,
- Pixmap pm, t_id id,
+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(x11);
+ dlgitem = newitem();
InitWin(&(dlgitem->win), x0, y0, w, h, bw, NULL);
dlgitem->ID = id;
dlgitem->type = edlgPM;
}
t_dlgitem *CreateStaticText(t_x11 *x11,
- int nlines, char * const * lines, t_id id,
+ int nlines, const 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);
+ dlgitem = newitem();
if (h == 0)
{
h = (XTextHeight(x11->font)+OFFS_Y)*nlines+OFFS_Y;
{
for (i = 0; (i < nlines); i++)
{
- w = max(w, XTextWidth(x11->font, lines[i], strlen(lines[i])));
+ w = std::max(w, XTextWidth(x11->font, lines[i], strlen(lines[i])));
}
w += 2*OFFS_X;
}
t_dlgitem *dlgitem;
t_edittext *et;
- dlgitem = newitem(x11);
+ dlgitem = newitem();
if (h == 0)
{
h = XTextHeight(x11->font)+OFFS_Y;
strcpy(et->buf, buf);
et->buflen = screenbuf;
et->strbegin = 0;
- et->bChanged = FALSE;
+ et->bChanged = false;
dlgitem->WndProc = WndProcET;
return dlgitem;
#define SC(src) (strlen(src) ? strdup(src) : NULL)
-void SetDlgitemOpts(t_dlgitem *dlgitem, gmx_bool bUseMon,
+void SetDlgitemOpts(t_dlgitem *dlgitem, bool bUseMon,
char *set, char *get, char *help)
{
dlgitem->bUseMon = bUseMon;
#define _xdlgitem_h
#include <typedefs.h>
-#include <Xstuff.h>
-#include <xutil.h>
-#include <x11.h>
+#include "Xstuff.h"
+#include "xutil.h"
+#include "x11.h"
+typedef enum {
+ edlgBN, edlgRB, edlgGB, edlgCB, edlgPM, edlgST, edlgET, edlgNR
+} edlgitem;
#define XCARET 2
enum {
typedef int t_id;
typedef struct {
- gmx_bool bDefault; /* This is the default button */
+ bool bDefault; /* This is the default button */
} t_button;
typedef struct {
- gmx_bool bSelect; /* Is this rb selected ? */
+ bool bSelect; /* Is this rb selected ? */
} t_radiobutton;
typedef struct {
- gmx_bool bChecked; /* Is this cb checked ? */
+ bool bChecked; /* Is this cb checked ? */
} t_checkbox;
typedef struct {
typedef struct {
int buflen, strbegin; /* Length of the screen buf and begin of string */
- int pos /*,len*/; /* Current length of the string and pos of caret */
+ int pos; /* Current length of the string and pos of caret */
/* Pos is relative to strbegin, and is the pos */
/* in the window. */
- gmx_bool bChanged;
+ bool bChanged;
char *buf;
} t_edittext;
t_id *item;
} t_groupbox;
-typedef enum {
- edlgBN, edlgRB, edlgGB, edlgCB, edlgPM, edlgST, edlgET, edlgNR
-} edlgitem;
typedef struct t_dlgitem {
t_windata win;
t_id ID, GroupID;
- gmx_bool bUseMon;
+ bool bUseMon;
char *set, *get, *help;
edlgitem type;
int (*WndProc)(t_x11 *x11, struct t_dlgitem *dlgitem, XEvent *event);
* on the dlg box, and if wished resize them.
*
****************************/
-extern t_dlgitem *CreateButton(t_x11 *x11, const char *szLab, gmx_bool bDef,
+extern t_dlgitem *CreateButton(t_x11 *x11, const char *szLab, bool bDef,
t_id id, t_id groupid,
int x0, int y0, int w, int h, int bw);
extern t_dlgitem *CreateRadioButton(t_x11 *x11,
- const char *szLab, gmx_bool bSet, t_id id,
+ const char *szLab, bool bSet, t_id id,
t_id groupid,
int x0, int y0, int w, int h, int bw);
int x0, int y0, int w, int h, int bw);
extern t_dlgitem *CreateCheckBox(t_x11 *x11, const char *szLab,
- gmx_bool bCheckedInitial,
+ bool bCheckedInitial,
t_id id, t_id groupid,
int x0, int y0, int w, int h, int bw);
-extern t_dlgitem *CreatePixmap(t_x11 *x11, Pixmap pm, t_id id, t_id groupid,
+extern t_dlgitem *CreatePixmap(Pixmap pm, t_id id, t_id groupid,
int x0, int y0, int w, int h, int bw);
extern t_dlgitem *CreateStaticText(t_x11 *x11,
- int nlines, char * const * lines, t_id id,
- t_id groupid,
+ int nlines, const char * const *lines,
+ t_id id, t_id groupid,
int x0, int y0, int w, int h, int bw);
extern 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);
-extern void SetDlgitemOpts(t_dlgitem *dlgitem, gmx_bool bUseMon,
+extern void SetDlgitemOpts(t_dlgitem *dlgitem, bool bUseMon,
char *set, char *get, char *help);
#endif /* _xdlgitem_h */
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#include "macros.h"
#include "Xstuff.h"
#include "x11.h"
+#include "xutil.h"
#include "xdlg.h"
#include "xmb.h"
#include "gmx_fatal.h"
}
t_dlg *MessageBox(t_x11 *x11, Window Parent, const char *title,
- int nlines, char ** lines, unsigned long Flags,
+ int nlines, const char * const * lines, unsigned long Flags,
DlgCallback *cb, void *data)
{
t_dlg *dlg;
}
}
- dlg = CreateDlg(x11, Parent, title, 0, 0, 0, 0, 3, x11->fg, bg, cb, data);
+ dlg = CreateDlg(x11, Parent, title, 0, 0, 0, 0, 3, cb, data);
x = 2*OFFS_X;
if (nicon > 0)
{
AddDlgItem(dlg, CreatePixmap
- (x11, XCreatePixmapFromBitmapData
+ (XCreatePixmapFromBitmapData
(x11->disp, dlg->win.self, icon_bits, icon_width, icon_height,
icon_fg, icon_bg, x11->depth),
ID_ICON, ID_BOX, 2*OFFS_X, 2*OFFS_Y, icon_width, icon_height, 0));
{
SetDlgItemPos(dlg, ID_ICON, 2*OFFS_X, 2*OFFS_Y+(y-yi)/2);
}
- y = max(y, yi);
+ if (yi > y)
+ {
+ y = yi;
+ }
}
x += QueryDlgItemW(dlg, ID_TEXT)+2*OFFS_X;
y += 2*OFFS_Y;
}
#define CB(name, butx, id) AddDlgItem(dlg, CreateButton(x11, name, \
- TRUE, id, ID_BOX, \
+ true, id, ID_BOX, \
butx, y, width, 0, 0))
if (Flags & MB_OK)
{
}
SetDlgSize(dlg, x, y+2*OFFS_Y+
- QueryDlgItemH(dlg, (Flags & MB_OK) ? MB_OK : MB_YES), TRUE);
+ QueryDlgItemH(dlg, (Flags & MB_OK) ? MB_OK : MB_YES), true);
if (Flags & MB_SYSTEMMODAL)
{
#ifndef _xmb_h
#define _xmb_h
-#include <x11.h>
+#include "x11.h"
#define MB_OK 1
#define MB_CANCEL (1<<1)
#define MB_DONTSHOW (1<<22)
t_dlg *MessageBox(t_x11 *x11, Window Parent, const char *title,
- int nlines, char ** lines, unsigned long Flags,
+ int nlines, const char * const *lines, unsigned long Flags,
DlgCallback *cb, void *data);
#endif /* _xmb_h */
* VERSION 3.2.0
* Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
* check out http://www.gromacs.org for more information.
* This program is free software; you can redistribute it and/or
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <xutil.h>
-#include <Xstuff.h>
#include "smalloc.h"
#include "typedefs.h"
#include "string2.h"
+#include "xutil.h"
+#include "Xstuff.h"
int CheckWin(Window win, const char *file, int line)
{
typedef struct {
- int n;
+ Window n;
const char *s;
} t_winerr;
- t_winerr winerr[] = {
+ t_winerr winerr[] = {
{ BadAlloc, "Bad Alloc" },
{ BadColor, "Bad Color" },
{ BadCursor, "Bad Cursor"},
{ BadWindow, "Bad Window"}
};
#define NERR (sizeof(winerr)/sizeof(winerr[0]))
- int i;
+ unsigned int i;
for (i = 0; (i < NERR); i++)
{
win->width = w;
win->height = h;
win->bwidth = bw;
- win->bFocus = FALSE;
+ win->bFocus = false;
win->cursor = 0;
if (text)
{
sfree(old);
}
-gmx_bool HelpPressed(XEvent *event)
+bool HelpPressed(XEvent *event)
{
#define BUFSIZE 24
char buf[BUFSIZE+1];
return (keysym == XK_F1);
}
-gmx_bool GrabOK(FILE *out, int err)
+bool GrabOK(FILE *out, int err)
{
switch (err)
{
case GrabSuccess:
- return TRUE;
+ return true;
case GrabNotViewable:
fprintf(out, "GrabNotViewable\n"); break;
case AlreadyGrabbed:
default:
break;
}
- return FALSE;
+ return false;
}
Window self, Parent;
unsigned long color;
char *text;
- gmx_bool bFocus;
+ bool bFocus;
int x, y, width, height, bwidth;
Cursor cursor;
} t_windata;
extern void PopMouse(Display *disp);
-extern gmx_bool HelpPressed(XEvent *event);
+extern bool HelpPressed(XEvent *event);
-extern gmx_bool GrabOK(FILE *out, int err);
-/* Return TRUE if grab succeeded, prints a message to out
- * and returns FALSE otherwise.
+extern bool GrabOK(FILE *out, int err);
+/* Return true if grab succeeded, prints a message to out
+ * and returns false otherwise.
*/
#endif /* _xutil_h */