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 */
55 # define _(s) gettext (s)
56 # define N_(s) gettext_noop (s)
62 extern GtkWidget *GUI_History;
63 extern GtkListStore *LIST_MoveHistory;
66 Position gameHistoryX, gameHistoryY;
67 Dimension gameHistoryW;
70 HistoryPopDown(object, user_data)
74 gtk_widget_hide (GUI_History);
78 void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)
82 XawListReturnStruct *R = (XawListReturnStruct *) call_data;
83 if (w == hist->mvn || w == hist->mvw) {
87 else if (w == hist->mvb) {
95 void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
98 char movewhite[2*MOVE_LEN],moveblack[2*MOVE_LEN],move[2*MOVE_LEN];
101 /* TODO need to add highlights for current move */
102 /* TODO need to add navigation by keyboard or mouse (double click on move) */
104 /* first clear everything, do we need this? */
105 gtk_list_store_clear(LIST_MoveHistory);
107 /* copy move list into history window */
109 /* go through all moves */
112 /* test if there is a move */
115 /* only copy everything before a ' ' */
116 char* p = strchr(movelist[i], ' ');
119 strncpy(move, movelist[i], p-movelist[i]);
120 move[p-movelist[i]] = NULLCHAR;
124 strcpy(move,movelist[i]);
133 strcpy(movewhite,move);
138 strcpy(moveblack,move);
141 gtk_list_store_append (LIST_MoveHistory, &iter);
142 gtk_list_store_set (LIST_MoveHistory, &iter,
148 strcpy(movewhite,"");
149 strcpy(moveblack,"");
152 /* check if ther is a white move left */
156 strcpy(moveblack,"");
158 gtk_list_store_append (LIST_MoveHistory, &iter);
159 gtk_list_store_set (LIST_MoveHistory, &iter,
172 "<Key>Up: BackwardProc() \n \
173 <Key>Left: BackwardProc() \n \
174 <Key>Down: ForwardProc() \n \
175 <Key>Right: ForwardProc() \n";
178 /*-------- create the widgets ---------------*/
180 // XtSetArg(args[j], XtNresizable, True); j++;
181 // XtSetArg(args[j], XtNallowShellResize, True); j++;
184 // XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass,
185 // shellWidget, args, j);
188 // XtCreatePopupShell(_("Move list"), transientShellWidgetClass,
189 // shellWidget, args, j);
192 // XtSetArg(args[j], XtNborderWidth, 0); j++;
193 // XtSetArg(args[j], XtNdefaultDistance, 0); j++;
195 // XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh,
199 // XtSetArg(args[j], XtNborderWidth, 0); j++;
200 // XtSetArg(args[j], XtNresizable, True); j++;
203 // XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
208 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
209 // XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
210 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
211 // XtSetArg(args[j], XtNright, XtChainRight); j++;
213 // XtSetArg(args[j], XtNborderWidth, 1); j++;
214 // XtSetArg(args[j], XtNresizable, False); j++;
215 // XtSetArg(args[j], XtNallowVert, True); j++;
216 // XtSetArg(args[j], XtNallowHoriz, True); j++;
217 // XtSetArg(args[j], XtNforceBars, False); j++;
218 // XtSetArg(args[j], XtNheight, 280); j++;
220 // XtCreateManagedWidget("viewport", viewportWidgetClass,
223 // XtSetArg(args[j], XtNborderWidth, 0); j++;
224 // XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++;
226 // XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j);
229 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
230 // XtSetArg(args[j], XtNbottom, XtChainTop); j++;
231 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
232 // XtSetArg(args[j], XtNright, XtChainLeft); j++;
234 // XtSetArg(args[j], XtNdefaultColumns, 1); j++;
235 // XtSetArg(args[j], XtNforceColumns, True); j++;
236 // XtSetArg(args[j], XtNverticalList, True); j++;
237 // XtSetArg(args[j], XtNborderWidth, 0); j++;
238 // XtSetArg(args[j], XtNresizable,True);j++;
239 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
240 // hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass,
241 // hist->vbox, args, j);
242 // XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist);
245 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
246 // XtSetArg(args[j], XtNbottom, XtChainTop); j++;
247 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
248 // XtSetArg(args[j], XtNright, XtRubber); j++;
250 // XtSetArg(args[j], XtNdefaultColumns, 1); j++;
251 // XtSetArg(args[j], XtNforceColumns, True); j++;
252 // XtSetArg(args[j], XtNverticalList, True); j++;
253 // XtSetArg(args[j], XtNborderWidth, 0); j++;
254 // XtSetArg(args[j], XtNresizable,True);j++;
255 // XtSetArg(args[j], XtNfromHoriz, hist->mvn); j++;
256 // hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass,
257 // hist->vbox, args, j);
258 // XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist);
261 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
262 // XtSetArg(args[j], XtNbottom, XtChainTop); j++;
263 // XtSetArg(args[j], XtNleft, XtRubber); j++;
264 // XtSetArg(args[j], XtNright, XtRubber); j++;
266 // XtSetArg(args[j], XtNdefaultColumns, 1); j++;
267 // XtSetArg(args[j], XtNforceColumns, True); j++;
268 // XtSetArg(args[j], XtNverticalList, True); j++;
269 // XtSetArg(args[j], XtNborderWidth, 0); j++;
270 // XtSetArg(args[j], XtNresizable,True);j++;
271 // XtSetArg(args[j], XtNfromHoriz, hist->mvw); j++;
272 // hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass,
273 // hist->vbox, args, j);
274 // XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist);
277 // XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
278 // XtSetArg(args[j], XtNtop, XtChainBottom); j++;
279 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
280 // XtSetArg(args[j], XtNright, XtChainLeft); j++;
281 // XtSetArg(args[j], XtNfromVert, hist->viewport); j++;
282 // b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass,
284 // XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0);
286 // XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr));
288 // XtRealizeWidget(hist->sh);
289 // CatchDeleteWindow(hist->sh, "HistoryPopDown");
291 // for(i=1;i<hist->aNr;i++){
292 // strcpy(hist->white[i],dots);
293 // strcpy(hist->black[i],"");
296 // // [HGM] restore old position
298 // XtSetArg(args[j], XtNx, &gameHistoryX); j++;
299 // XtSetArg(args[j], XtNy, &gameHistoryY); j++;
300 // XtSetArg(args[j], XtNwidth, &gameHistoryW); j++;
301 // XtGetValues(shellWidget, args, j);
303 // XtSetArg(args[j], XtNx, gameHistoryX + gameHistoryW); j++;
304 // XtSetArg(args[j], XtNy, gameHistoryY); j++;
305 // XtSetValues(hist->sh, args, j);
306 // XtRealizeWidget(hist->sh);
314 // if(!hist) HistoryCreate();
316 gtk_widget_show (GUI_History);
323 HistoryShowProc(object, user_data)
329 //TODO: ToNrEvent(currentMove);