Fix multi-leg promotions
[xboard.git] / xaw / xgamelist.c
1 /*
2  * xgamelist.c -- Game list window, part of X front end for XBoard
3  *
4  * Copyright 1995, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 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 #include "config.h"
24
25 #include <stdio.h>
26 #include <ctype.h>
27 #include <errno.h>
28 #include <sys/types.h>
29
30 #if STDC_HEADERS
31 # include <stdlib.h>
32 # include <string.h>
33 #else /* not STDC_HEADERS */
34 extern char *getenv();
35 # if HAVE_STRING_H
36 #  include <string.h>
37 # else /* not HAVE_STRING_H */
38 #  include <strings.h>
39 # endif /* not HAVE_STRING_H */
40 #endif /* not STDC_HEADERS */
41
42 #if HAVE_UNISTD_H
43 # include <unistd.h>
44 #endif
45
46 #include <X11/Intrinsic.h>
47 #include <X11/StringDefs.h>
48 #include <X11/Shell.h>
49 #include <X11/cursorfont.h>
50 #if USE_XAW3D
51 #include <X11/Xaw3d/Dialog.h>
52 #include <X11/Xaw3d/Form.h>
53 #include <X11/Xaw3d/List.h>
54 #include <X11/Xaw3d/Label.h>
55 #include <X11/Xaw3d/SimpleMenu.h>
56 #include <X11/Xaw3d/SmeBSB.h>
57 #include <X11/Xaw3d/SmeLine.h>
58 #include <X11/Xaw3d/Box.h>
59 #include <X11/Xaw3d/MenuButton.h>
60 #include <X11/Xaw3d/Text.h>
61 #include <X11/Xaw3d/AsciiText.h>
62 #include <X11/Xaw3d/Viewport.h>
63 #else
64 #include <X11/Xaw/Dialog.h>
65 #include <X11/Xaw/Form.h>
66 #include <X11/Xaw/List.h>
67 #include <X11/Xaw/Label.h>
68 #include <X11/Xaw/SimpleMenu.h>
69 #include <X11/Xaw/SmeBSB.h>
70 #include <X11/Xaw/SmeLine.h>
71 #include <X11/Xaw/Box.h>
72 #include <X11/Xaw/MenuButton.h>
73 #include <X11/Xaw/Text.h>
74 #include <X11/Xaw/AsciiText.h>
75 #include <X11/Xaw/Viewport.h>
76 #endif
77
78 #include "common.h"
79 #include "backend.h"
80 #include "xboard.h"
81 #include "xgamelist.h"
82 #include "dialogs.h"
83
84
85 char gameListTranslations[] =
86   "<Btn4Down>: WheelProc(-3) \n \
87    <Btn5Down>: WheelProc(3) \n \
88    <Btn1Down>: LoadSelectedProc(100) Set() \n \
89    <Btn1Up>(2): LoadSelectedProc(0) \n \
90    <Key>Home: LoadSelectedProc(-2) \n \
91    <Key>End: LoadSelectedProc(2) \n \
92    Ctrl<Key>Up: LoadSelectedProc(-3) \n \
93    Ctrl<Key>Down: LoadSelectedProc(3) \n \
94    <Key>Up: LoadSelectedProc(-1) \n \
95    <Key>Down: LoadSelectedProc(1) \n \
96    <Key>Left: LoadSelectedProc(-1) \n \
97    <Key>Right: LoadSelectedProc(1) \n \
98    <Key>Prior: LoadSelectedProc(-4) \n \
99    <Key>Next: LoadSelectedProc(4) \n \
100    <Key>Return: LoadSelectedProc(0) \n";
101 char filterTranslations[] =
102   "<Key>Return: SetFilterProc() \n";
103
104
105 void
106 LoadSelectedProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
107 {
108     if(GameListClicks(atoi(prms[0]))) return; // if no game loaded, no focus transfer
109     XSync(xDisplay, False);
110     XSetInputFocus(xDisplay, XtWindow(boardWidget), RevertToPointerRoot, CurrentTime);
111 }
112
113 void
114 SetFilterProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
115 {
116     SetFilter();
117 }