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, gameHistoryH;
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,"");
153 /* check if ther is a white move left */
157 strcpy(moveblack,"");
159 gtk_list_store_append (LIST_MoveHistory, &iter);
160 gtk_list_store_set (LIST_MoveHistory, &iter,
168 // EvalGraphSet( first, last, current, pvInfoList ); // piggy-backed
176 "<Key>Up: BackwardProc() \n \
177 <Key>Left: BackwardProc() \n \
178 <Key>Down: ForwardProc() \n \
179 <Key>Right: ForwardProc() \n";
182 /*-------- create the widgets ---------------*/
185 // XtSetArg(args[j], XtNresizable, True); j++;
186 // XtSetArg(args[j], XtNallowShellResize, True); j++;
188 // hist->sh = historyShell =
189 // XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass,
190 // shellWidget, args, j);
192 // hist->sh = historyShell =
193 // XtCreatePopupShell(_("Move list"), transientShellWidgetClass,
194 // shellWidget, args, j);
197 // XtSetArg(args[j], XtNborderWidth, 0); j++;
198 // XtSetArg(args[j], XtNdefaultDistance, 0); j++;
200 // XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh,
204 // XtSetArg(args[j], XtNborderWidth, 0); j++;
205 // XtSetArg(args[j], XtNresizable, True); j++;
208 // XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
211 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
212 // XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
213 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
214 // XtSetArg(args[j], XtNright, XtChainRight); j++;
216 // XtSetArg(args[j], XtNborderWidth, 1); j++;
217 // XtSetArg(args[j], XtNresizable, False); j++;
218 // XtSetArg(args[j], XtNallowVert, True); j++;
219 // XtSetArg(args[j], XtNallowHoriz, True); j++;
220 // XtSetArg(args[j], XtNforceBars, False); j++;
221 // XtSetArg(args[j], XtNheight, 280); j++;
223 // XtCreateManagedWidget("viewport", viewportWidgetClass,
226 // XtSetArg(args[j], XtNborderWidth, 0); j++;
227 // XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++;
229 // XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j);
232 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
233 // XtSetArg(args[j], XtNbottom, XtChainTop); j++;
234 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
235 // XtSetArg(args[j], XtNright, XtChainLeft); j++;
237 // XtSetArg(args[j], XtNdefaultColumns, 1); j++;
238 // XtSetArg(args[j], XtNforceColumns, True); j++;
239 // XtSetArg(args[j], XtNverticalList, True); j++;
240 // XtSetArg(args[j], XtNborderWidth, 0); j++;
241 // XtSetArg(args[j], XtNresizable,True);j++;
242 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
243 // hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass,
244 // hist->vbox, args, j);
245 // XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist);
248 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
249 // XtSetArg(args[j], XtNbottom, XtChainTop); j++;
250 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
251 // XtSetArg(args[j], XtNright, XtRubber); j++;
253 // XtSetArg(args[j], XtNdefaultColumns, 1); j++;
254 // XtSetArg(args[j], XtNforceColumns, True); j++;
255 // XtSetArg(args[j], XtNverticalList, True); j++;
256 // XtSetArg(args[j], XtNborderWidth, 0); j++;
257 // XtSetArg(args[j], XtNresizable,True);j++;
258 // XtSetArg(args[j], XtNfromHoriz, hist->mvn); j++;
259 // hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass,
260 // hist->vbox, args, j);
261 // XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist);
264 // XtSetArg(args[j], XtNtop, XtChainTop); j++;
265 // XtSetArg(args[j], XtNbottom, XtChainTop); j++;
266 // XtSetArg(args[j], XtNleft, XtRubber); j++;
267 // XtSetArg(args[j], XtNright, XtRubber); j++;
269 // XtSetArg(args[j], XtNdefaultColumns, 1); j++;
270 // XtSetArg(args[j], XtNforceColumns, True); j++;
271 // XtSetArg(args[j], XtNverticalList, True); j++;
272 // XtSetArg(args[j], XtNborderWidth, 0); j++;
273 // XtSetArg(args[j], XtNresizable,True);j++;
274 // XtSetArg(args[j], XtNfromHoriz, hist->mvw); j++;
275 // hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass,
276 // hist->vbox, args, j);
277 // XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist);
280 // XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
281 // XtSetArg(args[j], XtNtop, XtChainBottom); j++;
282 // XtSetArg(args[j], XtNleft, XtChainLeft); j++;
283 // XtSetArg(args[j], XtNright, XtChainLeft); j++;
284 // XtSetArg(args[j], XtNfromVert, hist->viewport); j++;
285 // b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass,
287 // XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0);
289 // XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr));
291 // XtRealizeWidget(hist->sh);
292 // CatchDeleteWindow(hist->sh, "HistoryPopDown");
294 // for(i=1;i<hist->aNr;i++){
295 // strcpy(hist->white[i],dots);
296 // strcpy(hist->black[i],"");
299 // if(wpMoveHistory.width > 0) {
300 // gameHistoryW = wpMoveHistory.width;
301 // gameHistoryH = wpMoveHistory.height;
302 // gameHistoryX = wpMoveHistory.x;
303 // gameHistoryY = wpMoveHistory.y;
306 // // [HGM] restore old position
307 // if(gameHistoryW > 0) {
309 // XtSetArg(args[j], XtNx, gameHistoryX); j++;
310 // XtSetArg(args[j], XtNy, gameHistoryY); j++;
311 // XtSetArg(args[j], XtNwidth, gameHistoryW); j++;
312 // XtSetArg(args[j], XtNheight, gameHistoryH); j++;
313 // XtSetValues(hist->sh, args, j);
315 // XtRealizeWidget(hist->sh);
324 // if(!hist) HistoryCreate();
326 gtk_widget_show (GUI_History);
333 HistoryShowProc(object, user_data)
339 //TODO: ToNrEvent(currentMove);
349 // return hist && hist->Up;