2 * xhistory.c -- Move list window, part of X front end for XBoard
4 * Copyright 2000,2009 Free Software Foundation, Inc.
5 * ------------------------------------------------------------------------
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.
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.
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/. *
20 *------------------------------------------------------------------------
21 ** See the file ChangeLog for a revision history. */
29 #include <sys/types.h>
34 #else /* not STDC_HEADERS */
35 extern char *getenv();
38 # else /* not HAVE_STRING_H */
40 # endif /* not HAVE_STRING_H */
41 #endif /* not STDC_HEADERS */
47 #include <X11/Intrinsic.h>
48 #include <X11/StringDefs.h>
49 #include <X11/Shell.h>
50 #include <X11/Xaw/Dialog.h>
51 #include <X11/Xaw/Form.h>
52 #include <X11/Xaw/List.h>
53 #include <X11/Xaw/Label.h>
54 #include <X11/Xaw/SimpleMenu.h>
55 #include <X11/Xaw/SmeBSB.h>
56 #include <X11/Xaw/SmeLine.h>
57 #include <X11/Xaw/Box.h>
58 #include <X11/Xaw/Paned.h>
59 #include <X11/Xaw/MenuButton.h>
60 #include <X11/cursorfont.h>
61 #include <X11/Xaw/Text.h>
62 #include <X11/Xaw/AsciiText.h>
63 #include <X11/Xaw/Viewport.h>
74 # define _(s) gettext (s)
75 # define N_(s) gettext_noop (s)
83 extern Widget formWidget, shellWidget, boardWidget, menuBarWidget;
84 extern Display *xDisplay;
85 extern int squareSize;
86 extern Pixmap xMarkPixmap;
87 extern char *layoutName;
89 extern GtkWidget *GUI_History;
90 extern GtkListStore *LIST_MoveHistory;
94 String *Nr,*white,*black;
95 int aNr; /* space actually alocated */
96 Widget mvn,mvw,mvb,vbox,viewport,sh;
100 struct History *hist=0;
102 Position gameHistoryX, gameHistoryY;
105 HistoryPopDown(object, user_data)
109 gtk_widget_hide (GUI_History);
113 void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)
116 XawListReturnStruct *R = (XawListReturnStruct *) call_data;
117 if (w == hist->mvn || w == hist->mvw) {
118 to=2*R->list_index-1;
121 else if (w == hist->mvb) {
128 void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
131 char movewhite[2*MOVE_LEN],moveblack[2*MOVE_LEN],move[2*MOVE_LEN];
134 /* first clear everything, do we need this? */
135 gtk_list_store_clear(LIST_MoveHistory);
137 /* copy move list into history window */
139 /* go through all moves */
142 /* test if there is a move */
145 /* only copy everything before a ' ' */
146 char* p = strchr(movelist[i], ' ');
149 strncpy(move, movelist[i], p-movelist[i]);
150 move[p-movelist[i]] = NULLCHAR;
154 strcpy(move,movelist[i]);
163 strcpy(movewhite,move);
168 strcpy(moveblack,move);
171 gtk_list_store_append (LIST_MoveHistory, &iter);
172 gtk_list_store_set (LIST_MoveHistory, &iter,
178 strcpy(movewhite,"");
179 strcpy(moveblack,"");
182 /* check if ther is a white move left */
186 strcpy(moveblack,"");
188 gtk_list_store_append (LIST_MoveHistory, &iter);
189 gtk_list_store_set (LIST_MoveHistory, &iter,
200 // XawListUnhighlight(hist->mvw);
201 // XawListUnhighlight(hist->mvb);
203 else if((current%2)==0){
204 // XawListHighlight(hist->mvw, current/2+1);
205 // XawListUnhighlight(hist->mvb);
208 // XawListUnhighlight(hist->mvw);
209 // if(current) XawListHighlight(hist->mvb, current/2+1);
210 // else XawListUnhighlight(hist->mvb);
219 "<Key>Up: BackwardProc() \n \
220 <Key>Left: BackwardProc() \n \
221 <Key>Down: ForwardProc() \n \
222 <Key>Right: ForwardProc() \n";
230 // if(!hist) HistoryCreate();
232 gtk_widget_show (GUI_History);
239 HistoryShowProc(object, user_data)
250 HistoryPopDown(NULL,NULL);
256 ToNrEvent(currentMove);