### define sources for the front-end and backend
-GTKsources = xboard.c xevalgraph.c xgamelist.c \
+GTKsources = xboard.c xgamelist.c \
xhistory.c xoptions.c xboard.h \
- xengineoutput.c xevalgraph.h xgamelist.h \
+ xengineoutput.c xgamelist.h \
xhistory.h
Xsources = xaw/xboard.c xaw/xboard.h \
xaw/xengineoutput.c \
- xaw/xevalgraph.c xaw/xevalgraph.h \
xaw/xgamelist.c xaw/xgamelist.h \
xaw/xhistory.c xaw/xhistory.h \
xaw/xoptions.c
draw.c draw.h \
dialogs.c dialogs.h \
engineoutput.c nengineoutput.c engineoutput.h \
- evalgraph.c evalgraph.h \
+ evalgraph.c nevalgraph.c evalgraph.h \
history.c nhistory.c \
menus.c menus.h \
usounds.c usystem.c usystem.h \
# include "zippy.h"
#endif
#include "backendz.h"
+#include "evalgraph.h"
#include "gettext.h"
#ifdef ENABLE_NLS
void Load P((ChessProgramState *cps, int n));
int MultiPV P((ChessProgramState *cps));
void MoveHistorySet P(( char movelist[][2*MOVE_LEN], int first, int last, int current, ChessProgramStats_Move * pvInfo ));
-void EvalGraphSet P(( int first, int last, int current, ChessProgramStats_Move * pvInfo ));
void MakeEngineOutputTitle P((void));
/* A point in time */
#include "common.h"
#include "backend.h"
-#include "xevalgraph.h"
#include "board.h"
#include "menus.h"
#include "dialogs.h"
+#include "evalgraph.h"
#include "gettext.h"
#include "draw.h"
#define White(piece) ((int)(piece) < (int)BlackPawn)
+char *crWhite = "#FFFFB0";
+char *crBlack = "#AD5D3D";
+
struct {
int x1, x2, y1, y2;
} gridSegments[BOARD_RANKS + BOARD_FILES + 2];
// if(!dual) DoDrawPolygon(csBoardBackup, arrow, nr);
}
+//-------------------- Eval Graph drawing routines (formerly in xevalgraph.h) --------------------
+
+static void
+ChoosePen(cairo_t *cr, int i)
+{
+ switch(i) {
+ case PEN_BLACK:
+ SetPen(cr, 1.0, "#000000", 0);
+ break;
+ case PEN_DOTTED:
+ SetPen(cr, 1.0, "#A0A0A0", 1);
+ break;
+ case PEN_BLUEDOTTED:
+ SetPen(cr, 1.0, "#0000FF", 1);
+ break;
+ case PEN_BOLDWHITE:
+ SetPen(cr, 3.0, crWhite, 0);
+ break;
+ case PEN_BOLDBLACK:
+ SetPen(cr, 3.0, crBlack, 0);
+ break;
+ case PEN_BACKGD:
+ SetPen(cr, 3.0, "#E0E0F0", 0);
+ break;
+ }
+}
+
+// [HGM] front-end, added as wrapper to avoid use of LineTo and MoveToEx in other routines (so they can be back-end)
+void
+DrawSegment (int x, int y, int *lastX, int *lastY, int penType)
+{
+ static int curX, curY;
+
+ if(penType != PEN_NONE) {
+ cairo_t *cr = cairo_create(DRAWABLE(disp));
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+ cairo_move_to (cr, curX, curY);
+ cairo_line_to (cr, x,y);
+ ChoosePen(cr, penType);
+ cairo_stroke (cr);
+ cairo_destroy (cr);
+ }
+
+ if(lastX != NULL) { *lastX = curX; *lastY = curY; }
+ curX = x; curY = y;
+}
+
+// front-end wrapper for drawing functions to do rectangles
+void
+DrawRectangle (int left, int top, int right, int bottom, int side, int style)
+{
+ cairo_t *cr;
+
+ cr = cairo_create (DRAWABLE(disp));
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+ cairo_rectangle (cr, left, top, right-left, bottom-top);
+ switch(side)
+ {
+ case 0: ChoosePen(cr, PEN_BOLDWHITE); break;
+ case 1: ChoosePen(cr, PEN_BOLDBLACK); break;
+ case 2: ChoosePen(cr, PEN_BACKGD); break;
+ }
+ cairo_fill (cr);
+
+ if(style != FILLED)
+ {
+ cairo_rectangle (cr, left, top, right-left-1, bottom-top-1);
+ ChoosePen(cr, PEN_BLACK);
+ cairo_stroke (cr);
+ }
+
+ cairo_destroy(cr);
+}
+
+// front-end wrapper for putting text in graph
+void
+DrawEvalText (char *buf, int cbBuf, int y)
+{
+ // the magic constants 8 and 5 should really be derived from the font size somehow
+ cairo_text_extents_t extents;
+ cairo_t *cr = cairo_create(DRAWABLE(disp));
+
+ /* GTK-TODO this has to go into the font-selection */
+ cairo_select_font_face (cr, "Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size (cr, 12.0);
+
+
+ cairo_text_extents (cr, buf, &extents);
+
+ cairo_move_to (cr, MarginX - 2 - 8*cbBuf, y+5);
+ cairo_text_path (cr, buf);
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 0, 1.0, 0);
+ cairo_set_line_width (cr, 0.1);
+ cairo_stroke (cr);
+
+ /* free memory */
+ cairo_destroy (cr);
+}
+
void CreateAnyPieces P((void));
void CreatePNGPieces P((void));
void CreateGrid P((void));
+void DrawSegment P((int x, int y, int *lastX, int *lastY, int p));
+void DrawRectangle P((int left, int top, int right, int bottom, int side, int style));
+void DrawEvalText P((char *buf, int cbBuf, int y));
+extern Option *disp;
+
+// defined in evaldraw.c
+float Color P((char *col, int n));
// defined in xoptions.c
void GraphExpose P((Option *opt, int x, int y, int w, int h));
// back-end
static void
-DrawLine (int x1, int y1, int x2, int y2, enum PEN penType)
+DrawLine (int x1, int y1, int x2, int y2, int penType)
{
DrawSegment( x1, y1, NULL, NULL, PEN_NONE );
DrawSegment( x2, y2, NULL, NULL, penType );
// back-end
static void
-DrawLineEx (int x1, int y1, int x2, int y2, enum PEN penType)
+DrawLineEx (int x1, int y1, int x2, int y2, int penType)
{
int savX, savY;
DrawSegment( x1, y1, &savX, &savY, PEN_NONE );
#define MIN_HIST_WIDTH 4
#define MAX_HIST_WIDTH 10
-enum PEN { PEN_NONE, PEN_BLACK, PEN_DOTTED, PEN_BLUEDOTTED, PEN_BOLDWHITE, PEN_BOLDBLACK, PEN_BACKGD };
+typedef enum { PEN_NONE, PEN_BLACK, PEN_DOTTED, PEN_BLUEDOTTED, PEN_BOLDWHITE, PEN_BOLDBLACK, PEN_BACKGD } PenType;
#define FILLED 1
#define OPEN 0
extern int MarginH;
// calls from back-end part into front-end part
-void DrawSegment( int x, int y, int *lastX, int *lastY, enum PEN );
+void DrawSegment( int x, int y, int *lastX, int *lastY, int p );
void DrawRectangle( int left, int top, int right, int bottom, int side, int style );
void DrawEvalText(char *buf, int cbBuf, int y);
+void EvalGraphSet P(( int first, int last, int current, ChessProgramStats_Move * pvInfo ));
// calls of front-end part into back-end part
extern int GetMoveIndexFromPoint( int x, int y );
--- /dev/null
+/*
+ * Evaluation graph
+ *
+ * Author: Alessandro Scotti (Dec 2005)
+ * Translated to X by H.G.Muller (Nov 2009)
+ *
+ * Copyright 2005 Alessandro Scotti
+ *
+ * Enhancements Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * GNU XBoard 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 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU XBoard 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ *
+ * ------------------------------------------------------------------------
+ ** See the file ChangeLog for a revision history. */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <string.h>
+#else /* not STDC_HEADERS */
+extern char *getenv();
+# if HAVE_STRING_H
+# include <string.h>
+# else /* not HAVE_STRING_H */
+# include <strings.h>
+# endif /* not HAVE_STRING_H */
+#endif /* not STDC_HEADERS */
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include "common.h"
+#include "backend.h"
+#include "dialogs.h"
+#include "menus.h"
+#include "evalgraph.h"
+#include "draw.h"
+#include "gettext.h"
+
+#ifdef ENABLE_NLS
+# define _(s) gettext (s)
+# define N_(s) gettext_noop (s)
+#else
+# define _(s) (s)
+# define N_(s) s
+#endif
+
+static char *title = N_("Evaluation graph");
+Option *disp;
+
+/* Module variables */
+
+static Option *EvalCallback P((int button, int x, int y));
+
+static int initDone = FALSE;
+
+static void
+InitializeEvalGraph (Option *opt, int w, int h)
+{
+ nWidthPB = w, nHeightPB = h;
+
+ initDone = TRUE;
+}
+
+// The following stuff is really back-end (but too little to bother with a separate file)
+
+static void
+EvalClick (int x, int y)
+{
+ int index = GetMoveIndexFromPoint( x, y );
+
+ if( index >= 0 && index < currLast ) ToNrEvent( index + 1 );
+}
+
+static Option graphOptions[] = {
+{ 150, 0x9C, 300, NULL, (void*) &EvalCallback, NULL, NULL, Graph , "" },
+{ 0, 2, 0, NULL, NULL, "", NULL, EndMark , "" }
+};
+
+static void
+DisplayEvalGraph ()
+{ // back-end painting; calls back front-end primitives for lines, rectangles and text
+ char *t = MakeEvalTitle(_(title));
+ nWidthPB = disp->max; nHeightPB = disp->value;
+ if(t != title && nWidthPB < 340) t = MakeEvalTitle(nWidthPB < 240 ? "" : _("Eval"));
+ PaintEvalGraph();
+ GraphExpose(graphOptions, 0, 0, nWidthPB, nHeightPB);
+ SetDialogTitle(EvalGraphDlg, t);
+}
+
+static Option *
+EvalCallback (int button, int x, int y)
+{
+ if(!initDone) return NULL;
+
+ switch(button) {
+ case 10: // expose event
+ /* Create or recreate paint box if needed */
+ if(x != nWidthPB || y != nHeightPB) {
+ InitializeEvalGraph(&graphOptions[0], x, y);
+ }
+ nWidthPB = x;
+ nHeightPB = y;
+ DisplayEvalGraph();
+ break;
+ case 1: EvalClick(x, y); // left button
+ default: break; // other buttons ignored
+ }
+ return NULL; // no context menu!
+}
+
+void
+EvalGraphPopUp ()
+{
+ if (GenericPopUp(graphOptions, _(title), EvalGraphDlg, BoardWindow, NONMODAL, 1)) {
+ InitializeEvalGraph(&graphOptions[0], wpEvalGraph.width, wpEvalGraph.height); // first time: add callbacks and initialize pens
+ disp = graphOptions;
+ } else {
+ SetDialogTitle(EvalGraphDlg, _(title));
+ SetIconName(EvalGraphDlg, _(title));
+ }
+
+ MarkMenu("View.EvaluationGraph", EvalGraphDlg);
+
+// ShowThinkingEvent(); // [HGM] thinking: might need to prompt engine for thinking output
+}
+
+void
+EvalGraphPopDown ()
+{
+ PopDown(EvalGraphDlg);
+
+// ShowThinkingEvent(); // [HGM] thinking: might need to shut off thinking output
+}
+
+Boolean
+EvalGraphIsUp ()
+{
+ return shellUp[EvalGraphDlg];
+}
+
+int
+EvalGraphDialogExists ()
+{
+ return DialogExists(EvalGraphDlg);
+}
+
+void
+EvalGraphProc ()
+{
+ if (!PopDown(EvalGraphDlg)) EvalGraphPopUp();
+}
+
+// This function is the interface to the back-end.
+
+void
+EvalGraphSet (int first, int last, int current, ChessProgramStats_Move * pvInfo)
+{
+ /* [AS] Danger! For now we rely on the pvInfo parameter being a static variable! */
+
+ currFirst = first;
+ currLast = last;
+ currCurrent = current;
+ currPvInfo = pvInfo;
+
+ if( DialogExists(EvalGraphDlg) ) {
+ DisplayEvalGraph();
+ }
+}
+
#include "childio.h"
#include "xgamelist.h"
#include "xhistory.h"
-#include "xevalgraph.h"
#include "menus.h"
#include "board.h"
#include "dialogs.h"
+++ /dev/null
-/*
- * Evaluation graph
- *
- * Author: Alessandro Scotti (Dec 2005)
- * Translated to X by H.G.Muller (Nov 2009)
- *
- * Copyright 2005 Alessandro Scotti
- *
- * Enhancements Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
- *
- * ------------------------------------------------------------------------
- *
- * GNU XBoard 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 3 of the License, or (at
- * your option) any later version.
- *
- * GNU XBoard 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- *
- * ------------------------------------------------------------------------
- ** See the file ChangeLog for a revision history. */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else /* not STDC_HEADERS */
-extern char *getenv();
-# if HAVE_STRING_H
-# include <string.h>
-# else /* not HAVE_STRING_H */
-# include <strings.h>
-# endif /* not HAVE_STRING_H */
-#endif /* not STDC_HEADERS */
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/Shell.h>
-#include <X11/Xaw/Dialog.h>
-#include <X11/Xaw/Form.h>
-#include <X11/Xaw/List.h>
-#include <X11/Xaw/Label.h>
-#include <X11/Xaw/SimpleMenu.h>
-#include <X11/Xaw/SmeBSB.h>
-#include <X11/Xaw/SmeLine.h>
-#include <X11/Xaw/Box.h>
-#include <X11/Xaw/Paned.h>
-#include <X11/Xaw/MenuButton.h>
-#include <X11/cursorfont.h>
-#include <X11/Xaw/Text.h>
-#include <X11/Xaw/AsciiText.h>
-#include <X11/Xaw/Viewport.h>
-
-#include <cairo/cairo.h>
-#include <cairo/cairo-xlib.h>
-
-#include "common.h"
-#include "frontend.h"
-#include "backend.h"
-#include "dialogs.h"
-#include "menus.h"
-#include "xboard.h"
-#include "evalgraph.h"
-#include "xevalgraph.h"
-#include "draw.h"
-#include "gettext.h"
-
-#ifdef ENABLE_NLS
-# define _(s) gettext (s)
-# define N_(s) gettext_noop (s)
-#else
-# define _(s) (s)
-# define N_(s) s
-#endif
-
-#include <X11/xpm.h>
-
-#ifdef SNAP
-#include "wsnap.h"
-#endif
-
-#define _LL_ 100
-
-Pixmap icons[8]; // [HGM] this front-end array translates back-end icon indicator to handle
-Widget outputField[2][7]; // [HGM] front-end array to translate output field to window handle
-static char *title = N_("Evaluation graph");
-
-//extern WindowPlacement wpEvalGraph;
-
-Position evalGraphX = -1, evalGraphY = -1;
-Dimension evalGraphW, evalGraphH;
-
-/* Module variables */
-
-char *crWhite = "#FFFFB0";
-char *crBlack = "#AD5D3D";
-Option *disp;
-
-static Option *EvalCallback P((int button, int x, int y));
-
-static void
-ChoosePen(cairo_t *cr, int i)
-{
- switch(i) {
- case PEN_BLACK:
- SetPen(cr, 1.0, "#000000", 0);
- break;
- case PEN_DOTTED:
- SetPen(cr, 1.0, "#A0A0A0", 1);
- break;
- case PEN_BLUEDOTTED:
- SetPen(cr, 1.0, "#0000FF", 1);
- break;
- case PEN_BOLDWHITE:
- SetPen(cr, 3.0, crWhite, 0);
- break;
- case PEN_BOLDBLACK:
- SetPen(cr, 3.0, crBlack, 0);
- break;
- case PEN_BACKGD:
- SetPen(cr, 3.0, "#E0E0F0", 0);
- break;
- }
-}
-
-// [HGM] front-end, added as wrapper to avoid use of LineTo and MoveToEx in other routines (so they can be back-end)
-void
-DrawSegment (int x, int y, int *lastX, int *lastY, enum PEN penType)
-{
- static int curX, curY;
-
- if(penType != PEN_NONE) {
- cairo_t *cr = cairo_create(DRAWABLE(disp));
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- cairo_move_to (cr, curX, curY);
- cairo_line_to (cr, x,y);
- ChoosePen(cr, penType);
- cairo_stroke (cr);
- cairo_destroy (cr);
- }
-
- if(lastX != NULL) { *lastX = curX; *lastY = curY; }
- curX = x; curY = y;
-}
-
-// front-end wrapper for drawing functions to do rectangles
-void
-DrawRectangle (int left, int top, int right, int bottom, int side, int style)
-{
- cairo_t *cr;
-
- cr = cairo_create (DRAWABLE(disp));
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- cairo_rectangle (cr, left, top, right-left, bottom-top);
- switch(side)
- {
- case 0: ChoosePen(cr, PEN_BOLDWHITE); break;
- case 1: ChoosePen(cr, PEN_BOLDBLACK); break;
- case 2: ChoosePen(cr, PEN_BACKGD); break;
- }
- cairo_fill (cr);
-
- if(style != FILLED)
- {
- cairo_rectangle (cr, left, top, right-left-1, bottom-top-1);
- ChoosePen(cr, PEN_BLACK);
- cairo_stroke (cr);
- }
-
- cairo_destroy(cr);
-}
-
-// front-end wrapper for putting text in graph
-void
-DrawEvalText (char *buf, int cbBuf, int y)
-{
- // the magic constants 8 and 5 should really be derived from the font size somehow
- cairo_text_extents_t extents;
- cairo_t *cr = cairo_create(DRAWABLE(disp));
-
- /* GTK-TODO this has to go into the font-selection */
- cairo_select_font_face (cr, "Sans",
- CAIRO_FONT_SLANT_NORMAL,
- CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size (cr, 12.0);
-
-
- cairo_text_extents (cr, buf, &extents);
-
- cairo_move_to (cr, MarginX - 2 - 8*cbBuf, y+5);
- cairo_text_path (cr, buf);
- cairo_set_source_rgb (cr, 0.0, 0.0, 0);
- cairo_fill_preserve (cr);
- cairo_set_source_rgb (cr, 0, 1.0, 0);
- cairo_set_line_width (cr, 0.1);
- cairo_stroke (cr);
-
- /* free memory */
- cairo_destroy (cr);
-}
-
-static int initDone = FALSE;
-
-static void
-InitializeEvalGraph (Option *opt, int w, int h)
-{
- if(w == 0) {
- Arg args[10];
- XtSetArg(args[0], XtNwidth, &evalGraphW);
- XtSetArg(args[1], XtNheight, &evalGraphH);
- XtGetValues(opt->handle, args, 2);
- nWidthPB = evalGraphW; nHeightPB = evalGraphH;
- } else nWidthPB = w, nHeightPB = h;
-
- initDone = TRUE;
-}
-
-// The following stuff is really back-end (but too little to bother with a separate file)
-
-static void
-EvalClick (int x, int y)
-{
- int index = GetMoveIndexFromPoint( x, y );
-
- if( index >= 0 && index < currLast ) ToNrEvent( index + 1 );
-}
-
-static Option graphOptions[] = {
-{ 150, 0x9C, 300, NULL, (void*) &EvalCallback, NULL, NULL, Graph , "" },
-{ 0, 2, 0, NULL, NULL, "", NULL, EndMark , "" }
-};
-
-static void
-DisplayEvalGraph ()
-{ // back-end painting; calls back front-end primitives for lines, rectangles and text
- char *t = MakeEvalTitle(_(title));
- nWidthPB = disp->max; nHeightPB = disp->value;
- if(t != title && nWidthPB < 340) t = MakeEvalTitle(nWidthPB < 240 ? "" : _("Eval"));
- PaintEvalGraph();
- GraphExpose(graphOptions, 0, 0, nWidthPB, nHeightPB);
- SetDialogTitle(EvalGraphDlg, t);
-}
-
-static Option *
-EvalCallback (int button, int x, int y)
-{
- if(!initDone) return NULL;
-
- switch(button) {
- case 10: // expose event
- /* Create or recreate paint box if needed */
- if(x != nWidthPB || y != nHeightPB) {
- InitializeEvalGraph(&graphOptions[0], x, y);
- }
- nWidthPB = x;
- nHeightPB = y;
- DisplayEvalGraph();
- break;
- case 1: EvalClick(x, y); // left button
- default: break; // other buttons ignored
- }
- return NULL; // no context menu!
-}
-
-void
-EvalGraphPopUp ()
-{
- if (GenericPopUp(graphOptions, _(title), EvalGraphDlg, BoardWindow, NONMODAL, 1)) {
- InitializeEvalGraph(&graphOptions[0], 0, 0); // first time: add callbacks and initialize pens
- disp = graphOptions;
- } else {
- SetDialogTitle(EvalGraphDlg, _(title));
- SetIconName(EvalGraphDlg, _(title));
- }
-
- MarkMenu("View.EvaluationGraph", EvalGraphDlg);
-
-// ShowThinkingEvent(); // [HGM] thinking: might need to prompt engine for thinking output
-}
-
-void
-EvalGraphPopDown ()
-{
- PopDown(EvalGraphDlg);
-
-// ShowThinkingEvent(); // [HGM] thinking: might need to shut off thinking output
-}
-
-Boolean
-EvalGraphIsUp ()
-{
- return shellUp[EvalGraphDlg];
-}
-
-int
-EvalGraphDialogExists ()
-{
- return DialogExists(EvalGraphDlg);
-}
-
-void
-EvalGraphProc ()
-{
- if (!PopDown(EvalGraphDlg)) EvalGraphPopUp();
-}
-
-// This function is the interface to the back-end.
-
-void
-EvalGraphSet (int first, int last, int current, ChessProgramStats_Move * pvInfo)
-{
- /* [AS] Danger! For now we rely on the pvInfo parameter being a static variable! */
-
- currFirst = first;
- currLast = last;
- currCurrent = current;
- currPvInfo = pvInfo;
-
- if( DialogExists(EvalGraphDlg) ) {
- DisplayEvalGraph();
- }
-}
-
+++ /dev/null
-/*
- * xevalgraph.h
- *
- * Copyright 2010, 2011, 2012 Free Software Foundation, Inc.
- *
- * ------------------------------------------------------------------------
- *
- * GNU XBoard 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 3 of the License, or (at
- * your option) any later version.
- *
- * GNU XBoard 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/. *
- *
- *------------------------------------------------------------------------
- ** See the file ChangeLog for a revision history. */
-
-#ifndef XB_XEVALGRAPH
-#define XB_XEVALGRAPH
-
-void EvalGraphSet P(( int first, int last, int current, ChessProgramStats_Move * pvInfo ));
-float Color P((char *col, int n));
-void SetPen P((cairo_t *cr, float w, char *col, int dash));
-
-#endif
#include "childio.h"
#include "xgamelist.h"
#include "xhistory.h"
-#include "xevalgraph.h"
#include "menus.h"
#include "board.h"
#include "dialogs.h"
+++ /dev/null
-/*
- * Evaluation graph
- *
- * Author: Alessandro Scotti (Dec 2005)
- * Translated to X by H.G.Muller (Nov 2009)
- *
- * Copyright 2005 Alessandro Scotti
- *
- * Enhancements Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
- *
- * ------------------------------------------------------------------------
- *
- * GNU XBoard 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 3 of the License, or (at
- * your option) any later version.
- *
- * GNU XBoard 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- *
- * ------------------------------------------------------------------------
- ** See the file ChangeLog for a revision history. */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else /* not STDC_HEADERS */
-extern char *getenv();
-# if HAVE_STRING_H
-# include <string.h>
-# else /* not HAVE_STRING_H */
-# include <strings.h>
-# endif /* not HAVE_STRING_H */
-#endif /* not STDC_HEADERS */
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/Shell.h>
-#include <X11/Xaw/Dialog.h>
-#include <X11/Xaw/Form.h>
-#include <X11/Xaw/List.h>
-#include <X11/Xaw/Label.h>
-#include <X11/Xaw/SimpleMenu.h>
-#include <X11/Xaw/SmeBSB.h>
-#include <X11/Xaw/SmeLine.h>
-#include <X11/Xaw/Box.h>
-#include <X11/Xaw/Paned.h>
-#include <X11/Xaw/MenuButton.h>
-#include <X11/cursorfont.h>
-#include <X11/Xaw/Text.h>
-#include <X11/Xaw/AsciiText.h>
-#include <X11/Xaw/Viewport.h>
-
-#include <cairo/cairo.h>
-#include <cairo/cairo-xlib.h>
-
-#include "common.h"
-#include "frontend.h"
-#include "backend.h"
-#include "dialogs.h"
-#include "menus.h"
-#include "xboard.h"
-#include "evalgraph.h"
-#include "xevalgraph.h"
-#include "draw.h"
-#include "gettext.h"
-
-#ifdef ENABLE_NLS
-# define _(s) gettext (s)
-# define N_(s) gettext_noop (s)
-#else
-# define _(s) (s)
-# define N_(s) s
-#endif
-
-#include <X11/xpm.h>
-
-#ifdef SNAP
-#include "wsnap.h"
-#endif
-
-#define _LL_ 100
-
-Pixmap icons[8]; // [HGM] this front-end array translates back-end icon indicator to handle
-Widget outputField[2][7]; // [HGM] front-end array to translate output field to window handle
-static char *title = N_("Evaluation graph");
-
-//extern WindowPlacement wpEvalGraph;
-
-Position evalGraphX = -1, evalGraphY = -1;
-Dimension evalGraphW, evalGraphH;
-
-/* Module variables */
-
-char *crWhite = "#FFFFB0";
-char *crBlack = "#AD5D3D";
-Option *disp;
-
-static Option *EvalCallback P((int button, int x, int y));
-
-static void
-ChoosePen(cairo_t *cr, int i)
-{
- switch(i) {
- case PEN_BLACK:
- SetPen(cr, 1.0, "#000000", 0);
- break;
- case PEN_DOTTED:
- SetPen(cr, 1.0, "#A0A0A0", 1);
- break;
- case PEN_BLUEDOTTED:
- SetPen(cr, 1.0, "#0000FF", 1);
- break;
- case PEN_BOLDWHITE:
- SetPen(cr, 3.0, crWhite, 0);
- break;
- case PEN_BOLDBLACK:
- SetPen(cr, 3.0, crBlack, 0);
- break;
- case PEN_BACKGD:
- SetPen(cr, 3.0, "#E0E0F0", 0);
- break;
- }
-}
-
-// [HGM] front-end, added as wrapper to avoid use of LineTo and MoveToEx in other routines (so they can be back-end)
-void
-DrawSegment (int x, int y, int *lastX, int *lastY, enum PEN penType)
-{
- static int curX, curY;
-
- if(penType != PEN_NONE) {
- cairo_t *cr = cairo_create(DRAWABLE(disp));
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- cairo_move_to (cr, curX, curY);
- cairo_line_to (cr, x,y);
- ChoosePen(cr, penType);
- cairo_stroke (cr);
- cairo_destroy (cr);
- }
-
- if(lastX != NULL) { *lastX = curX; *lastY = curY; }
- curX = x; curY = y;
-}
-
-// front-end wrapper for drawing functions to do rectangles
-void
-DrawRectangle (int left, int top, int right, int bottom, int side, int style)
-{
- cairo_t *cr;
-
- cr = cairo_create (DRAWABLE(disp));
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- cairo_rectangle (cr, left, top, right-left, bottom-top);
- switch(side)
- {
- case 0: ChoosePen(cr, PEN_BOLDWHITE); break;
- case 1: ChoosePen(cr, PEN_BOLDBLACK); break;
- case 2: ChoosePen(cr, PEN_BACKGD); break;
- }
- cairo_fill (cr);
-
- if(style != FILLED)
- {
- cairo_rectangle (cr, left, top, right-left-1, bottom-top-1);
- ChoosePen(cr, PEN_BLACK);
- cairo_stroke (cr);
- }
-
- cairo_destroy(cr);
-}
-
-// front-end wrapper for putting text in graph
-void
-DrawEvalText (char *buf, int cbBuf, int y)
-{
- // the magic constants 8 and 5 should really be derived from the font size somehow
- cairo_text_extents_t extents;
- cairo_t *cr = cairo_create(DRAWABLE(disp));
-
- /* GTK-TODO this has to go into the font-selection */
- cairo_select_font_face (cr, "Sans",
- CAIRO_FONT_SLANT_NORMAL,
- CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size (cr, 12.0);
-
-
- cairo_text_extents (cr, buf, &extents);
-
- cairo_move_to (cr, MarginX - 2 - 8*cbBuf, y+5);
- cairo_text_path (cr, buf);
- cairo_set_source_rgb (cr, 0.0, 0.0, 0);
- cairo_fill_preserve (cr);
- cairo_set_source_rgb (cr, 0, 1.0, 0);
- cairo_set_line_width (cr, 0.1);
- cairo_stroke (cr);
-
- /* free memory */
- cairo_destroy (cr);
-}
-
-static int initDone = FALSE;
-
-static void
-InitializeEvalGraph (Option *opt, int w, int h)
-{
- if(w == 0) {
- Arg args[10];
- XtSetArg(args[0], XtNwidth, &evalGraphW);
- XtSetArg(args[1], XtNheight, &evalGraphH);
- XtGetValues(opt->handle, args, 2);
- nWidthPB = evalGraphW; nHeightPB = evalGraphH;
- } else nWidthPB = w, nHeightPB = h;
-
- initDone = TRUE;
-}
-
-// The following stuff is really back-end (but too little to bother with a separate file)
-
-static void
-EvalClick (int x, int y)
-{
- int index = GetMoveIndexFromPoint( x, y );
-
- if( index >= 0 && index < currLast ) ToNrEvent( index + 1 );
-}
-
-static Option graphOptions[] = {
-{ 150, 0x9C, 300, NULL, (void*) &EvalCallback, NULL, NULL, Graph , "" },
-{ 0, 2, 0, NULL, NULL, "", NULL, EndMark , "" }
-};
-
-static void
-DisplayEvalGraph ()
-{ // back-end painting; calls back front-end primitives for lines, rectangles and text
- char *t = MakeEvalTitle(_(title));
- nWidthPB = disp->max; nHeightPB = disp->value;
- if(t != title && nWidthPB < 340) t = MakeEvalTitle(nWidthPB < 240 ? "" : _("Eval"));
- PaintEvalGraph();
- GraphExpose(graphOptions, 0, 0, nWidthPB, nHeightPB);
- SetDialogTitle(EvalGraphDlg, t);
-}
-
-static Option *
-EvalCallback (int button, int x, int y)
-{
- if(!initDone) return NULL;
-
- switch(button) {
- case 10: // expose event
- /* Create or recreate paint box if needed */
- if(x != nWidthPB || y != nHeightPB) {
- InitializeEvalGraph(&graphOptions[0], x, y);
- }
- nWidthPB = x;
- nHeightPB = y;
- DisplayEvalGraph();
- break;
- case 1: EvalClick(x, y); // left button
- default: break; // other buttons ignored
- }
- return NULL; // no context menu!
-}
-
-void
-EvalGraphPopUp ()
-{
- if (GenericPopUp(graphOptions, _(title), EvalGraphDlg, BoardWindow, NONMODAL, 1)) {
- InitializeEvalGraph(&graphOptions[0], 0, 0); // first time: add callbacks and initialize pens
- disp = graphOptions;
- } else {
- SetDialogTitle(EvalGraphDlg, _(title));
- SetIconName(EvalGraphDlg, _(title));
- }
-
- MarkMenu("View.EvaluationGraph", EvalGraphDlg);
-
-// ShowThinkingEvent(); // [HGM] thinking: might need to prompt engine for thinking output
-}
-
-void
-EvalGraphPopDown ()
-{
- PopDown(EvalGraphDlg);
-
-// ShowThinkingEvent(); // [HGM] thinking: might need to shut off thinking output
-}
-
-Boolean
-EvalGraphIsUp ()
-{
- return shellUp[EvalGraphDlg];
-}
-
-int
-EvalGraphDialogExists ()
-{
- return DialogExists(EvalGraphDlg);
-}
-
-void
-EvalGraphProc ()
-{
- if (!PopDown(EvalGraphDlg)) EvalGraphPopUp();
-}
-
-// This function is the interface to the back-end.
-
-void
-EvalGraphSet (int first, int last, int current, ChessProgramStats_Move * pvInfo)
-{
- /* [AS] Danger! For now we rely on the pvInfo parameter being a static variable! */
-
- currFirst = first;
- currLast = last;
- currCurrent = current;
- currPvInfo = pvInfo;
-
- if( DialogExists(EvalGraphDlg) ) {
- DisplayEvalGraph();
- }
-}
-
+++ /dev/null
-/*
- * xevalgraph.h
- *
- * Copyright 2010, 2011, 2012 Free Software Foundation, Inc.
- *
- * ------------------------------------------------------------------------
- *
- * GNU XBoard 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 3 of the License, or (at
- * your option) any later version.
- *
- * GNU XBoard 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/. *
- *
- *------------------------------------------------------------------------
- ** See the file ChangeLog for a revision history. */
-
-#ifndef XB_XEVALGRAPH
-#define XB_XEVALGRAPH
-
-void EvalGraphSet P(( int first, int last, int current, ChessProgramStats_Move * pvInfo ));
-float Color P((char *col, int n));
-void SetPen P((cairo_t *cr, float w, char *col, int dash));
-
-#endif