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;
64 extern GtkTreeView *TREE_History;
67 Position gameHistoryX, gameHistoryY;
68 Dimension gameHistoryW, gameHistoryH;
71 HistoryPopDown(object, user_data)
75 /* hides the history window */
77 gtk_widget_hide (GUI_History);
82 HistoryMoveProc(window, event, data)
87 int to; /* the move we want to go to */
89 /* check if the mouse was clicked */
90 if(event->type == GDK_BUTTON_PRESS)
92 GtkTreeViewColumn *column;
98 /* can we convert this into an element of the history list? */
99 if(gtk_tree_view_get_path_at_pos(TREE_History,
100 (gint)event->button.x, (gint)event->button.y,
101 &path,&column,NULL,NULL))
103 /* find out which row and column the user clicked on */
104 indices = gtk_tree_path_get_indices(path);
106 cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(column->tree_view));
107 col = g_list_index(cols,(gpointer)column);
109 gtk_tree_path_free(path);
111 printf("DEBUG: row %d col %d\n",row,col);
116 /* user didn't click on the move number */
119 printf("DEBUG: going to %d\n",to);fflush(stdout);
121 /* set board to that move */
130 void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current)
133 char movewhite[2*MOVE_LEN],moveblack[2*MOVE_LEN],move[2*MOVE_LEN];
136 /* TODO need to add highlights for current move */
137 /* TODO need to add navigation by keyboard or mouse (double click on move) */
139 strcpy(movewhite,"");
140 strcpy(moveblack,"");
142 /* first clear everything, do we need this? */
143 gtk_list_store_clear(LIST_MoveHistory);
145 /* copy move list into history window */
147 /* go through all moves */
150 /* test if there is a move */
153 /* only copy everything before a ' ' */
154 char* p = strchr(movelist[i], ' ');
157 strncpy(move, movelist[i], p-movelist[i]);
158 move[p-movelist[i]] = NULLCHAR;
162 strcpy(move,movelist[i]);
171 strcpy(movewhite,move);
176 strcpy(moveblack,move);
179 gtk_list_store_append (LIST_MoveHistory, &iter);
180 gtk_list_store_set (LIST_MoveHistory, &iter,
186 strcpy(movewhite,"");
187 strcpy(moveblack,"");
191 /* check if there is a white move left */
194 strcpy(moveblack,"");
197 gtk_list_store_append (LIST_MoveHistory, &iter);
198 gtk_list_store_set (LIST_MoveHistory, &iter,
207 // EvalGraphSet( first, last, current, pvInfoList ); // piggy-backed
215 "<Key>Up: BackwardProc() \n \
216 <Key>Left: BackwardProc() \n \
217 <Key>Down: ForwardProc() \n \
218 <Key>Right: ForwardProc() \n";
221 // if(wpMoveHistory.width > 0) {
222 // gameHistoryW = wpMoveHistory.width;
223 // gameHistoryH = wpMoveHistory.height;
224 // gameHistoryX = wpMoveHistory.x;
225 // gameHistoryY = wpMoveHistory.y;
228 // // [HGM] restore old position
229 // if(gameHistoryW > 0) {
231 // XtSetArg(args[j], XtNx, gameHistoryX); j++;
232 // XtSetArg(args[j], XtNy, gameHistoryY); j++;
233 // XtSetArg(args[j], XtNwidth, gameHistoryW); j++;
234 // XtSetArg(args[j], XtNheight, gameHistoryH); j++;
235 // XtSetValues(hist->sh, args, j);
242 /* show history window */
244 gtk_widget_show (GUI_History);
250 HistoryShowProc(object, user_data)
256 //TODO: ToNrEvent(currentMove);
264 /* return status of history window */
266 return gtk_widget_get_visible (GUI_History);