X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xhistory.c;h=c00a9b8b46a4a6e3b49e46d0aa69d6fa3dcfa540;hb=869f98444437c60d1178e217db0a45530e37b945;hp=c2ac39290d2a540fc31ad3b34a09541d0ce4ff33;hpb=a5acdedf686f954492492595b327089f15de76a0;p=xboard.git diff --git a/xhistory.c b/xhistory.c index c2ac392..c00a9b8 100644 --- a/xhistory.c +++ b/xhistory.c @@ -1,7 +1,7 @@ /* * xhistory.c -- Move list window, part of X front end for XBoard * - * Copyright 2000,2009 Free Software Foundation, Inc. + * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc. * ------------------------------------------------------------------------ * * GNU XBoard is free software: you can redistribute it and/or modify @@ -67,6 +67,7 @@ extern char *getenv(); #include "xboard.h" #include "xhistory.h" #include "gettext.h" +#include "xevalgraph.h" #ifdef ENABLE_NLS # define _(s) gettext (s) @@ -78,12 +79,6 @@ extern char *getenv(); #define _LL_ 100 -extern Widget formWidget, shellWidget, boardWidget, menuBarWidget; -extern Display *xDisplay; -extern int squareSize; -extern Pixmap xMarkPixmap; -extern char *layoutName; - struct History{ String *Nr,*white,*black; int aNr; /* space actually alocated */ @@ -94,6 +89,7 @@ struct History{ struct History *hist=0; String dots=" ... "; Position gameHistoryX, gameHistoryY; +Dimension gameHistoryW, gameHistoryH; void HistoryPopDown(w, client_data, call_data) @@ -103,18 +99,25 @@ HistoryPopDown(w, client_data, call_data) Arg args[16]; int j; if(hist) { + // [HGM] remember old position j = 0; XtSetArg(args[j], XtNx, &gameHistoryX); j++; XtSetArg(args[j], XtNy, &gameHistoryY); j++; + XtSetArg(args[j], XtNwidth, &gameHistoryW); j++; + XtSetArg(args[j], XtNheight, &gameHistoryH); j++; XtGetValues(hist->sh, args, j); + wpMoveHistory.x = gameHistoryX - 4; + wpMoveHistory.y = gameHistoryY - 23; + wpMoveHistory.width = gameHistoryW; + wpMoveHistory.height = gameHistoryH; XtPopdown(hist->sh); hist->Up=False; } j=0; XtSetArg(args[j], XtNleftBitmap, None); j++; - XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"), + XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Move History"), args, j); } @@ -215,6 +218,7 @@ HistoryFill() void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){ int i,b,m; + Widget scroll; if(hist){ if(last >= hist->aNr) HistoryAlloc(last+_LL_); for(i=0;iwhite[i/2+1], movelist[i], p-movelist[i]); hist->white[i/2+1][p-movelist[i]] = NULLCHAR; } else { - strcpy(hist->white[i/2+1],movelist[i]); + safeStrCpy(hist->white[i/2+1],movelist[i], MOVE_LEN); } } else { - strcpy(hist->white[i/2+1],dots); + safeStrCpy(hist->white[i/2+1],dots, MOVE_LEN); } } else { if(movelist[i][0]) { @@ -237,14 +241,14 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){ strncpy(hist->black[i/2+1], movelist[i], p-movelist[i]); hist->black[i/2+1][p-movelist[i]] = NULLCHAR; } else { - strcpy(hist->black[i/2+1],movelist[i]); + safeStrCpy(hist->black[i/2+1],movelist[i], MOVE_LEN); } } else { - strcpy(hist->black[i/2+1],""); + safeStrCpy(hist->black[i/2+1],"", MOVE_LEN); } } } - strcpy(hist->black[last/2+1],""); + safeStrCpy(hist->black[last/2+1],"", MOVE_LEN); b=first/2; m=(last+3)/2-b; XawFormDoLayout(hist->vbox, False); @@ -266,7 +270,15 @@ void HistorySet(char movelist[][2*MOVE_LEN],int first,int last,int current){ if(current) XawListHighlight(hist->mvb, current/2+1); else XawListUnhighlight(hist->mvb); } + if(scroll = XtNameToWidget(hist->sh, "*form.viewport.vertical")) { // [HGM] always scroll to bottom + static char *params[3] = { "", "Forward", "FullLength" }; + static XEvent event; + XtCallActionProc(scroll, "StartScroll", &event, params+1, 1); + XtCallActionProc(scroll, "NotifyScroll", &event, params+2, 1); + XtCallActionProc(scroll, "EndScroll", &event, params, 0); + } } + EvalGraphSet( first, last, current, pvInfoList ); // piggy-backed } Widget HistoryCreate() @@ -288,11 +300,11 @@ Widget HistoryCreate() XtSetArg(args[j], XtNresizable, True); j++; XtSetArg(args[j], XtNallowShellResize, True); j++; #if TOPLEVEL - hist->sh = + hist->sh = historyShell = XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass, shellWidget, args, j); #else - hist->sh = + hist->sh = historyShell = XtCreatePopupShell(_("Move list"), transientShellWidgetClass, shellWidget, args, j); #endif @@ -309,10 +321,8 @@ Widget HistoryCreate() form = XtCreateManagedWidget("form", formWidgetClass, layout, args, j); - j=0; j = 0; - XtSetArg(args[j], XtNtop, XtChainTop); j++; XtSetArg(args[j], XtNbottom, XtChainBottom); j++; XtSetArg(args[j], XtNleft, XtChainLeft); j++; @@ -397,10 +407,28 @@ Widget HistoryCreate() CatchDeleteWindow(hist->sh, "HistoryPopDown"); for(i=1;iaNr;i++){ - strcpy(hist->white[i],dots); - strcpy(hist->black[i],""); + safeStrCpy(hist->white[i],dots, MOVE_LEN); + safeStrCpy(hist->black[i],"", MOVE_LEN); } + if(wpMoveHistory.width > 0) { + gameHistoryW = wpMoveHistory.width; + gameHistoryH = wpMoveHistory.height; + gameHistoryX = wpMoveHistory.x; + gameHistoryY = wpMoveHistory.y; + } + + // [HGM] restore old position + if(gameHistoryW > 0) { + j = 0; + XtSetArg(args[j], XtNx, gameHistoryX); j++; + XtSetArg(args[j], XtNy, gameHistoryY); j++; + XtSetArg(args[j], XtNwidth, gameHistoryW); j++; + XtSetArg(args[j], XtNheight, gameHistoryH); j++; + XtSetValues(hist->sh, args, j); + } + XtRealizeWidget(hist->sh); + return hist->sh; } @@ -414,15 +442,9 @@ HistoryPopUp() XtPopup(hist->sh, XtGrabNone); - // [HGM] restore old position - j = 0; - XtSetArg(args[j], XtNx, gameHistoryX); j++; - XtSetArg(args[j], XtNy, gameHistoryY); j++; - XtSetValues(hist->sh, args, j); - j=0; XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++; - XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"), + XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Move History"), args, j); hist->Up=True; } @@ -446,3 +468,8 @@ HistoryShowProc(w, event, prms, nprms) ToNrEvent(currentMove); } +Boolean +MoveHistoryIsUp() +{ + return hist && hist->Up; +}