Create General-Options dialog
[xboard.git] / xoptions.c
1 /*
2  * xoptions.c -- Move list window, part of X front end for XBoard
3  *
4  * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc.
5  * ------------------------------------------------------------------------
6  *
7  * GNU XBoard is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or (at
10  * your option) any later version.
11  *
12  * GNU XBoard is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see http://www.gnu.org/licenses/.  *
19  *
20  *------------------------------------------------------------------------
21  ** See the file ChangeLog for a revision history.  */
22
23 // [HGM] this file is the counterpart of woptions.c, containing xboard popup menus
24 // similar to those of WinBoard, to set the most common options interactively.
25
26 #include "config.h"
27
28 #include <stdio.h>
29 #include <ctype.h>
30 #include <errno.h>
31 #include <sys/types.h>
32
33 #if STDC_HEADERS
34 # include <stdlib.h>
35 # include <string.h>
36 #else /* not STDC_HEADERS */
37 extern char *getenv();
38 # if HAVE_STRING_H
39 #  include <string.h>
40 # else /* not HAVE_STRING_H */
41 #  include <strings.h>
42 # endif /* not HAVE_STRING_H */
43 #endif /* not STDC_HEADERS */
44
45 #if HAVE_UNISTD_H
46 # include <unistd.h>
47 #endif
48 #include <stdint.h>
49
50 #include <X11/Intrinsic.h>
51 #include <X11/StringDefs.h>
52 #include <X11/Shell.h>
53 #include <X11/Xaw/Dialog.h>
54 #include <X11/Xaw/Form.h>
55 #include <X11/Xaw/List.h>
56 #include <X11/Xaw/Label.h>
57 #include <X11/Xaw/SimpleMenu.h>
58 #include <X11/Xaw/SmeBSB.h>
59 #include <X11/Xaw/SmeLine.h>
60 #include <X11/Xaw/Box.h>
61 #include <X11/Xaw/Paned.h>
62 #include <X11/Xaw/MenuButton.h>
63 #include <X11/cursorfont.h>
64 #include <X11/Xaw/Text.h>
65 #include <X11/Xaw/AsciiText.h>
66 #include <X11/Xaw/Viewport.h>
67 #include <X11/Xaw/Toggle.h>
68
69 #include "common.h"
70 #include "backend.h"
71 #include "xboard.h"
72 #include "gettext.h"
73
74 #ifdef ENABLE_NLS
75 # define  _(s) gettext (s)
76 # define N_(s) gettext_noop (s)
77 #else
78 # define  _(s) (s)
79 # define N_(s)  s
80 #endif
81
82 extern void SendToProgram P((char *message, ChessProgramState *cps));
83 FILE * XsraSelFile P((Widget w, char *prompt, char *ok, char *cancel, char *failed,
84                 char *init_path, char *mode, int (*show_entry)(), char **name_return));
85
86 extern Widget formWidget, shellWidget, boardWidget, menuBarWidget;
87 extern Display *xDisplay;
88 extern int squareSize;
89 extern Pixmap xMarkPixmap;
90 extern char *layoutName;
91 extern Window xBoardWindow;
92 extern Arg layoutArgs[2], formArgs[2];
93 Pixel timerForegroundPixel, timerBackgroundPixel;
94 extern int searchTime;
95 extern int lineGap;
96
97 // [HGM] the following code for makng menu popups was cloned from the FileNamePopUp routines
98
99 static Widget previous = NULL;
100
101 void SetFocus(Widget w, XtPointer data, XEvent *event, Boolean *b)
102 {
103     Arg args[2];
104     char *s;
105
106     if(previous) {
107         XtSetArg(args[0], XtNdisplayCaret, False);
108         XtSetValues(previous, args, 1);
109     }
110     XtSetArg(args[0], XtNstring, &s);
111     XtGetValues(w, args, 1);
112     XtSetArg(args[0], XtNdisplayCaret, True);
113     XtSetArg(args[1], XtNinsertPosition, strlen(s));
114     XtSetValues(w, args, 2);
115     XtSetKeyboardFocus((Widget) data, w);
116     previous = w;
117 }
118
119 //--------------------------- New Shuffle Game --------------------------------------------
120 extern int shuffleOpenings;
121 extern int startedFromPositionFile;
122 int shuffleUp;
123 Widget shuffleShell;
124
125 void ShufflePopDown()
126 {
127     if (!shuffleUp) return;
128     XtPopdown(shuffleShell);
129     XtDestroyWidget(shuffleShell);
130     shuffleUp = False;
131     ModeHighlight();
132 }
133
134 void ShuffleCallback(w, client_data, call_data)
135      Widget w;
136      XtPointer client_data, call_data;
137 {
138     String name;
139     Widget w2;
140     Arg args[16];
141     char buf[MSG_SIZ];
142
143     XtSetArg(args[0], XtNlabel, &name);
144     XtGetValues(w, args, 1);
145
146     if (strcmp(name, _("cancel")) == 0) {
147         ShufflePopDown();
148         return;
149     }
150     if (strcmp(name, _("off")) == 0) {
151         ShufflePopDown();
152         shuffleOpenings = False; // [HGM] should be moved to New Variant menu, once we have it!
153         ResetGameEvent();
154         return;
155     }
156     if (strcmp(name, _("random")) == 0) {
157       snprintf(buf, MSG_SIZ,  "%d", rand());
158         XtSetArg(args[0],XtNvalue, buf); // erase bad (non-numeric) value
159         XtSetValues(XtParent(w), args, 1);
160         return;
161     }
162     if (strcmp(name, _("ok")) == 0) {
163         int nr; String name;
164         name = XawDialogGetValueString(w2 = XtParent(w));
165         if(sscanf(name ,"%d",&nr) != 1) {
166           snprintf(buf, MSG_SIZ,  "%d", appData.defaultFrcPosition);
167             XtSetArg(args[0],XtNvalue, buf); // erase bad (non-numeric) value
168             XtSetValues(w2, args, 1);
169             return;
170         }
171         appData.defaultFrcPosition = nr;
172         shuffleOpenings = True;
173         ShufflePopDown();
174         ResetGameEvent();
175         return;
176     }
177 }
178
179 void ShufflePopUp()
180 {
181     Arg args[16];
182     Widget popup, layout, dialog, edit;
183     Window root, child;
184     int x, y, i;
185     int win_x, win_y;
186     unsigned int mask;
187     char def[MSG_SIZ];
188
189     i = 0;
190     XtSetArg(args[i], XtNresizable, True); i++;
191     XtSetArg(args[i], XtNwidth, DIALOG_SIZE); i++;
192     shuffleShell = popup =
193       XtCreatePopupShell(_("New Shuffle Game"), transientShellWidgetClass,
194                          shellWidget, args, i);
195
196     layout =
197       XtCreateManagedWidget(layoutName, formWidgetClass, popup,
198                             layoutArgs, XtNumber(layoutArgs));
199
200     snprintf(def, MSG_SIZ,  "%d\n", appData.defaultFrcPosition);
201     i = 0;
202     XtSetArg(args[i], XtNlabel, _("Start-position number:")); i++;
203     XtSetArg(args[i], XtNvalue, def); i++;
204     XtSetArg(args[i], XtNborderWidth, 0); i++;
205     dialog = XtCreateManagedWidget(_("Shuffle"), dialogWidgetClass,
206                                    layout, args, i);
207
208 //    XtSetArg(args[0], XtNeditType, XawtextEdit);  // [HGM] can't get edit to work decently
209 //    XtSetArg(args[1], XtNuseStringInPlace, False);
210 //    XtSetValues(dialog, args, 2);
211
212     XawDialogAddButton(dialog, _("ok"), ShuffleCallback, (XtPointer) dialog);
213     XawDialogAddButton(dialog, _("cancel"), ShuffleCallback, (XtPointer) dialog);
214     XawDialogAddButton(dialog, _("random"), ShuffleCallback, (XtPointer) dialog);
215     XawDialogAddButton(dialog, _("off"), ShuffleCallback, (XtPointer) dialog);
216
217     XtRealizeWidget(popup);
218     CatchDeleteWindow(popup, "ShufflePopDown");
219
220     XQueryPointer(xDisplay, xBoardWindow, &root, &child,
221                   &x, &y, &win_x, &win_y, &mask);
222
223     XtSetArg(args[0], XtNx, x - 10);
224     XtSetArg(args[1], XtNy, y - 30);
225     XtSetValues(popup, args, 2);
226
227     XtPopup(popup, XtGrabExclusive);
228     shuffleUp = True;
229
230     edit = XtNameToWidget(dialog, "*value");
231
232     XtSetKeyboardFocus(popup, edit);
233 }
234
235 void ShuffleMenuProc(w, event, prms, nprms)
236      Widget w;
237      XEvent *event;
238      String *prms;
239      Cardinal *nprms;
240 {
241 //    if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
242 //      Reset(FALSE, TRUE);
243 //    }
244     ShufflePopUp();
245 }
246
247 //--------------------------- Time-Control Menu Popup ----------------------------------
248 int TimeControlUp;
249 Widget TimeControlShell;
250 int tcInc;
251 Widget tcMess1, tcMess2, tcData, tcTime, tcOdds1, tcOdds2;
252 int tcIncrement, tcMoves;
253
254 void TimeControlPopDown()
255 {
256     if (!TimeControlUp) return;
257     previous = NULL;
258     XtPopdown(TimeControlShell);
259     XtDestroyWidget(TimeControlShell);
260     TimeControlUp = False;
261     ModeHighlight();
262 }
263
264 void TimeControlCallback(w, client_data, call_data)
265      Widget w;
266      XtPointer client_data, call_data;
267 {
268     String name, txt;
269     Arg args[16];
270     char buf[MSG_SIZ];
271     int j;
272
273     XtSetArg(args[0], XtNlabel, &name);
274     XtGetValues(w, args, 1);
275
276     if (strcmp(name, _("classical")) == 0) {
277         if(tcInc == 0) return;
278         j=0;
279         XtSetArg(args[j], XtNlabel, _("minutes for each")); j++;
280         XtSetValues(tcMess1, args, j);
281         j=0;
282         XtSetArg(args[j], XtNlabel, _("moves")); j++;
283         XtSetValues(tcMess2, args, j);
284         if(tcInc == 1) {
285             j=0;
286             XtSetArg(args[j], XtNstring, &name); j++;
287             XtGetValues(tcData, args, j);
288             tcIncrement = 0; sscanf(name, "%d", &tcIncrement);
289         }
290         snprintf(buf, MSG_SIZ,  "%d", tcMoves);
291         j=0;
292         XtSetArg(args[j], XtNstring, buf); j++;
293         XtSetValues(tcData, args, j);
294         tcInc = 0;
295         return;
296     }
297     if (strcmp(name, _("incremental")) == 0) {
298         if(tcInc == 1) return;
299         j=0;
300         XtSetArg(args[j], XtNlabel, _("minutes, plus")); j++;
301         XtSetValues(tcMess1, args, j);
302         j=0;
303         XtSetArg(args[j], XtNlabel, _("sec/move")); j++;
304         XtSetValues(tcMess2, args, j);
305         if(tcInc == 0) {
306             j=0;
307             XtSetArg(args[j], XtNstring, &name); j++;
308             XtGetValues(tcData, args, j);
309             tcMoves = appData.movesPerSession; sscanf(name, "%d", &tcMoves);
310         }
311         snprintf(buf, MSG_SIZ,  "%d", tcIncrement);
312         j=0;
313         XtSetArg(args[j], XtNstring, buf); j++;
314         XtSetValues(tcData, args, j);
315         tcInc = 1;
316         return;
317     }
318     if (strcmp(name, _("fixed time")) == 0) {
319         if(tcInc == 2) return;
320         j=0;
321         XtSetArg(args[j], XtNlabel, _("sec/move (max)")); j++;
322         XtSetValues(tcMess1, args, j);
323         j=0;
324         XtSetArg(args[j], XtNlabel, _("")); j++;
325         XtSetValues(tcMess2, args, j);
326         j=0;
327         XtSetArg(args[j], XtNstring, ""); j++;
328         XtSetValues(tcData, args, j);
329         tcInc = 2;
330         return;
331     }
332     if (strcmp(name, _(" OK ")) == 0) {
333         int inc, mps, ok;
334         XtSetArg(args[0], XtNstring, &txt);
335         XtGetValues(tcData, args, 1);
336         switch(tcInc) {
337           case 1:
338             ok = sscanf(txt, "%d", &inc); mps = 0;
339             if(!ok && txt[0] == 0) { inc = 0; ok = 1; } // accept empty string as zero
340             ok &= (inc >= 0);
341             break;
342           case 0:
343             ok = sscanf(txt, "%d", &mps); inc = -1;
344             ok &= (mps > 0);
345             break;
346           case 2:
347             ok = 1; inc = -1; mps = 40;
348         }
349         if(ok != 1) {
350             XtSetArg(args[0], XtNstring, ""); // erase any offending input
351             XtSetValues(tcData, args, 1);
352             return;
353         }
354         XtSetArg(args[0], XtNstring, &txt);
355         XtGetValues(tcTime, args, 1);
356         if(tcInc == 2) {
357             if(sscanf(txt, "%d", &inc) != 1) {
358                 XtSetArg(args[0], XtNstring, ""); // erase any offending input
359                 XtSetValues(tcTime, args, 1);
360                 DisplayError(_("Bad Time-Control String"), 0);
361                 return;
362             }
363             searchTime = inc;
364         } else {
365             if(!ParseTimeControl(txt, inc, mps)) {
366                 XtSetArg(args[0], XtNstring, ""); // erase any offending input
367                 XtSetValues(tcTime, args, 1);
368                 DisplayError(_("Bad Time-Control String"), 0);
369                 return;
370             }
371             searchTime = 0;
372             appData.movesPerSession = mps;
373             appData.timeIncrement = inc;
374             appData.timeControl = strdup(txt);
375         }
376         XtSetArg(args[0], XtNstring, &txt);
377         XtGetValues(tcOdds1, args, 1);
378         appData.firstTimeOdds = first.timeOdds
379                 = (sscanf(txt, "%d", &j) == 1 && j > 0) ? j : 1;
380         XtGetValues(tcOdds2, args, 1);
381         appData.secondTimeOdds = second.timeOdds
382                 = (sscanf(txt, "%d", &j) == 1 && j > 0) ? j : 1;
383
384         Reset(True, True);
385         TimeControlPopDown();
386         return;
387     }
388 }
389
390 void TimeControlPopUp()
391 {
392     Arg args[16];
393     Widget popup, layout, form,  b_ok, b_cancel, b_clas, b_inc, mess;
394     Window root, child;
395     int x, y, i, j;
396     int win_x, win_y;
397     unsigned int mask;
398     char def[MSG_SIZ];
399
400     tcInc = searchTime > 0 ? 2 : (appData.timeIncrement >= 0);
401     tcMoves = appData.movesPerSession; tcIncrement = appData.timeIncrement;
402     if(!tcInc) tcIncrement = 0;
403     snprintf(def, MSG_SIZ,  "%d", tcInc ? tcIncrement : tcMoves);
404
405     i = 0;
406     XtSetArg(args[i], XtNresizable, True); i++;
407 //    XtSetArg(args[i], XtNwidth, DIALOG_SIZE); i++;
408     TimeControlShell = popup =
409       XtCreatePopupShell(_("TimeControl Menu"), transientShellWidgetClass,
410                          shellWidget, args, i);
411
412     layout =
413       XtCreateManagedWidget(layoutName, formWidgetClass, popup,
414                             layoutArgs, XtNumber(layoutArgs));
415
416     form =
417       XtCreateManagedWidget(layoutName, formWidgetClass, layout,
418                             formArgs, XtNumber(formArgs));
419
420     j = 0;
421 //    XtSetArg(args[j], XtNwidth,     (XtArgVal) 300); j++;
422 //    XtSetArg(args[j], XtNheight,    (XtArgVal) 85); j++;
423     XtSetValues(popup, args, j);
424
425     j= 0;
426     XtSetArg(args[j], XtNborderWidth, 1); j++;
427     XtSetArg(args[j], XtNeditType, XawtextEdit);  j++;
428     XtSetArg(args[j], XtNuseStringInPlace, False);  j++;
429     XtSetArg(args[j], XtNstring, appData.timeControl);  j++;
430     XtSetArg(args[j], XtNdisplayCaret, False);  j++;
431     XtSetArg(args[j], XtNtop, XtChainTop);  j++;
432     XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
433     XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
434     XtSetArg(args[j], XtNright, XtChainRight);  j++;
435     XtSetArg(args[j], XtNresizable, True);  j++;
436     XtSetArg(args[j], XtNwidth,  85);  j++;
437     XtSetArg(args[j], XtNinsertPosition, 9999);  j++;
438     tcTime = XtCreateManagedWidget("TC", asciiTextWidgetClass, form, args, j);
439     XtAddEventHandler(tcTime, ButtonPressMask, False, SetFocus, (XtPointer) popup);
440
441     j= 0;
442     XtSetArg(args[j], XtNlabel, tcInc ? tcInc == 2 ? _("sec/move (max)   ") : _("   minutes, plus   ") : _("minutes for each")); j++;
443     XtSetArg(args[j], XtNborderWidth, 0); j++;
444     XtSetArg(args[j], XtNfromHoriz, tcTime); j++;
445     XtSetArg(args[j], XtNtop, XtChainTop);  j++;
446     XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
447     XtSetArg(args[j], XtNleft, XtChainRight);  j++;
448     XtSetArg(args[j], XtNright, XtChainRight);  j++;
449   //  XtSetArg(args[j], XtNwidth,  100);  j++;
450   //  XtSetArg(args[j], XtNheight, 20);  j++;
451     tcMess1 = XtCreateManagedWidget("TCtext", labelWidgetClass, form, args, j);
452
453     j= 0;
454     XtSetArg(args[j], XtNborderWidth, 1); j++;
455     XtSetArg(args[j], XtNfromHoriz, tcMess1); j++;
456     XtSetArg(args[j], XtNeditType, XawtextEdit);  j++;
457     XtSetArg(args[j], XtNuseStringInPlace, False);  j++;
458     XtSetArg(args[j], XtNstring, def);  j++;
459     XtSetArg(args[j], XtNdisplayCaret, False);  j++;
460     XtSetArg(args[j], XtNtop, XtChainTop);  j++;
461     XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
462     XtSetArg(args[j], XtNleft, XtChainRight);  j++;
463     XtSetArg(args[j], XtNright, XtChainRight);  j++;
464     XtSetArg(args[j], XtNresizable, True);  j++;
465     XtSetArg(args[j], XtNwidth,  40);  j++;
466 //    XtSetArg(args[j], XtNheight, 20);  j++;
467     tcData = XtCreateManagedWidget("MPS", asciiTextWidgetClass, form, args, j);
468     XtAddEventHandler(tcData, ButtonPressMask, False, SetFocus, (XtPointer) popup);
469
470     j= 0;
471     XtSetArg(args[j], XtNlabel, tcInc ? tcInc == 2 ? _("             ") : _("sec/move") : _("moves     ")); j++;
472     XtSetArg(args[j], XtNjustify, XtJustifyLeft); j++;
473     XtSetArg(args[j], XtNborderWidth, 0); j++;
474     XtSetArg(args[j], XtNfromHoriz, tcData); j++;
475     XtSetArg(args[j], XtNtop, XtChainTop);  j++;
476     XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
477     XtSetArg(args[j], XtNleft, XtChainRight);  j++;
478     XtSetArg(args[j], XtNright, XtChainRight);  j++;
479 //    XtSetArg(args[j], XtNwidth,  80);  j++;
480 //    XtSetArg(args[j], XtNheight, 20);  j++;
481     tcMess2 = XtCreateManagedWidget("MPStext", labelWidgetClass,
482                                    form, args, j);
483
484     j= 0;
485     XtSetArg(args[j], XtNborderWidth, 1); j++;
486     XtSetArg(args[j], XtNfromVert, tcTime); j++;
487     XtSetArg(args[j], XtNeditType, XawtextEdit);  j++;
488     XtSetArg(args[j], XtNuseStringInPlace, False);  j++;
489     XtSetArg(args[j], XtNstring, "1");  j++;
490     XtSetArg(args[j], XtNdisplayCaret, False);  j++;
491     XtSetArg(args[j], XtNtop, XtChainTop);  j++;
492     XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
493     XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
494     XtSetArg(args[j], XtNright, XtChainLeft);  j++;
495     XtSetArg(args[j], XtNresizable, True);  j++;
496     XtSetArg(args[j], XtNwidth,  40);  j++;
497 //    XtSetArg(args[j], XtNheight, 20);  j++;
498     tcOdds1 = XtCreateManagedWidget("Odds1", asciiTextWidgetClass, form, args, j);
499     XtAddEventHandler(tcOdds1, ButtonPressMask, False, SetFocus, (XtPointer) popup);
500
501     j= 0;
502     XtSetArg(args[j], XtNborderWidth, 1); j++;
503     XtSetArg(args[j], XtNfromVert, tcTime); j++;
504     XtSetArg(args[j], XtNfromHoriz, tcOdds1); j++;
505     XtSetArg(args[j], XtNeditType, XawtextEdit);  j++;
506     XtSetArg(args[j], XtNuseStringInPlace, False);  j++;
507     XtSetArg(args[j], XtNstring, "1");  j++;
508     XtSetArg(args[j], XtNdisplayCaret, False);  j++;
509     XtSetArg(args[j], XtNtop, XtChainTop);  j++;
510     XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
511     XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
512     XtSetArg(args[j], XtNright, XtChainLeft);  j++;
513     XtSetArg(args[j], XtNresizable, True);  j++;
514     XtSetArg(args[j], XtNwidth,  40);  j++;
515 //    XtSetArg(args[j], XtNheight, 20);  j++;
516     tcOdds2 = XtCreateManagedWidget("Odds2", asciiTextWidgetClass, form, args, j);
517     XtAddEventHandler(tcOdds2, ButtonPressMask, False, SetFocus, (XtPointer) popup);
518
519     j= 0;
520     XtSetArg(args[j], XtNlabel, _("Engine #1 and #2 Time-Odds Factors")); j++;
521     XtSetArg(args[j], XtNjustify, XtJustifyLeft); j++;
522     XtSetArg(args[j], XtNborderWidth, 0); j++;
523     XtSetArg(args[j], XtNfromVert, tcTime); j++;
524     XtSetArg(args[j], XtNfromHoriz, tcOdds2); j++;
525     XtSetArg(args[j], XtNtop, XtChainTop);  j++;
526     XtSetArg(args[j], XtNbottom, XtChainTop);  j++;
527     XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
528     XtSetArg(args[j], XtNright, XtChainRight);  j++;
529 //    XtSetArg(args[j], XtNwidth,  200);  j++;
530 //    XtSetArg(args[j], XtNheight, 20);  j++;
531     mess = XtCreateManagedWidget("Oddstext", labelWidgetClass,
532                                    form, args, j);
533     j=0;
534     XtSetArg(args[j], XtNfromVert, tcOdds1);  j++;
535     XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
536     XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
537     XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
538     XtSetArg(args[j], XtNright, XtChainLeft);  j++;
539     XtSetArg(args[j], XtNstate, tcInc==0); j++;
540     b_clas= XtCreateManagedWidget(_("classical"), toggleWidgetClass,
541                                    form, args, j);
542     XtAddCallback(b_clas, XtNcallback, TimeControlCallback, (XtPointer) 0);
543
544     j=0;
545     XtSetArg(args[j], XtNradioGroup, b_clas); j++;
546     XtSetArg(args[j], XtNfromVert, tcOdds1);  j++;
547     XtSetArg(args[j], XtNfromHoriz, b_clas);  j++;
548     XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
549     XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
550     XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
551     XtSetArg(args[j], XtNright, XtChainLeft);  j++;
552     XtSetArg(args[j], XtNstate, tcInc==1); j++;
553     b_inc = XtCreateManagedWidget(_("incremental"), toggleWidgetClass,
554                                    form, args, j);
555     XtAddCallback(b_inc, XtNcallback, TimeControlCallback, (XtPointer) 0);
556
557     j=0;
558     XtSetArg(args[j], XtNradioGroup, b_inc); j++;
559     XtSetArg(args[j], XtNfromVert, tcOdds1);  j++;
560     XtSetArg(args[j], XtNfromHoriz, b_inc);  j++;
561     XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
562     XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
563     XtSetArg(args[j], XtNleft, XtChainLeft);  j++;
564     XtSetArg(args[j], XtNright, XtChainLeft);  j++;
565     XtSetArg(args[j], XtNstate, tcInc==2); j++;
566     b_inc = XtCreateManagedWidget(_("fixed time"), toggleWidgetClass,
567                                    form, args, j);
568     XtAddCallback(b_inc, XtNcallback, TimeControlCallback, (XtPointer) 0);
569
570     j=0;
571     XtSetArg(args[j], XtNfromVert, tcOdds1);  j++;
572     XtSetArg(args[j], XtNfromHoriz, tcData);  j++;
573     XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
574     XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
575     XtSetArg(args[j], XtNleft, XtChainRight);  j++;
576     XtSetArg(args[j], XtNright, XtChainRight);  j++;
577     b_ok= XtCreateManagedWidget(_(" OK "), commandWidgetClass,
578                                    form, args, j);
579     XtAddCallback(b_ok, XtNcallback, TimeControlCallback, (XtPointer) 0);
580
581     j=0;
582     XtSetArg(args[j], XtNfromVert, tcOdds1);  j++;
583     XtSetArg(args[j], XtNfromHoriz, b_ok);  j++;
584     XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
585     XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
586     XtSetArg(args[j], XtNleft, XtChainRight);  j++;
587     XtSetArg(args[j], XtNright, XtChainRight);  j++;
588     b_cancel= XtCreateManagedWidget(_("cancel"), commandWidgetClass,
589                                    form, args, j);
590     XtAddCallback(b_cancel, XtNcallback, TimeControlPopDown, (XtPointer) 0);
591
592     XtRealizeWidget(popup);
593     CatchDeleteWindow(popup, "TimeControlPopDown");
594
595     XQueryPointer(xDisplay, xBoardWindow, &root, &child,
596                   &x, &y, &win_x, &win_y, &mask);
597
598     XtSetArg(args[0], XtNx, x - 10);
599     XtSetArg(args[1], XtNy, y - 30);
600     XtSetValues(popup, args, 2);
601
602     XtPopup(popup, XtGrabExclusive);
603     TimeControlUp = True;
604
605     previous = NULL;
606     SetFocus(tcTime, popup, (XEvent*) NULL, False);
607 //    XtSetKeyboardFocus(popup, tcTime);
608 }
609
610 void TimeControlProc(w, event, prms, nprms)
611      Widget w;
612      XEvent *event;
613      String *prms;
614      Cardinal *nprms;
615 {
616    TimeControlPopUp();
617 }
618
619 //--------------------------- Engine-specific options menu ----------------------------------
620
621 int SettingsUp;
622 Widget SettingsShell;
623 int values[MAX_OPTIONS];
624 ChessProgramState *currentCps;
625
626 void SettingsPopDown()
627 {
628     if (!SettingsUp) return;
629     previous = NULL;
630     XtPopdown(SettingsShell);
631     XtDestroyWidget(SettingsShell);
632     SettingsUp = False;
633     ModeHighlight();
634 }
635
636 void SpinCallback(w, client_data, call_data)
637      Widget w;
638      XtPointer client_data, call_data;
639 {
640     String name, val;
641     Arg args[16];
642     char buf[MSG_SIZ], *p;
643     int j;
644     int data = (intptr_t) client_data;
645
646     XtSetArg(args[0], XtNlabel, &name);
647     XtGetValues(w, args, 1);
648
649     j = 0;
650     XtSetArg(args[0], XtNstring, &val);
651     XtGetValues(currentCps->option[data].handle, args, 1);
652     sscanf(val, "%d", &j);
653     if (strcmp(name, "browse") == 0) {
654         if(XsraSelFile(SettingsShell, currentCps->option[data].name, NULL, NULL, "", "", 
655                                   currentCps->option[data].type == PathName ? "p" : "f", NULL, &p)) {
656                 int len = strlen(p);
657                 if(len && p[len-1] == '/') p[len-1] = NULLCHAR;
658                 XtSetArg(args[0], XtNstring, p);
659                 XtSetValues(currentCps->option[data].handle, args, 1);
660         }
661         SetFocus(currentCps->option[data].handle, SettingsShell, (XEvent*) NULL, False);
662         return;
663     } else
664     if (strcmp(name, "+") == 0) {
665         if(++j > currentCps->option[data].max) return;
666     } else
667     if (strcmp(name, "-") == 0) {
668         if(--j < currentCps->option[data].min) return;
669     } else return;
670     snprintf(buf, MSG_SIZ,  "%d", j);
671     XtSetArg(args[0], XtNstring, buf);
672     XtSetValues(currentCps->option[data].handle, args, 1);
673 }
674
675 void SettingsCallback(w, client_data, call_data)
676      Widget w;
677      XtPointer client_data, call_data;
678 {
679     String name, val;
680     Arg args[16];
681     char buf[MSG_SIZ];
682     int i, j;
683     int data = (intptr_t) client_data;
684
685     XtSetArg(args[0], XtNlabel, &name);
686     XtGetValues(w, args, 1);
687
688     if (strcmp(name, _("cancel")) == 0) {
689         SettingsPopDown();
690         return;
691     }
692     if (strcmp(name, _("OK")) == 0 || data) { // save buttons imply OK
693         for(i=0; i<currentCps->nrOptions; i++) { // send all options that had to be OK-ed to engine
694             switch(currentCps->option[i].type) {
695                 case TextBox:
696                     XtSetArg(args[0], XtNstring, &val);
697                     XtGetValues(currentCps->option[i].handle, args, 1);
698                     if(strcmp(currentCps->option[i].textValue, val)) {
699                       safeStrCpy(currentCps->option[i].textValue, val, MSG_SIZ - (currentCps->option[i].textValue - currentCps->option[i].name) );
700                       snprintf(buf, MSG_SIZ,  "option %s=%s\n", currentCps->option[i].name, val);
701                       SendToProgram(buf, currentCps);
702                     }
703                     break;
704                 case Spin:
705                     XtSetArg(args[0], XtNstring, &val);
706                     XtGetValues(currentCps->option[i].handle, args, 1);
707                     sscanf(val, "%d", &j);
708                     if(j > currentCps->option[i].max) j = currentCps->option[i].max;
709                     if(j < currentCps->option[i].min) j = currentCps->option[i].min;
710                     if(currentCps->option[i].value != j) {
711                         currentCps->option[i].value = j;
712                         snprintf(buf, MSG_SIZ,  "option %s=%d\n", currentCps->option[i].name, j);
713                         SendToProgram(buf, currentCps);
714                     }
715                     break;
716                 case CheckBox:
717                     j = 0;
718                     XtSetArg(args[0], XtNstate, &j);
719                     XtGetValues(currentCps->option[i].handle, args, 1);
720                     if(currentCps->option[i].value != j) {
721                         currentCps->option[i].value = j;
722                         snprintf(buf, MSG_SIZ,  "option %s=%d\n", currentCps->option[i].name, j);
723                         SendToProgram(buf, currentCps);
724                     }
725                     break;
726                 case ComboBox:
727                     if(currentCps->option[i].value != values[i]) {
728                         currentCps->option[i].value = values[i];
729                         snprintf(buf, MSG_SIZ,  "option %s=%s\n", currentCps->option[i].name,
730                                 ((char**)currentCps->option[i].textValue)[values[i]]);
731                         SendToProgram(buf, currentCps);
732                     }
733                     break;
734             default:
735               if( appData.debugMode )
736                 fprintf(debugFP, "SettingsPopUp: unexpected case in switch.\n");
737               break;
738             }
739         }
740         if(data) { // send save-button command to engine
741           snprintf(buf, MSG_SIZ,  "option %s\n", name);
742           SendToProgram(buf, currentCps);
743         }
744         SettingsPopDown();
745         return;
746     }
747     snprintf(buf, MSG_SIZ,  "option %s\n", name);
748     SendToProgram(buf, currentCps);
749 }
750
751 void ComboSelect(w, addr, index) // callback for all combo items
752      Widget w;
753      caddr_t addr;
754      caddr_t index;
755 {
756     Arg args[16];
757     int i = ((intptr_t)addr)>>8;
758     int j = 255 & (intptr_t) addr;
759
760     values[i] = j; // store in temporary, for transfer at OK
761     XtSetArg(args[0], XtNlabel, ((char**)currentCps->option[i].textValue)[j]);
762     XtSetValues(currentCps->option[i].handle, args, 1);
763 }
764
765 void CreateComboPopup(parent, name, n, mb)
766      Widget parent;
767      String name;
768      int n;
769      char *mb[];
770 {
771     int i=0, j;
772     Widget menu, entry;
773     Arg args[16];
774
775     menu = XtCreatePopupShell(name, simpleMenuWidgetClass,
776                               parent, NULL, 0);
777     j = 0;
778     XtSetArg(args[j], XtNwidth, 100);  j++;
779 //    XtSetArg(args[j], XtNright, XtChainRight);  j++;
780     while (mb[i] != NULL) {
781             entry = XtCreateManagedWidget(mb[i], smeBSBObjectClass,
782                                           menu, args, j);
783             XtAddCallback(entry, XtNcallback,
784                           (XtCallbackProc) ComboSelect,
785                           (caddr_t)(intptr_t) (256*n+i));
786         i++;
787     }
788 }
789
790 void
791 SettingsPopUp(ChessProgramState *cps)
792 {
793     Arg args[16];
794     Widget popup, layout, dialog, edit=NULL, form,  last, b_ok, b_cancel, leftMargin = NULL, textField = NULL;
795     Window root, child;
796     int x, y, i, j, height, width, h, c;
797     int win_x, win_y, maxWidth, maxTextWidth;
798     unsigned int mask;
799     char def[MSG_SIZ];
800     static char pane[6] = "paneX";
801     Widget texts[100], forelast = NULL, anchor, widest;
802
803     // to do: start up second engine if needed
804     if(!cps->initDone || !cps->nrOptions) return; // nothing to be done
805     currentCps = cps;
806
807     if(cps->nrOptions > 50) width = 4; else if(cps->nrOptions>24) width = 2; else width = 1;
808     height = cps->nrOptions / width + 1;
809      i = 0;
810     XtSetArg(args[i], XtNresizable, True); i++;
811     SettingsShell = popup =
812       XtCreatePopupShell(_("Settings Menu"), transientShellWidgetClass,
813                          shellWidget, args, i);
814
815     layout =
816       XtCreateManagedWidget(layoutName, formWidgetClass, popup,
817                             layoutArgs, XtNumber(layoutArgs));
818   for(c=0; c<width; c++) {
819     pane[4] = 'A'+c;
820     form =
821       XtCreateManagedWidget(pane, formWidgetClass, layout,
822                             formArgs, XtNumber(formArgs));
823     j=0;
824     XtSetArg(args[j], XtNfromHoriz, leftMargin);  j++;
825     XtSetValues(form, args, j);
826     leftMargin = form;
827
828     last = widest = NULL; anchor = forelast;
829     for(h=0; h<height; h++) {
830         forelast = last;
831         i = h + c*height;
832         if(i >= cps->nrOptions) break;
833         switch(cps->option[i].type) {
834           case Spin:
835             snprintf(def, MSG_SIZ,  "%d", cps->option[i].value);
836           case TextBox:
837             j=0;
838             XtSetArg(args[j], XtNfromVert, last);  j++;
839             XtSetArg(args[j], XtNborderWidth, 0);  j++;
840             XtSetArg(args[j], XtNjustify, XtJustifyLeft);  j++;
841             texts[h] =
842             dialog = XtCreateManagedWidget(cps->option[i].name, labelWidgetClass, form, args, j);
843             j=0;
844             XtSetArg(args[j], XtNfromVert, last);  j++;
845             XtSetArg(args[j], XtNfromHoriz, dialog);  j++;
846             XtSetArg(args[j], XtNborderWidth, 1); j++;
847             XtSetArg(args[j], XtNwidth, cps->option[i].type == Spin ? 40 : 175); j++;
848             XtSetArg(args[j], XtNeditType, XawtextEdit);  j++;
849             XtSetArg(args[j], XtNuseStringInPlace, False);  j++;
850             XtSetArg(args[j], XtNdisplayCaret, False);  j++;
851             XtSetArg(args[j], XtNright, XtChainRight);  j++;
852             XtSetArg(args[j], XtNresizable, True);  j++;
853             XtSetArg(args[j], XtNstring, cps->option[i].type==Spin ? def : cps->option[i].textValue);  j++;
854             XtSetArg(args[j], XtNinsertPosition, 9999);  j++;
855             edit = last;
856             cps->option[i].handle = (void*)
857                 (textField = last = XtCreateManagedWidget("text", asciiTextWidgetClass, form, args, j));
858             XtAddEventHandler(last, ButtonPressMask, False, SetFocus, (XtPointer) popup);
859             if(cps->option[i].type == TextBox) break;
860
861             // add increment and decrement controls for spin
862             j=0;
863             XtSetArg(args[j], XtNfromVert, edit);  j++;
864             XtSetArg(args[j], XtNfromHoriz, last);  j++;
865             XtSetArg(args[j], XtNheight, 10);  j++;
866             XtSetArg(args[j], XtNwidth, 20);  j++;
867             edit = XtCreateManagedWidget("+", commandWidgetClass, form, args, j);
868             XtAddCallback(edit, XtNcallback, SpinCallback,
869                           (XtPointer)(intptr_t) i);
870
871             j=0;
872             XtSetArg(args[j], XtNfromVert, edit);  j++;
873             XtSetArg(args[j], XtNfromHoriz, last);  j++;
874             XtSetArg(args[j], XtNheight, 10);  j++;
875             XtSetArg(args[j], XtNwidth, 20);  j++;
876             last = XtCreateManagedWidget("-", commandWidgetClass, form, args, j);
877             XtAddCallback(last, XtNcallback, SpinCallback,
878                           (XtPointer)(intptr_t) i);
879             break;
880           case CheckBox:
881             j=0;
882             XtSetArg(args[j], XtNfromVert, last);  j++;
883             XtSetArg(args[j], XtNwidth, 10);  j++;
884             XtSetArg(args[j], XtNheight, 10);  j++;
885             XtSetArg(args[j], XtNstate, cps->option[i].value);  j++;
886             cps->option[i].handle = (void*)
887                 (dialog = XtCreateManagedWidget(" ", toggleWidgetClass, form, args, j));
888             j=0;
889             XtSetArg(args[j], XtNfromVert, last);  j++;
890             XtSetArg(args[j], XtNfromHoriz, dialog);  j++;
891             XtSetArg(args[j], XtNborderWidth, 0);  j++;
892             XtSetArg(args[j], XtNjustify, XtJustifyLeft);  j++;
893             last = XtCreateManagedWidget(cps->option[i].name, labelWidgetClass, form, args, j);
894             break;
895           case SaveButton:
896           case Button:
897             j=0;
898             XtSetArg(args[j], XtNfromVert, last);  j++;
899             XtSetArg(args[j], XtNstate, cps->option[i].value);  j++;
900             cps->option[i].handle = (void*)
901                 (dialog = last = XtCreateManagedWidget(cps->option[i].name, commandWidgetClass, form, args, j));
902             XtAddCallback(last, XtNcallback, SettingsCallback,
903                           (XtPointer)(intptr_t) (cps->option[i].type == SaveButton));
904             break;
905           case ComboBox:
906             j=0;
907             XtSetArg(args[j], XtNfromVert, last);  j++;
908             XtSetArg(args[j], XtNborderWidth, 0);  j++;
909             XtSetArg(args[j], XtNjustify, XtJustifyLeft);  j++;
910             dialog = XtCreateManagedWidget(cps->option[i].name, labelWidgetClass, form, args, j);
911
912             j=0;
913             XtSetArg(args[j], XtNfromVert, last);  j++;
914             XtSetArg(args[j], XtNfromHoriz, dialog);  j++;
915             XtSetArg(args[j], XtNwidth, 100);  j++;
916             XtSetArg(args[j], XtNmenuName, XtNewString(cps->option[i].name));  j++;
917             XtSetArg(args[j], XtNlabel, ((char**)cps->option[i].textValue)[cps->option[i].value]);  j++;
918             cps->option[i].handle = (void*)
919                 (last = XtCreateManagedWidget(" ", menuButtonWidgetClass, form, args, j));
920             CreateComboPopup(last, cps->option[i].name, i, (char **) cps->option[i].textValue);
921             values[i] = cps->option[i].value;
922             break;
923         default:
924           if( appData.debugMode )
925             fprintf(debugFP, "SettingsPopUp: unexpected case in switch.\n");
926           break;
927         }
928     }
929
930     // make an attempt to align all spins and textbox controls
931     maxWidth = maxTextWidth = 0;
932     for(h=0; h<height; h++) {
933         i = h + c*height;
934         if(i >= cps->nrOptions) break;
935         if(cps->option[i].type == Spin || cps->option[i].type == TextBox) {
936             Dimension w;
937             j=0;
938             XtSetArg(args[j], XtNwidth, &w);  j++;
939             XtGetValues(texts[h], args, j);
940             if(cps->option[i].type == Spin) {
941                 if(w > maxWidth) maxWidth = w;
942                 widest = texts[h];
943             } else {
944                 if(w > maxTextWidth) maxTextWidth = w;
945                 if(!widest) widest = texts[h];
946             }
947         }
948     }
949     if(maxTextWidth + 110 < maxWidth)
950          maxTextWidth = maxWidth - 110;
951     else maxWidth = maxTextWidth + 110;
952     for(h=0; h<height; h++) {
953         i = h + c*height;
954         if(i >= cps->nrOptions) break;
955         j=0;
956         if(cps->option[i].type == Spin) {
957             XtSetArg(args[j], XtNwidth, maxWidth);  j++;
958             XtSetValues(texts[h], args, j);
959         } else
960         if(cps->option[i].type == TextBox) {
961             XtSetArg(args[j], XtNwidth, maxTextWidth);  j++;
962             XtSetValues(texts[h], args, j);
963         }
964     }
965   }
966     j=0;
967     XtSetArg(args[j], XtNfromVert, anchor ? anchor : last);  j++;
968     XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
969     XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
970     XtSetArg(args[j], XtNleft, XtChainRight);  j++;
971     XtSetArg(args[j], XtNright, XtChainRight);  j++;
972     XtSetArg(args[j], XtNfromHoriz, widest ? widest : dialog);  j++;
973     b_ok = XtCreateManagedWidget(_("OK"), commandWidgetClass, form, args, j);
974     XtAddCallback(b_ok, XtNcallback, SettingsCallback, (XtPointer) 0);
975
976     XtSetArg(args[j-1], XtNfromHoriz, b_ok);
977     b_cancel = XtCreateManagedWidget(_("cancel"), commandWidgetClass, form, args, j);
978     XtAddCallback(b_cancel, XtNcallback, SettingsPopDown, (XtPointer) 0);
979
980     XtRealizeWidget(popup);
981     CatchDeleteWindow(popup, "SettingsPopDown");
982
983     XQueryPointer(xDisplay, xBoardWindow, &root, &child,
984                   &x, &y, &win_x, &win_y, &mask);
985
986     XtSetArg(args[0], XtNx, x - 10);
987     XtSetArg(args[1], XtNy, y - 30);
988     XtSetValues(popup, args, 2);
989
990     XtPopup(popup, XtGrabExclusive);
991     SettingsUp = True;
992
993     previous = NULL;
994     if(textField)SetFocus(textField, popup, (XEvent*) NULL, False);
995 }
996
997 void FirstSettingsProc(w, event, prms, nprms)
998      Widget w;
999      XEvent *event;
1000      String *prms;
1001      Cardinal *nprms;
1002 {
1003    SettingsPopUp(&first);
1004 }
1005
1006 void SecondSettingsProc(w, event, prms, nprms)
1007      Widget w;
1008      XEvent *event;
1009      String *prms;
1010      Cardinal *nprms;
1011 {
1012    if(WaitForSecond(SettingsMenuIfReady)) return;
1013    SettingsPopUp(&second);
1014 }
1015
1016 //----------------------------Generic dialog --------------------------------------------
1017
1018 // cloned from Engine Settings dialog
1019
1020 #define CURR -2000000000 /* indicates control should start at actual value of target */
1021
1022 typedef void ButtonCallback(int n);
1023
1024 char *trialSound;
1025 static Option *currentOption;
1026 static int oldCores, oldPonder;
1027 int MakeColors P((void));
1028 void CreateGCs P((int redo));
1029 void CreateXPMBoard P((char *s, int kind));
1030 void CreateXPMPieces P((void));
1031 void GenericReadout();
1032
1033 void GeneralOptionsOK(int n)
1034 {
1035         int newPonder = appData.ponderNextMove;
1036         appData.ponderNextMove = oldPonder;
1037         PonderNextMoveEvent(newPonder);
1038 }
1039
1040 Option generalOptions[] = {
1041 { 0,  0, 0, NULL, (void*) &appData.alwaysPromoteToQueen, "", NULL, CheckBox, _("Always Queen") },
1042 { 0,  0, 0, NULL, (void*) &appData.animateDragging, "", NULL, CheckBox, _("Animate Dragging") },
1043 { 0,  0, 0, NULL, (void*) &appData.animate, "", NULL, CheckBox, _("Animate Moving") },
1044 { 0,  0, 0, NULL, (void*) &appData.autoCallFlag, "", NULL, CheckBox, _("Auto Flag") },
1045 { 0,  0, 0, NULL, (void*) &appData.autoFlipView, "", NULL, CheckBox, _("Auto Flip View") },
1046 { 0,  0, 0, NULL, (void*) &appData.blindfold, "", NULL, CheckBox, _("Blindfold") },
1047 { 0,  0, 0, NULL, (void*) &appData.dropMenu, "", NULL, CheckBox, _("Drop Menu") },
1048 { 0,  0, 0, NULL, (void*) &appData.highlightDragging, "", NULL, CheckBox, _("Highlight Dragging (Show Move Targets)") },
1049 { 0,  0, 0, NULL, (void*) &appData.highlightLastMove, "", NULL, CheckBox, _("Highlight Last Move") },
1050 { 0,  0, 0, NULL, (void*) &appData.highlightMoveWithArrow, "", NULL, CheckBox, _("Highlight with Arrow") },
1051 { 0,  0, 0, NULL, (void*) &appData.ringBellAfterMoves, "", NULL, CheckBox, _("Move Sound") },
1052 { 0,  0, 0, NULL, (void*) &appData.oneClick, "", NULL, CheckBox, _("One-Click Moving") },
1053 { 0,  0, 0, NULL, (void*) &appData.periodicUpdates, "", NULL, CheckBox, _("Periodic Updates (in Analysis Mode)") },
1054 { 0,  0, 0, NULL, (void*) &appData.ponderNextMove, "", NULL, CheckBox, _("Ponder Next Move") },
1055 { 0,  0, 0, NULL, (void*) &appData.popupExitMessage, "", NULL, CheckBox, _("Popup Exit Messages") },
1056 { 0,  0, 0, NULL, (void*) &appData.popupMoveErrors, "", NULL, CheckBox, _("Popup Move Errors") },
1057 { 0,  0, 0, NULL, (void*) &appData.showCoords, "", NULL, CheckBox, _("Show Coordinates") },
1058 { 0,  0, 0, NULL, (void*) &appData.markers, "", NULL, CheckBox, _("Show Target Squares") },
1059 { 0,  0, 0, NULL, (void*) &appData.hideThinkingFromHuman, "", NULL, CheckBox, _("Hide Thinking from Human") },
1060 { 0,  0, 0, NULL, (void*) &appData.testLegality, "", NULL, CheckBox, _("Test Legality") },
1061 { 0, 0, 10, NULL, (void*) &appData.flashCount, "", NULL, Spin, _("Flash Moves (0 = no flashing):") },
1062 { 0, 1, 10, NULL, (void*) &appData.flashRate, "", NULL, Spin, _("Flash Rate (high = fast):") },
1063 { 0, 5, 100,NULL, (void*) &appData.animSpeed, "", NULL, Spin, _("Animation Speed (high = slow):") },
1064 { 0,  0, 0, NULL, (void*) &GeneralOptionsOK, "", NULL, EndMark , "" }
1065 };
1066
1067 void Pick(int n)
1068 {
1069         VariantClass v = currentOption[n].value;
1070         if(!appData.noChessProgram) {
1071             char *name = VariantName(v), buf[MSG_SIZ];
1072             if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) {
1073                 /* [HGM] in protocol 2 we check if variant is suported by engine */
1074               snprintf(buf, MSG_SIZ,  _("Variant %s not supported by %s"), name, first.tidy);
1075                 DisplayError(buf, 0);
1076                 return; /* ignore OK if first engine does not support it */
1077             } else
1078             if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) {
1079               snprintf(buf, MSG_SIZ,  _("Warning: second engine (%s) does not support this!"), second.tidy);
1080                 DisplayError(buf, 0);   /* use of second engine is optional; only warn user */
1081             }
1082         }
1083
1084         GenericReadout(); // make sure ranks and file settings are read
1085
1086         gameInfo.variant = v;
1087         appData.variant = VariantName(v);
1088
1089         shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */
1090         startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */
1091         appData.pieceToCharTable = NULL;
1092         appData.pieceNickNames = "";
1093         appData.colorNickNames = "";
1094         Reset(True, True);
1095         SettingsPopDown();
1096         return;
1097 }
1098
1099 Option variantDescriptors[] = {
1100 { VariantNormal, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("normal")},
1101 { VariantFairy, 1, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("fairy")},
1102 { VariantFischeRandom, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("FRC")},
1103 { VariantSChess, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Seirawan")},
1104 { VariantWildCastle, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("wild castle")},
1105 { VariantSuper, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Superchess")},
1106 { VariantNoCastle, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("no castle")},
1107 { VariantCrazyhouse, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("crazyhouse")},
1108 { VariantKnightmate, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("knightmate")},
1109 { VariantBughouse, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("bughouse")},
1110 { VariantBerolina, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("berolina")},
1111 { VariantShogi, 1, 135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("shogi (9x9)")},
1112 { VariantCylinder, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("cylinder")},
1113 { VariantXiangqi, 1, 135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("xiangqi (9x10)")},
1114 { VariantShatranj, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("shatranj")},
1115 { VariantCourier, 1, 135, NULL, (void*) &Pick, "#BFFFBF", NULL, Button, N_("courier (12x8)")},
1116 { VariantMakruk, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("makruk")},
1117 { VariantGreat, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Great Shatranj (10x8)")},
1118 { VariantAtomic, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("atomic")},
1119 { VariantCapablanca, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Capablanca (10x8)")},
1120 { VariantTwoKings, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("two kings")},
1121 { VariantGothic, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Gothic (10x8)")},
1122 { Variant3Check, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("3-checks")},
1123 { VariantJanus, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("janus (10x8)")},
1124 { VariantSuicide, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("suicide")},
1125 { VariantCapaRandom, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("CRC (10x8)")},
1126 { VariantGiveaway, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("give-away")},
1127 { VariantSpartan, 1, 135, NULL, (void*) &Pick, "#FF0000", NULL, Button, N_("Spartan")},
1128 { VariantLosers, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("losers")},
1129 { 0, 0, 0, NULL, NULL, NULL, NULL, Label, _("Board size ( -1 = default for selected variant):")},
1130 { 0, -1, BOARD_RANKS-1, NULL, (void*) &appData.NrRanks, "", NULL, Spin, N_("Number of Board Ranks:") },
1131 { 0, -1, BOARD_FILES, NULL, (void*) &appData.NrFiles, "", NULL, Spin, N_("Number of Board Files:") },
1132 { 0, -1, BOARD_RANKS-1, NULL, (void*) &appData.holdingsSize, "", NULL, Spin, N_("Holdings Size:") },
1133 { 0, 0, 0, NULL, NULL, NULL, NULL, Label,
1134                                 _("WARNING: variants with un-orthodox\n"
1135                                   "pieces only have built-in bitmaps\n"
1136                                   "for -boardSize middling, bulky and\n"
1137                                   "petite, and substitute king or amazon\n"
1138                                   "for missing bitmaps. (See manual.)")},
1139 { 0, 2, 0, NULL, NULL, "", NULL, EndMark , "" }
1140 };
1141
1142 void CommonOptionsOK(int n)
1143 {
1144         int newPonder = appData.ponderNextMove;
1145         // make sure changes are sent to first engine by re-initializing it
1146         // if it was already started pre-emptively at end of previous game
1147         if(gameMode == BeginningOfGame) Reset(True, True); else {
1148             // Some changed setting need immediate sending always.
1149             if(oldCores != appData.smpCores)
1150                 NewSettingEvent(False, &(first.maxCores), "cores", appData.smpCores);
1151             appData.ponderNextMove = oldPonder;
1152             PonderNextMoveEvent(newPonder);
1153         }
1154 }
1155
1156 Option commonEngineOptions[] = {
1157 { 0,     0, 0, NULL, (void*) &appData.ponderNextMove, "", NULL, CheckBox, _("Ponder Next Move") },
1158 { 0,  0, 1000, NULL, (void*) &appData.smpCores, "", NULL, Spin, _("Maximum Number of CPUs per Engine:") },
1159 { 0,     0, 0, NULL, (void*) &appData.polyglotDir, "", NULL, PathName, _("Polygot Directory:") },
1160 { 0, 0, 16000, NULL, (void*) &appData.defaultHashSize, "", NULL, Spin, _("Hash-Table Size (MB):") },
1161 { 0,     0, 0, NULL, (void*) &appData.defaultPathEGTB, "", NULL, PathName, _("Nalimov EGTB Path:") },
1162 { 0,  0, 1000, NULL, (void*) &appData.defaultCacheSizeEGTB, "", NULL, Spin, _("EGTB Cache Size (MB):") },
1163 { 0,     0, 0, NULL, (void*) &appData.usePolyglotBook, "", NULL, CheckBox, _("Use GUI Book") },
1164 { 0,     0, 0, NULL, (void*) &appData.polyglotBook, "", NULL, FileName, _("Opening-Book Filename:") },
1165 { 0,   0, 100, NULL, (void*) &appData.bookDepth, "", NULL, Spin, _("Book Depth (moves):") },
1166 { 0,   0, 100, NULL, (void*) &appData.bookStrength, "", NULL, Spin, _("Book Variety (0) vs. Strength (100):") },
1167 { 0,     0, 0, NULL, (void*) &appData.firstHasOwnBookUCI, "", NULL, CheckBox, _("Engine #1 Has Own Book") },
1168 { 0,     0, 0, NULL, (void*) &appData.secondHasOwnBookUCI, "", NULL, CheckBox, _("Engine #2 Has Own Book          ") },
1169 { 0,     1, 0, NULL, (void*) &CommonOptionsOK, "", NULL, EndMark , "" }
1170 };
1171
1172 Option adjudicationOptions[] = {
1173 { 0, 0,    0, NULL, (void*) &appData.checkMates, "", NULL, CheckBox, _("Detect all Mates") },
1174 { 0, 0,    0, NULL, (void*) &appData.testClaims, "", NULL, CheckBox, _("Verify Engine Result Claims") },
1175 { 0, 0,    0, NULL, (void*) &appData.materialDraws, "", NULL, CheckBox, _("Draw if Insufficient Mating Material") },
1176 { 0, 0,    0, NULL, (void*) &appData.trivialDraws, "", NULL, CheckBox, _("Adjudicate Trivial Draws (3-Move Delay)") },
1177 { 0, 0,  100, NULL, (void*) &appData.ruleMoves, "", NULL, Spin, _("N-Move Rule:") },
1178 { 0, 0,    6, NULL, (void*) &appData.drawRepeats, "", NULL, Spin, _("N-fold Repeats:") },
1179 { 0, 0, 1000, NULL, (void*) &appData.adjudicateDrawMoves, "", NULL, Spin, _("Draw after N Moves Total:") },
1180 { 0,-5000, 0, NULL, (void*) &appData.adjudicateLossThreshold, "", NULL, Spin, _("Win / Loss Threshold:") },
1181 { 0, 0,    0, NULL, (void*) &first.scoreIsAbsolute, "", NULL, CheckBox, _("Negate Score of Engine #1") },
1182 { 0, 0,    0, NULL, (void*) &second.scoreIsAbsolute, "", NULL, CheckBox, _("Negate Score of Engine #2") },
1183 { 0, 1,    0, NULL, NULL, "", NULL, EndMark , "" }
1184 };
1185
1186 void IcsOptionsOK(int n)
1187 {
1188     ParseIcsTextColors();
1189 }
1190
1191 Option icsOptions[] = {
1192 { 0, 0, 0, NULL, (void*) &appData.autoKibitz, "",  NULL, CheckBox, _("Auto-Kibitz") },
1193 { 0, 0, 0, NULL, (void*) &appData.autoComment, "", NULL, CheckBox, _("Auto-Comment") },
1194 { 0, 0, 0, NULL, (void*) &appData.autoObserve, "", NULL, CheckBox, _("Auto-Observe") },
1195 { 0, 0, 0, NULL, (void*) &appData.autoRaiseBoard, "", NULL, CheckBox, _("Auto-Raise Board") },
1196 { 0, 0, 0, NULL, (void*) &appData.bgObserve, "",   NULL, CheckBox, _("Background Observe while Playing") },
1197 { 0, 0, 0, NULL, (void*) &appData.dualBoard, "",   NULL, CheckBox, _("Dual Board for Background-Observed Game") },
1198 { 0, 0, 0, NULL, (void*) &appData.getMoveList, "", NULL, CheckBox, _("Get Move List") },
1199 { 0, 0, 0, NULL, (void*) &appData.quietPlay, "",   NULL, CheckBox, _("Quiet Play") },
1200 { 0, 0, 0, NULL, (void*) &appData.seekGraph, "",   NULL, CheckBox, _("Seek Graph") },
1201 { 0, 0, 0, NULL, (void*) &appData.autoRefresh, "", NULL, CheckBox, _("Auto-Refresh Seek Graph") },
1202 { 0, 0, 0, NULL, (void*) &appData.premove, "",     NULL, CheckBox, _("Premove") },
1203 { 0, 0, 0, NULL, (void*) &appData.premoveWhite, "", NULL, CheckBox, _("Premove for White") },
1204 { 0, 0, 0, NULL, (void*) &appData.premoveWhiteText, "", NULL, TextBox, _("First White Move:") },
1205 { 0, 0, 0, NULL, (void*) &appData.premoveBlack, "", NULL, CheckBox, _("Premove for Black") },
1206 { 0, 0, 0, NULL, (void*) &appData.premoveBlackText, "", NULL, TextBox, _("First Black Move:") },
1207 { 0, 0, 0, NULL, NULL, NULL, NULL, Break, "" },
1208 { 0, 0, 0, NULL, (void*) &appData.icsAlarm, "", NULL, CheckBox, _("Alarm") },
1209 { 0, 0, 100000000, NULL, (void*) &appData.icsAlarmTime, "", NULL, Spin, _("Alarm Time (msec):") },
1210 //{ 0, 0, 0, NULL, (void*) &appData.chatBoxes, "", NULL, TextBox, _("Startup Chat Boxes:") },
1211 { 0, 0, 0, NULL, (void*) &appData.colorize, "", NULL, CheckBox, _("Colorize Messages") },
1212 { 0, 0, 0, NULL, (void*) &appData.colorShout, "", NULL, TextBox, _("Shout Text Colors:") },
1213 { 0, 0, 0, NULL, (void*) &appData.colorSShout, "", NULL, TextBox, _("S-Shout Text Colors:") },
1214 { 0, 0, 0, NULL, (void*) &appData.colorChannel1, "", NULL, TextBox, _("Channel #1 Text Colors:") },
1215 { 0, 0, 0, NULL, (void*) &appData.colorChannel, "", NULL, TextBox, _("Other Channel Text Colors:") },
1216 { 0, 0, 0, NULL, (void*) &appData.colorKibitz, "", NULL, TextBox, _("Kibitz Text Colors:") },
1217 { 0, 0, 0, NULL, (void*) &appData.colorTell, "", NULL, TextBox, _("Tell Text Colors:") },
1218 { 0, 0, 0, NULL, (void*) &appData.colorChallenge, "", NULL, TextBox, _("Challenge Text Colors:") },
1219 { 0, 0, 0, NULL, (void*) &appData.colorRequest, "", NULL, TextBox, _("Request Text Colors:") },
1220 { 0, 0, 0, NULL, (void*) &appData.colorSeek, "", NULL, TextBox, _("Seek Text Colors:") },
1221 { 0, 0, 0, NULL, (void*) &IcsOptionsOK, "", NULL, EndMark , "" }
1222 };
1223
1224 Option loadOptions[] = {
1225 { 0, 0, 0, NULL, (void*) &appData.autoDisplayTags, "", NULL, CheckBox, _("Auto-Display Tags") },
1226 { 0, 0, 0, NULL, (void*) &appData.autoDisplayComment, "", NULL, CheckBox, _("Auto-Display Comment") },
1227 { 0, 0, 0, NULL, NULL, NULL, NULL, Label, _("Auto-Play speed of loaded games\n(0 = instant, -1 = off):") },
1228 { 0, -1, 10000000, NULL, (void*) &appData.timeDelay, "", NULL, Fractional, _("Seconds per Move:") },
1229 { 0,  0, 0, NULL, NULL, "", NULL, EndMark , "" }
1230 };
1231
1232 Option saveOptions[] = {
1233 { 0, 0, 0, NULL, (void*) &appData.autoSaveGames, "", NULL, CheckBox, _("Auto-Save Games") },
1234 { 0, 0, 0, NULL, (void*) &appData.saveGameFile, "", NULL, FileName,  _("Save Games on File:") },
1235 { 0, 0, 0, NULL, (void*) &appData.savePositionFile, "", NULL, FileName,  _("Save Final Positions on File:") },
1236 { 0, 0, 0, NULL, (void*) &appData.pgnEventHeader, "", NULL, TextBox,  _("PGN Event Header:") },
1237 { 0, 0, 0, NULL, (void*) &appData.oldSaveStyle, "", NULL, CheckBox, _("Old Save Style (as opposed to PGN)") },
1238 { 0, 0, 0, NULL, (void*) &appData.saveExtendedInfoInPGN, "", NULL, CheckBox, _("Save Score/Depth Info in PGN") },
1239 { 0, 0, 0, NULL, (void*) &appData.saveOutOfBookInfo, "", NULL, CheckBox, _("Save Out-of-Book Info in PGN           ") },
1240 { 0, 1, 0, NULL, NULL, "", NULL, EndMark , "" }
1241 };
1242
1243 char *soundNames[] = {
1244         N_("No Sound"),
1245         N_("Default Beep"),
1246         N_("Above WAV File"),
1247         N_("Ching"),
1248         N_("Click"),
1249         N_("Ding"),
1250         N_("Gong"),
1251         N_("Laser"),
1252         N_("Penalty"),
1253         N_("Phone"),
1254         N_("Thud"),
1255         N_("Challenge"),
1256         N_("Tell"),
1257         NULL,
1258         N_("User File")
1259 };
1260
1261 char *soundFiles[] = { // sound files corresponding to above names
1262         "",
1263         "$",
1264         "*", // kludge alert: as first thing in the dialog readout this is replaced with the user-given .WAV filename
1265         "ching.wav",
1266         "click.wav",
1267         "ding1.wav",
1268         "gong.wav",
1269         "laser.wav",
1270         "penalty.wav",
1271         "phone.wav",
1272         "thud.wav",
1273         "challenge.wav",
1274         "tell.wav",
1275         NULL,
1276         NULL
1277 };
1278
1279 void Test(int n)
1280 {
1281     if(soundFiles[values[3]]) PlaySound(soundFiles[values[3]]);
1282 }
1283
1284 Option soundOptions[] = {
1285 { 0, 0, 0, NULL, (void*) &appData.soundProgram, "", NULL, TextBox, _("Sound Program:") },
1286 { 0, 0, 0, NULL, (void*) &appData.soundDirectory, "", NULL, PathName, _("Sounds Directory:") },
1287 { 0, 0, 0, NULL, (void*) (soundFiles+2) /* kludge! */, "", NULL, FileName, _("User WAV File:") },
1288 { 0, 0, 0, NULL, (void*) &trialSound, (char*) soundNames, soundFiles, ComboBox, _("Try-Out Sound:") },
1289 { 0, 1, 0, NULL, (void*) &Test, NULL, NULL, Button, _("Play") },
1290 { 0, 0, 0, NULL, (void*) &appData.soundMove, (char*) soundNames, soundFiles, ComboBox, _("Move:") },
1291 { 0, 0, 0, NULL, (void*) &appData.soundIcsWin, (char*) soundNames, soundFiles, ComboBox, _("Win:") },
1292 { 0, 0, 0, NULL, (void*) &appData.soundIcsLoss, (char*) soundNames, soundFiles, ComboBox, _("Lose:") },
1293 { 0, 0, 0, NULL, (void*) &appData.soundIcsDraw, (char*) soundNames, soundFiles, ComboBox, _("Draw:") },
1294 { 0, 0, 0, NULL, (void*) &appData.soundIcsUnfinished, (char*) soundNames, soundFiles, ComboBox, _("Unfinished:") },
1295 { 0, 0, 0, NULL, (void*) &appData.soundIcsAlarm, (char*) soundNames, soundFiles, ComboBox, _("Alarm:") },
1296 { 0, 0, 0, NULL, (void*) &appData.soundShout, (char*) soundNames, soundFiles, ComboBox, _("Shout:") },
1297 { 0, 0, 0, NULL, (void*) &appData.soundSShout, (char*) soundNames, soundFiles, ComboBox, _("S-Shout:") },
1298 { 0, 0, 0, NULL, (void*) &appData.soundChannel, (char*) soundNames, soundFiles, ComboBox, _("Channel:") },
1299 { 0, 0, 0, NULL, (void*) &appData.soundChannel1, (char*) soundNames, soundFiles, ComboBox, _("Channel 1:") },
1300 { 0, 0, 0, NULL, (void*) &appData.soundTell, (char*) soundNames, soundFiles, ComboBox, _("Tell:") },
1301 { 0, 0, 0, NULL, (void*) &appData.soundKibitz, (char*) soundNames, soundFiles, ComboBox, _("Kibitz:") },
1302 { 0, 0, 0, NULL, (void*) &appData.soundChallenge, (char*) soundNames, soundFiles, ComboBox, _("Challenge:") },
1303 { 0, 0, 0, NULL, (void*) &appData.soundRequest, (char*) soundNames, soundFiles, ComboBox, _("Request:") },
1304 { 0, 0, 0, NULL, (void*) &appData.soundSeek, (char*) soundNames, soundFiles, ComboBox, _("Seek:") },
1305 { 0, 1, 0, NULL, NULL, "", NULL, EndMark , "" }
1306 };
1307
1308 void SetColor(char *colorName, Widget box)
1309 {
1310         Arg args[5];
1311         Pixel buttonColor;
1312         XrmValue vFrom, vTo;
1313         if (!appData.monoMode) {
1314             vFrom.addr = (caddr_t) colorName;
1315             vFrom.size = strlen(colorName);
1316             XtConvert(shellWidget, XtRString, &vFrom, XtRPixel, &vTo);
1317             if (vTo.addr == NULL) {
1318                 buttonColor = (Pixel) -1;
1319             } else {
1320                 buttonColor = *(Pixel *) vTo.addr;
1321             }
1322         }
1323         XtSetArg(args[0], XtNbackground, buttonColor);;
1324         XtSetValues(box, args, 1);
1325 }
1326
1327 void AdjustColor(int i)
1328 {
1329     int n = currentOption[i].value, col, j, r, g, b, step = 10;
1330     char *s, buf[MSG_SIZ]; // color string
1331     Arg args[5];
1332     XtSetArg(args[0], XtNstring, &s);
1333     XtGetValues(currentOption[i-n-1].handle, args, 1);
1334     if(sscanf(s, "#%x", &col) != 1) return;   // malformed
1335     b = col & 0xFF; g = col & 0xFF00; r = col & 0xFF0000;
1336     switch(n) {
1337         case 1: g -= 0x100*step; b -= step; break;
1338         case 2: r -= 0x10000*step; b -= step; break;
1339         case 3: g -= 0x100*step; r -= 0x10000*step; break;
1340         case 4: r += 0x10000*step; g += 0x100*step; b += step; break;
1341     }
1342     if(r < 0) r = 0; if(g < 0) g = 0; if(b < 0) b = 0;
1343     if(r > 0xFF0000) r = 0xFF0000; if(g > 0xFF00) g = 0xFF00; if(b > 0xFF) b = 0xFF;
1344     col = r | g | b;
1345     snprintf(buf, MSG_SIZ, "#%06x", col);
1346     for(j=1; j<7; j++) if(buf[j] >= 'a') buf[j] -= 32; // capitalize
1347     SetColor(buf, currentOption[i-n].handle);
1348     XtSetArg(args[0], XtNstring, buf);
1349     XtSetValues(currentOption[i-n-1].handle, args, 1);
1350 }
1351
1352 void BoardOptionsOK(int n)
1353 {
1354     if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap;
1355     MakeColors(); CreateGCs(True);
1356     CreateXPMPieces();
1357     CreateXPMBoard(appData.liteBackTextureFile, 1);
1358     CreateXPMBoard(appData.darkBackTextureFile, 0);
1359     InitDrawingSizes(-1, 0);
1360     DrawPosition(True, NULL);
1361 }
1362
1363 Option boardOptions[] = {
1364 { 0,   0, 70, NULL, (void*) &appData.whitePieceColor, "", NULL, TextBox, _("White Piece Color:") },
1365 { 1000, 1, 0, NULL, NULL, NULL, NULL, Button, "      " },
1366 {    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "R" },
1367 {    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "G" },
1368 {    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "B" },
1369 {    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "W" },
1370 { 0,   0, 70, NULL, (void*) &appData.blackPieceColor, "", NULL, TextBox, _("Black Piece Color:") },
1371 { 1000, 1, 0, NULL, NULL, NULL, NULL, Button, "      " },
1372 {    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "R" },
1373 {    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "G" },
1374 {    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "B" },
1375 {    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "W" },
1376 { 0,   0, 70, NULL, (void*) &appData.lightSquareColor, "", NULL, TextBox, _("Light Square Color:") },
1377 { 1000, 1, 0, NULL, NULL, NULL, NULL, Button, "      " },
1378 {    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "R" },
1379 {    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "G" },
1380 {    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "B" },
1381 {    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "W" },
1382 { 0,   0, 70, NULL, (void*) &appData.darkSquareColor, "", NULL, TextBox, _("Dark Square Color:") },
1383 { 1000, 1, 0, NULL, NULL, NULL, NULL, Button, "      " },
1384 {    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "R" },
1385 {    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "G" },
1386 {    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "B" },
1387 {    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "W" },
1388 { 0,   0, 70, NULL, (void*) &appData.highlightSquareColor, "", NULL, TextBox, _("Highlight Color:") },
1389 { 1000, 1, 0, NULL, NULL, NULL, NULL, Button, "      " },
1390 {    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "R" },
1391 {    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "G" },
1392 {    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "B" },
1393 {    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "W" },
1394 { 0,   0, 70, NULL, (void*) &appData.premoveHighlightColor, "", NULL, TextBox, _("Premove Highlight Color:") },
1395 { 1000, 1, 0, NULL, NULL, NULL, NULL, Button, "      " },
1396 {    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "R" },
1397 {    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "G" },
1398 {    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "B" },
1399 {    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, "W" },
1400 { 0, 0, 0, NULL, (void*) &appData.upsideDown, "", NULL, CheckBox, _("Flip Pieces Shogi Style") },
1401 { 0, 0, 0, NULL, (void*) &appData.allWhite, "", NULL, CheckBox, _("Use Outline Pieces for Black") },
1402 { 0, 0, 0, NULL, (void*) &appData.monoMode, "", NULL, CheckBox, _("Mono Mode") },
1403 { 0,-1, 5, NULL, (void*) &appData.overrideLineGap, "", NULL, Spin, _("Line Gap ( -1 = default for board size):") },
1404 { 0, 0, 0, NULL, (void*) &appData.liteBackTextureFile, "", NULL, FileName, _("Light-Squares Texture File:") },
1405 { 0, 0, 0, NULL, (void*) &appData.darkBackTextureFile, "", NULL, FileName, _("Dark-Squares Texture File:") },
1406 { 0, 0, 0, NULL, (void*) &appData.bitmapDirectory, "", NULL, PathName, _("Directory with Bitmap Pieces:") },
1407 { 0, 0, 0, NULL, (void*) &appData.pixmapDirectory, "", NULL, PathName, _("Directory with Pixmap Pieces:") },
1408 { 0, 0, 0, NULL, (void*) &BoardOptionsOK, "", NULL, EndMark , "" }
1409 };
1410
1411 void GenericReadout()
1412 {
1413     int i, j;
1414     String name, val;
1415     Arg args[16];
1416     char buf[MSG_SIZ];
1417     float x;
1418         for(i=0; ; i++) { // send all options that had to be OK-ed to engine
1419             switch(currentOption[i].type) {
1420                 case TextBox:
1421                 case FileName:
1422                 case PathName:
1423                     XtSetArg(args[0], XtNstring, &val);
1424                     XtGetValues(currentOption[i].handle, args, 1);
1425                     if(*(char**) currentOption[i].target == NULL || strcmp(*(char**) currentOption[i].target, val)) {
1426                         safeStrCpy(currentOption[i].name + 100, val, MSG_SIZ-100); // text value kept in pivate storage for each option
1427                         *(char**) currentOption[i].target = currentOption[i].name + 100; // option gets to point to that
1428                     }
1429                     break;
1430                 case Spin:
1431                 case Fractional:
1432                     XtSetArg(args[0], XtNstring, &val);
1433                     XtGetValues(currentOption[i].handle, args, 1);
1434                     sscanf(val, "%f", &x);
1435                     if(x > currentOption[i].max) x = currentOption[i].max;
1436                     if(x < currentOption[i].min) x = currentOption[i].min;
1437                     if(currentOption[i].value != x) {
1438                         currentOption[i].value = x;
1439                         if(currentOption[i].type == Spin) *(int*) currentOption[i].target = x;
1440                         else *(float*) currentOption[i].target = x;
1441                     }
1442                     break;
1443                 case CheckBox:
1444                     j = 0;
1445                     XtSetArg(args[0], XtNstate, &j);
1446                     XtGetValues(currentOption[i].handle, args, 1);
1447                     if(currentOption[i].value != j) {
1448                         currentOption[i].value = j;
1449                         *(Boolean*) currentOption[i].target = j;
1450                     }
1451                     break;
1452                 case ComboBox:
1453                     val = ((char**)currentOption[i].choice)[values[i]];
1454                     if(val && (*(char**) currentOption[i].target == NULL || strcmp(*(char**) currentOption[i].target, val))) {
1455                       if(*(char**) currentOption[i].target) free(*(char**) currentOption[i].target);
1456                       *(char**) currentOption[i].target = strdup(val);
1457                     }
1458                     break;
1459                 case EndMark:
1460                     if(currentOption[i].target) // callback for implementing necessary actions on OK (like redraw)
1461                         ((ButtonCallback*) currentOption[i].target)(i);
1462                     break;
1463             default:
1464                 printf("GenericReadout: unexpected case in switch.\n");
1465                 case Button:
1466                 case Label:
1467               break;
1468             }
1469             if(currentOption[i].type == EndMark) break;
1470         }
1471 }
1472
1473 void GenericCallback(w, client_data, call_data)
1474      Widget w;
1475      XtPointer client_data, call_data;
1476 {
1477     String name, val;
1478     Arg args[16];
1479     char buf[MSG_SIZ];
1480     int i, j;
1481     int data = (intptr_t) client_data;
1482
1483     XtSetArg(args[0], XtNlabel, &name);
1484     XtGetValues(w, args, 1);
1485
1486     if (strcmp(name, _("cancel")) == 0) {
1487         SettingsPopDown();
1488         return;
1489     }
1490     if (strcmp(name, _("OK")) == 0) { // save buttons imply OK
1491         GenericReadout();
1492         SettingsPopDown();
1493         return;
1494     }
1495     if(currentOption[data].textValue);
1496     ((ButtonCallback*) currentOption[data].target)(data);
1497 }
1498
1499 void
1500 GenericPopUp(Option *option, char *title)
1501 {
1502     Arg args[16];
1503     Widget popup, layout, dialog, edit=NULL, form,  last, b_ok, b_cancel, leftMargin = NULL, textField = NULL;
1504     Window root, child;
1505     int x, y, i, j, height=999, width=1, h, c, w;
1506     int win_x, win_y, maxWidth, maxTextWidth;
1507     unsigned int mask;
1508     char def[MSG_SIZ], *msg;
1509     static char pane[6] = "paneX";
1510     Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL;
1511
1512     currentOption = option; // make available to callback
1513     // kludge: fake address of a ChessProgramState struct that contains the options, so Spin and Combo callbacks work on it
1514     currentCps = (ChessProgramState *) ((char *) option - ((char *)&first.option - (char *)&first));
1515
1516 //    if(cps->nrOptions > 50) width = 4; else if(cps->nrOptions>24) width = 2; else width = 1;
1517 //    height = cps->nrOptions / width + 1;
1518      i = 0;
1519     XtSetArg(args[i], XtNresizable, True); i++;
1520     SettingsShell = popup =
1521       XtCreatePopupShell(title, transientShellWidgetClass,
1522                          shellWidget, args, i);
1523
1524     layout =
1525       XtCreateManagedWidget(layoutName, formWidgetClass, popup,
1526                             layoutArgs, XtNumber(layoutArgs));
1527   for(c=0; c<width; c++) {
1528     pane[4] = 'A'+c;
1529     form =
1530       XtCreateManagedWidget(pane, formWidgetClass, layout,
1531                             formArgs, XtNumber(formArgs));
1532     j=0;
1533     XtSetArg(args[j], XtNfromHoriz, leftMargin);  j++;
1534     XtSetValues(form, args, j);
1535     leftMargin = form;
1536
1537     last = widest = NULL; anchor = lastrow;
1538     for(h=0; h<height; h++) {
1539         i = h + c*height;
1540         if(option[i].type == EndMark) break;
1541         lastrow = forelast;
1542         forelast = last;
1543         switch(option[i].type) {
1544           case Fractional:
1545             snprintf(def, MSG_SIZ,  "%.2f", *(float*)option[i].target);
1546             option[i].value = *(float*)option[i].target;
1547             goto tBox;
1548           case Spin:
1549             snprintf(def, MSG_SIZ,  "%d", option[i].value = *(int*)option[i].target);
1550           case TextBox:
1551           case FileName:
1552           case PathName:
1553           tBox:
1554             if(option[i].name[0]) {
1555             j=0;
1556             XtSetArg(args[j], XtNfromVert, last);  j++;
1557             XtSetArg(args[j], XtNleft, XtChainLeft); j++;
1558             XtSetArg(args[j], XtNright, XtChainLeft); j++;
1559             XtSetArg(args[j], XtNborderWidth, 0);  j++;
1560             XtSetArg(args[j], XtNjustify, XtJustifyLeft);  j++;
1561             texts[h] =
1562             dialog = XtCreateManagedWidget(option[i].name, labelWidgetClass, form, args, j);
1563             } else texts[h] = dialog = NULL;
1564             w = option[i].type == Spin || option[i].type == Fractional ? 70 : option[i].max ? option[i].max : 205;
1565             if(option[i].type == FileName || option[i].type == PathName) w -= 55;
1566             j=0;
1567             XtSetArg(args[j], XtNfromVert, last);  j++;
1568             XtSetArg(args[j], XtNfromHoriz, dialog);  j++;
1569             XtSetArg(args[j], XtNborderWidth, 1); j++;
1570             XtSetArg(args[j], XtNwidth, w); j++;
1571             if(option[i].type == TextBox && option[i].min) XtSetArg(args[j], XtNheight, option[i].min); j++;
1572             XtSetArg(args[j], XtNleft, XtChainLeft); j++;
1573             XtSetArg(args[j], XtNeditType, XawtextEdit);  j++;
1574             XtSetArg(args[j], XtNuseStringInPlace, False);  j++;
1575             XtSetArg(args[j], XtNdisplayCaret, False);  j++;
1576             XtSetArg(args[j], XtNright, XtChainRight);  j++;
1577             XtSetArg(args[j], XtNresizable, True);  j++;
1578             XtSetArg(args[j], XtNstring, option[i].type==Spin || option[i].type==Fractional ? def : *(char**)option[i].target);  j++;
1579             XtSetArg(args[j], XtNinsertPosition, 9999);  j++;
1580             edit = last;
1581             option[i].handle = (void*)
1582                 (textField = last = XtCreateManagedWidget("text", asciiTextWidgetClass, form, args, j));
1583             XtAddEventHandler(last, ButtonPressMask, False, SetFocus, (XtPointer) popup);
1584
1585             if(option[i].type == TextBox || option[i].type == Fractional) break;
1586
1587             // add increment and decrement controls for spin
1588             j=0;
1589             XtSetArg(args[j], XtNfromVert, edit);  j++;
1590             XtSetArg(args[j], XtNfromHoriz, last);  j++;
1591             XtSetArg(args[j], XtNleft, XtChainRight); j++;
1592             XtSetArg(args[j], XtNright, XtChainRight); j++;
1593             if(option[i].type == FileName || option[i].type == PathName) {
1594                 w = 50; msg = "browse";
1595             } else {
1596                 XtSetArg(args[j], XtNheight, 10);  j++;
1597                 w = 20; msg = "+";
1598             }
1599             XtSetArg(args[j], XtNwidth, w);  j++;
1600             edit = XtCreateManagedWidget(msg, commandWidgetClass, form, args, j);
1601             XtAddCallback(edit, XtNcallback, SpinCallback,
1602                           (XtPointer)(intptr_t) i);
1603
1604             if(option[i].type != Spin) break;
1605
1606             j=0;
1607             XtSetArg(args[j], XtNfromVert, edit);  j++;
1608             XtSetArg(args[j], XtNfromHoriz, last);  j++;
1609             XtSetArg(args[j], XtNheight, 10);  j++;
1610             XtSetArg(args[j], XtNwidth, 20);  j++;
1611             XtSetArg(args[j], XtNleft, XtChainRight); j++;
1612             XtSetArg(args[j], XtNright, XtChainRight); j++;
1613             last = XtCreateManagedWidget("-", commandWidgetClass, form, args, j);
1614             XtAddCallback(last, XtNcallback, SpinCallback,
1615                           (XtPointer)(intptr_t) i);
1616             break;
1617           case CheckBox:
1618             j=0;
1619             XtSetArg(args[j], XtNfromVert, last);  j++;
1620             XtSetArg(args[j], XtNwidth, 10);  j++;
1621             XtSetArg(args[j], XtNheight, 10);  j++;
1622             XtSetArg(args[j], XtNleft, XtChainLeft); j++;
1623             XtSetArg(args[j], XtNright, XtChainLeft); j++;
1624             XtSetArg(args[j], XtNstate, option[i].value = *(Boolean*)option[i].target);  j++;
1625             option[i].handle = (void*)
1626                 (dialog = XtCreateManagedWidget(" ", toggleWidgetClass, form, args, j));
1627           case Label:
1628             msg = option[i].name;
1629             if(*msg == NULLCHAR) msg = option[i].textValue;
1630             if(!msg) break;
1631             j=0;
1632             XtSetArg(args[j], XtNfromVert, last);  j++;
1633             XtSetArg(args[j], XtNfromHoriz, option[i].type != Label ? dialog : NULL);  j++;
1634             XtSetArg(args[j], XtNleft, XtChainLeft); j++;
1635             XtSetArg(args[j], XtNborderWidth, 0);  j++;
1636             XtSetArg(args[j], XtNjustify, XtJustifyLeft);  j++;
1637             last = XtCreateManagedWidget(msg, labelWidgetClass, form, args, j);
1638             break;
1639           case Button:
1640             j=0;
1641             XtSetArg(args[j], XtNfromVert, option[i].min & 1 ? lastrow : last);  j++;
1642             if(option[i].min & 1) { XtSetArg(args[j], XtNfromHoriz, last);  j++; }
1643             else  { XtSetArg(args[j], XtNfromHoriz, NULL);  j++; lastrow = forelast; }
1644             if(option[i].max) XtSetArg(args[j], XtNwidth, option[i].max);  j++;
1645             if(option[i].textValue) { // special for buttons of New Variant dialog
1646                 XtSetArg(args[j], XtNsensitive, appData.noChessProgram || option[i].value < 0
1647                                          || strstr(first.variants, VariantName(option[i].value))); j++;
1648                 XtSetArg(args[j], XtNborderWidth, (gameInfo.variant == option[i].value)+1); j++;
1649             }
1650             option[i].handle = (void*)
1651                 (dialog = last = XtCreateManagedWidget(option[i].name, commandWidgetClass, form, args, j));
1652             if(option[i].target == NULL) SetColor( *(char**) option[i-1].target, last); else
1653             XtAddCallback(last, XtNcallback, GenericCallback,
1654                           (XtPointer)(intptr_t) i);
1655             if(option[i].textValue) SetColor( option[i].textValue, last);
1656             forelast = lastrow; // next button can go on same row
1657             break;
1658           case ComboBox:
1659             j=0;
1660             XtSetArg(args[j], XtNfromVert, last);  j++;
1661             XtSetArg(args[j], XtNleft, XtChainLeft); j++;
1662             XtSetArg(args[j], XtNright, XtChainLeft); j++;
1663             XtSetArg(args[j], XtNborderWidth, 0);  j++;
1664             XtSetArg(args[j], XtNjustify, XtJustifyLeft);  j++;
1665             texts[h] = dialog = XtCreateManagedWidget(option[i].name, labelWidgetClass, form, args, j);
1666
1667             for(j=0; option[i].choice[j]; j++)
1668                 if(*(char**)option[i].target && !strcmp(*(char**)option[i].target, option[i].choice[j])) break;
1669             option[i].value = j + (option[i].choice[j] == NULL);
1670
1671             j=0;
1672             XtSetArg(args[j], XtNfromVert, last);  j++;
1673             XtSetArg(args[j], XtNfromHoriz, dialog);  j++;
1674             XtSetArg(args[j], XtNwidth, option[i].max ? option[i].max : 100);  j++;
1675             XtSetArg(args[j], XtNleft, XtChainLeft); j++;
1676             XtSetArg(args[j], XtNmenuName, XtNewString(option[i].name));  j++;
1677             XtSetArg(args[j], XtNlabel, ((char**)option[i].textValue)[option[i].value]);  j++;
1678             option[i].handle = (void*)
1679                 (last = XtCreateManagedWidget(" ", menuButtonWidgetClass, form, args, j));
1680             CreateComboPopup(last, option[i].name, i, (char **) option[i].textValue);
1681             values[i] = option[i].value;
1682             break;
1683           case Break:
1684             width++;
1685             height = i+1;
1686             break;
1687         default:
1688             printf("GenericPopUp: unexpected case in switch.\n");
1689             break;
1690         }
1691     }
1692
1693     // make an attempt to align all spins and textbox controls
1694     maxWidth = maxTextWidth = 0;
1695     for(h=0; h<height; h++) {
1696         i = h + c*height;
1697         if(option[i].type == EndMark) break;
1698         if(option[i].type == Spin || option[i].type == TextBox || option[i].type == ComboBox
1699                                   || option[i].type == PathName || option[i].type == FileName) {
1700             Dimension w;
1701             if(!texts[h]) continue;
1702             j=0;
1703             XtSetArg(args[j], XtNwidth, &w);  j++;
1704             XtGetValues(texts[h], args, j);
1705             if(option[i].type == Spin) {
1706                 if(w > maxWidth) maxWidth = w;
1707                 widest = texts[h];
1708             } else {
1709                 if(w > maxTextWidth) maxTextWidth = w;
1710                 if(!widest) widest = texts[h];
1711             }
1712         }
1713     }
1714     if(maxTextWidth + 110 < maxWidth)
1715          maxTextWidth = maxWidth - 110;
1716     else maxWidth = maxTextWidth + 110;
1717     for(h=0; h<height; h++) {
1718         i = h + c*height;
1719         if(option[i].type == EndMark) break;
1720         if(!texts[h]) continue;
1721         j=0;
1722         if(option[i].type == Spin) {
1723             XtSetArg(args[j], XtNwidth, maxWidth);  j++;
1724             XtSetValues(texts[h], args, j);
1725         } else
1726         if(option[i].type == TextBox || option[i].type == ComboBox || option[i].type == PathName || option[i].type == FileName) {
1727             XtSetArg(args[j], XtNwidth, maxTextWidth);  j++;
1728             XtSetValues(texts[h], args, j);
1729         }
1730     }
1731   }
1732
1733   if(!(option[i].min & 2)) {
1734     j=0;
1735     if(option[i].min & 1) { XtSetArg(args[j], XtNfromHoriz, last); last = forelast; } else
1736     XtSetArg(args[j], XtNfromHoriz, widest ? widest : dialog);  j++;
1737     XtSetArg(args[j], XtNfromVert, anchor ? anchor : last);  j++;
1738     XtSetArg(args[j], XtNbottom, XtChainBottom);  j++;
1739     XtSetArg(args[j], XtNtop, XtChainBottom);  j++;
1740     XtSetArg(args[j], XtNleft, XtChainRight);  j++;
1741     XtSetArg(args[j], XtNright, XtChainRight);  j++;
1742     b_ok = XtCreateManagedWidget(_("OK"), commandWidgetClass, form, args, j);
1743     XtAddCallback(b_ok, XtNcallback, GenericCallback, (XtPointer) 0);
1744
1745     XtSetArg(args[0], XtNfromHoriz, b_ok);
1746     b_cancel = XtCreateManagedWidget(_("cancel"), commandWidgetClass, form, args, j);
1747     XtAddCallback(b_cancel, XtNcallback, SettingsPopDown, (XtPointer) 0);
1748   }
1749
1750     XtRealizeWidget(popup);
1751     CatchDeleteWindow(popup, "SettingsPopDown");
1752
1753     XQueryPointer(xDisplay, xBoardWindow, &root, &child,
1754                   &x, &y, &win_x, &win_y, &mask);
1755
1756     XtSetArg(args[0], XtNx, x - 10);
1757     XtSetArg(args[1], XtNy, y - 30);
1758     XtSetValues(popup, args, 2);
1759
1760     XtPopup(popup, XtGrabExclusive);
1761     SettingsUp = True;
1762
1763     previous = NULL;
1764     if(textField)SetFocus(textField, popup, (XEvent*) NULL, False);
1765 }
1766
1767
1768 void IcsOptionsProc(w, event, prms, nprms)
1769      Widget w;
1770      XEvent *event;
1771      String *prms;
1772      Cardinal *nprms;
1773 {
1774    GenericPopUp(icsOptions, _("ICS Options"));
1775 }
1776
1777 void LoadOptionsProc(w, event, prms, nprms)
1778      Widget w;
1779      XEvent *event;
1780      String *prms;
1781      Cardinal *nprms;
1782 {
1783    GenericPopUp(loadOptions, _("Load Game Options"));
1784 }
1785
1786 void SaveOptionsProc(w, event, prms, nprms)
1787      Widget w;
1788      XEvent *event;
1789      String *prms;
1790      Cardinal *nprms;
1791 {
1792    GenericPopUp(saveOptions, _("Save Game Options"));
1793 }
1794
1795 void SoundOptionsProc(w, event, prms, nprms)
1796      Widget w;
1797      XEvent *event;
1798      String *prms;
1799      Cardinal *nprms;
1800 {
1801    soundFiles[2] = "*";
1802    GenericPopUp(soundOptions, _("Sound Options"));
1803 }
1804
1805 void BoardOptionsProc(w, event, prms, nprms)
1806      Widget w;
1807      XEvent *event;
1808      String *prms;
1809      Cardinal *nprms;
1810 {
1811    GenericPopUp(boardOptions, _("Board Options"));
1812 }
1813
1814 void EngineMenuProc(w, event, prms, nprms)
1815      Widget w;
1816      XEvent *event;
1817      String *prms;
1818      Cardinal *nprms;
1819 {
1820    GenericPopUp(adjudicationOptions, "Adjudicate non-ICS Games");
1821 }
1822
1823 void UciMenuProc(w, event, prms, nprms)
1824      Widget w;
1825      XEvent *event;
1826      String *prms;
1827      Cardinal *nprms;
1828 {
1829    oldCores = appData.smpCores;
1830    oldPonder = appData.ponderNextMove;
1831    GenericPopUp(commonEngineOptions, _("Common Engine Settings"));
1832 }
1833
1834 void NewVariantProc(w, event, prms, nprms)
1835      Widget w;
1836      XEvent *event;
1837      String *prms;
1838      Cardinal *nprms;
1839 {
1840    GenericPopUp(variantDescriptors, _("New Variant"));
1841 }
1842
1843 void OptionsProc(w, event, prms, nprms)
1844      Widget w;
1845      XEvent *event;
1846      String *prms;
1847      Cardinal *nprms;
1848 {
1849    oldPonder = appData.ponderNextMove;
1850    GenericPopUp(generalOptions, _("General Options"));
1851 }
1852
1853 //---------------------------- Chat Windows ----------------------------------------------
1854
1855 void OutputChatMessage(int partner, char *mess)
1856 {
1857     return; // dummy
1858 }
1859