*
* Copyright 2005 Alessandro Scotti
*
- * Enhancements Copyright 2009 Free Software Foundation, Inc.
+ * Enhancements Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
*
* ------------------------------------------------------------------------
*
#include <X11/xpm.h>
-// [HGM] pixmaps of some ICONS used in the engine-outut window
-#include "pixmaps/WHITE_14.xpm"
-#include "pixmaps/BLACK_14.xpm"
-#include "pixmaps/CLEAR_14.xpm"
-#include "pixmaps/UNKNOWN_14.xpm"
-#include "pixmaps/THINKING_14.xpm"
-#include "pixmaps/PONDER_14.xpm"
-#include "pixmaps/ANALYZING_14.xpm"
-
#ifdef SNAP
#include "wsnap.h"
#endif
#define _LL_ 100
-// imports from xboard.c
-extern Widget formWidget, shellWidget, boardWidget, menuBarWidget;
-extern Display *xDisplay;
-extern Window xBoardWindow;
-extern int squareSize;
-extern Pixmap xMarkPixmap, wIconPixmap, bIconPixmap;
-extern char *layoutName;
-
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
-
-/* Imports from backend.c */
-
-/* Imports from xboard.c */
-extern Arg layoutArgs[2], formArgs[2], messageArgs[4];
-extern GC coordGC;
+static char *title = N_("Evaluation graph");
//extern WindowPlacement wpEvalGraph;
static HBITMAP hbmPB = NULL;
#endif
-// [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 )
+// [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 curX, curY;
- if(penType != PEN_NONE)
- XDrawLine(yDisplay, eGraphWindow, pens[penType], curX, curY, x, y);
- if(lastX != NULL) { *lastX = curX; *lastY = curY; }
- curX = x; curY = y;
+ static int curX, curY;
+
+ if(penType != PEN_NONE)
+ XDrawLine(yDisplay, eGraphWindow, pens[penType], curX, curY, x, y);
+ 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 )
+void
+DrawRectangle (int left, int top, int right, int bottom, int side, int style)
{
XFillRectangle(yDisplay, eGraphWindow, hbrHist[side], left, top, right-left, bottom-top);
if(style != FILLED)
}
// front-end wrapper for putting text in graph
-void DrawEvalText(char *buf, int cbBuf, int y)
+void
+DrawEvalText (char *buf, int cbBuf, int y)
{
// the magic constants 7 and 5 should really be derived from the font size somehow
XDrawString(yDisplay, eGraphWindow, coordGC, MarginX - 2 - 7*cbBuf, y+5, buf, cbBuf);
}
// front-end
-static Pixel MakeColor(char *color )
+static Pixel
+MakeColor (char *color)
{
XrmValue vFrom, vTo;
return *(Pixel *) vTo.addr;
}
-static GC CreateGC(int width, char *fg, char *bg, int style)
+static GC
+CreateGC (int width, char *fg, char *bg, int style)
{
XtGCMask value_mask = GCLineWidth | GCLineStyle | GCForeground
| GCBackground | GCFunction | GCPlaneMask;
// front-end. Create pens, device context and buffer bitmap for global use, copy result to display
// The back-end part n the middle has been taken out and moed to PainEvalGraph()
-static void DisplayEvalGraph()
+static void
+DisplayEvalGraph ()
{
int j;
int width;
// back-end painting; calls back front-end primitives for lines, rectangles and text
PaintEvalGraph();
+ XtSetArg(args[0], XtNtitle, MakeEvalTitle(_(title))); j++;
+ XtSetValues(evalGraphShell, args, 1);
XSync(yDisplay, False);
}
-static void InitializeEvalGraph()
-{ int i; XtGCMask value_mask = GCLineWidth | GCLineStyle | GCForeground
- | GCBackground | GCFunction | GCPlaneMask;
- XGCValues gc_values;
-// GC copyInvertedGC;
-
- pens[PEN_BLACK] = CreateGC(1, "black", "black", LineSolid);
- pens[PEN_DOTTED] = CreateGC(1, "#A0A0A0", "#A0A0A0", LineOnOffDash);
- pens[PEN_BLUEDOTTED] = CreateGC(1, "#0000FF", "#0000FF", LineOnOffDash);
- pens[PEN_BOLD] = CreateGC(3, crWhite, crWhite, LineSolid);
- pens[PEN_BOLD+1] = CreateGC(3, crBlack, crBlack, LineSolid);
- hbrHist[0] = CreateGC(3, crWhite, crWhite, LineSolid);
- hbrHist[1] = CreateGC(3, crBlack, crBlack, LineSolid);
- hbrHist[2] = CreateGC(3, "#E0E0F0", "#E0E0F0", LineSolid);; // background (a bit blueish, for contrst with yellow curve)
+static void
+InitializeEvalGraph ()
+{
+ pens[PEN_BLACK] = CreateGC(1, "black", "black", LineSolid);
+ pens[PEN_DOTTED] = CreateGC(1, "#A0A0A0", "#A0A0A0", LineOnOffDash);
+ pens[PEN_BLUEDOTTED] = CreateGC(1, "#0000FF", "#0000FF", LineOnOffDash);
+ pens[PEN_BOLD] = CreateGC(3, crWhite, crWhite, LineSolid);
+ pens[PEN_BOLD+1] = CreateGC(3, crBlack, crBlack, LineSolid);
+ hbrHist[0] = CreateGC(3, crWhite, crWhite, LineSolid);
+ hbrHist[1] = CreateGC(3, crBlack, crBlack, LineSolid);
+ hbrHist[2] = CreateGC(3, "#E0E0F0", "#E0E0F0", LineSolid);; // background (a bit blueish, for contrst with yellow curve)
}
-void EvalClick(widget, unused, event)
- Widget widget;
- caddr_t unused;
- XEvent *event;
+void
+EvalClick (Widget widget, caddr_t unused, XEvent *event)
{
if( widget && event->type == ButtonPress ) {
int index = GetMoveIndexFromPoint( event->xbutton.x, event->xbutton.y );
// This (cloned from EventProc in xboard.c) is needed as event handler, to prevent
// the graph being wiped out after covering / uncovering by other windows.
-void EvalEventProc(widget, unused, event)
- Widget widget;
- caddr_t unused;
- XEvent *event;
+void
+EvalEventProc (Widget widget, caddr_t unused, XEvent *event)
{
if (!XtIsRealized(widget))
return;
}
// The following routines are mutated clones of the commentPopUp routines
-Widget EvalGraphCreate(name)
- char *name;
+Widget
+EvalGraphCreate (char *name)
{
Arg args[16];
- Widget shell, layout, form, form2, edit;
+ Widget shell, layout, form;
Dimension bw_width, bw_height;
int j;
j = 0;
XtSetArg(args[j], XtNresizable, True); j++;
shell =
-#if TOPLEVEL
+#if TOPLEVEL
XtCreatePopupShell(name, topLevelShellWidgetClass,
#else
XtCreatePopupShell(name, transientShellWidgetClass,
if (evalGraphX == -1) {
int xx, yy;
Window junk;
- Dimension pw_height;
- Dimension ew_height;
evalGraphH = bw_height/4;
evalGraphW = bw_width-16;
XtSetArg(args[j], XtNx, evalGraphX); j++;
XtSetArg(args[j], XtNy, evalGraphY); j++;
XtSetValues(shell, args, j);
-// XtSetKeyboardFocus(shell, edit);
yDisplay = XtDisplay(shell);
eGraphWindow = XtWindow(form);
return shell;
}
-void
-EvalGraphPopUp()
+void
+EvalGraphPopUp ()
{
Arg args[16];
int j;
- Widget edit;
static int needInit = TRUE;
- static char *title = _("Evaluation graph");
if (evalGraphShell == NULL) {
evalGraphShell =
- EvalGraphCreate(title);
+ EvalGraphCreate(_(title));
XtRealizeWidget(evalGraphShell);
CatchDeleteWindow(evalGraphShell, "EvalGraphPopDown");
if( needInit ) {
}
} else {
j = 0;
- XtSetArg(args[j], XtNiconName, (XtArgVal) title); j++;
- XtSetArg(args[j], XtNtitle, (XtArgVal) title); j++;
+ XtSetArg(args[j], XtNiconName, (XtArgVal) _(title)); j++;
+ XtSetArg(args[j], XtNtitle, (XtArgVal) _(title)); j++;
XtSetValues(evalGraphShell, args, j);
}
j=0;
XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++;
- XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Evaluation Graph"),
+ XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Evaluation Graph"),
args, j);
evalGraphDialogUp = True;
// ShowThinkingEvent(); // [HGM] thinking: might need to prompt engine for thinking output
}
-void EvalGraphPopDown()
+void
+EvalGraphPopDown ()
{
Arg args[16];
int j;
XSync(xDisplay, False);
j=0;
XtSetArg(args[j], XtNleftBitmap, None); j++;
- XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Evaluation Graph"),
+ XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Evaluation Graph"),
args, j);
evalGraphDialogUp = False;
// ShowThinkingEvent(); // [HGM] thinking: might need to shut off thinking output
}
-Boolean EvalGraphIsUp()
+Boolean
+EvalGraphIsUp ()
{
return evalGraphDialogUp;
}
-int EvalGraphDialogExists()
+int
+EvalGraphDialogExists ()
{
return evalGraphShell != NULL;
}
void
-EvalGraphProc(w, event, prms, nprms)
- Widget w;
- XEvent *event;
- String *prms;
- Cardinal *nprms;
+EvalGraphProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
{
if (evalGraphDialogUp) {
EvalGraphPopDown();
// This function is the interface to the back-end. It is currently called through the front-end,
// though, where it shares the HistorySet() wrapper with MoveHistorySet(). Once all front-ends
// support the eval graph, it would be more logical to call it directly from the back-end.
-void EvalGraphSet( int first, int last, int current, ChessProgramStats_Move * pvInfo )
+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! */