move++;
continue;
} else if(piece <= Q_BCASTL) { // castling, encoded as (Q_XCASTL, king-to) + (rook, rook-to)
- int rook;
piece = pieceList[piece]; // first two elements of pieceList contain King numbers
from = pieceList[piece]; // so this must be King
quickBoard[from] = 0;
static int lastBoardValid[2] = {0, 0};
static Board lastBoard[2];
static char lastMarker[BOARD_RANKS][BOARD_FILES];
- Arg args[16];
int rrow, rcol;
int nr = twoBoards*partnerUp;
void
GenericUpdate (Option *opts, int selected)
{
- int i, j;
+ int i;
char buf[MSG_SIZ];
- float x;
- for(i=0; ; i++) {
- if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; }
- switch(opts[i].type) {
- case TextBox:
- case FileName:
- case PathName:
- SetWidgetText(&opts[i], *(char**) opts[i].target, -1);
- break;
- case Spin:
- sprintf(buf, "%d", *(int*) opts[i].target);
- SetWidgetText(&opts[i], buf, -1);
- break;
- case Fractional:
- sprintf(buf, "%4.2f", *(float*) opts[i].target);
- SetWidgetText(&opts[i], buf, -1);
- break;
- case CheckBox:
- SetWidgetState(&opts[i], *(Boolean*) opts[i].target);
- break;
- case ComboBox:
- if(opts[i].min & COMBO_CALLBACK) break;
- SetCurrentComboSelection(opts+i);
- // TODO: actually display this (but it is never used that way...)
- break;
- case EndMark:
- return;
- default:
- printf("GenericUpdate: unexpected case in switch.\n");
- case ListBox:
- case Button:
- case SaveButton:
- case Label:
- case Break:
- break;
- }
- }
+
+ for(i=0; ; i++)
+ {
+ if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; }
+ switch(opts[i].type)
+ {
+ case TextBox:
+ case FileName:
+ case PathName:
+ SetWidgetText(&opts[i], *(char**) opts[i].target, -1);
+ break;
+ case Spin:
+ sprintf(buf, "%d", *(int*) opts[i].target);
+ SetWidgetText(&opts[i], buf, -1);
+ break;
+ case Fractional:
+ sprintf(buf, "%4.2f", *(float*) opts[i].target);
+ SetWidgetText(&opts[i], buf, -1);
+ break;
+ case CheckBox:
+ SetWidgetState(&opts[i], *(Boolean*) opts[i].target);
+ break;
+ case ComboBox:
+ if(opts[i].min & COMBO_CALLBACK) break;
+ SetCurrentComboSelection(opts+i);
+ // TODO: actually display this (but it is never used that way...)
+ break;
+ case EndMark:
+ return;
+ default:
+ printf("GenericUpdate: unexpected case in switch.\n");
+ case ListBox:
+ case Button:
+ case SaveButton:
+ case Label:
+ case Break:
+ break;
+ }
+ }
}
//------------------------------------------- Read out dialog controls ------------------------------------
void
EditCommentProc ()
{
- int j;
if (PopDown(CommentDlg)) { // popdown succesful
// MarkMenuItem("Edit.EditComment", False);
// MarkMenuItem("View.Comments", False);
Option *
BoardPopUp (int squareSize, int lineGap, void *clockFontThingy)
{
- extern Option *dialogOptions[];
int i, size = BOARD_WIDTH*(squareSize + lineGap) + lineGap;
mainOptions[W_WHITE].choice = (char**) clockFontThingy;
mainOptions[W_BLACK].choice = (char**) clockFontThingy;
static ChessProgramState *savCps;
static FILE **savFP;
-static char *fileName, *extFilter, *dirListing, *savMode, **namePtr;
+static char *fileName, *extFilter, *savMode, **namePtr;
static int folderPtr, filePtr, oldVal, byExtension, extFlag;
static char curDir[MSG_SIZ], title[MSG_SIZ], *folderList[1000], *fileList[1000];
struct dirent *dp;
struct stat statBuf;
static int lastFlag;
- char buf[MSG_SIZ];
if(pathFlag < 0) pathFlag = lastFlag;
lastFlag = pathFlag;
folderPtr = filePtr = 0; // clear listing
while (dp = readdir(dir)) { // pass 1: list foders
- char *s = dp->d_name, match;
+ char *s = dp->d_name;
if(!stat(s, &statBuf) && S_ISDIR(statBuf.st_mode)) { // stat succeeds and tells us it is directory
if(s[0] == '.' && strcmp(s, "..")) continue; // suppress hidden, except ".."
ASSIGN(folderList[folderPtr], s); folderPtr++;
void
SaveOnExitProc ()
{
- Arg args[16];
+ saveSettingsOnExit = !saveSettingsOnExit;
- saveSettingsOnExit = !saveSettingsOnExit;
-
- MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit);
+ MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit);
}
void
SaveSettingsProc ()
{
- SaveSettings(settingsFileName);
+ SaveSettings(settingsFileName);
}
void
void
PonderNextMoveProc ()
{
- Arg args[16];
-
- PonderNextMoveEvent(!appData.ponderNextMove);
- MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove);
+ PonderNextMoveEvent(!appData.ponderNextMove);
+ MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove);
}
void
void
HideThinkingProc ()
{
- Arg args[16];
-
- appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
- ShowThinkingEvent();
+ appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
+ ShowThinkingEvent();
- MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman);
+ MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman);
}
/*
static void
GL_Button (int n)
{
- int index, j;
+ int index;
n = gamesOptions[n].value; // use marker in option rather than n itself, for more easy adding/deletng of buttons
if (n == 6) { // close
PopDown(GameListDlg);
GameListReplace (int page)
{
// filter: put in separate routine, to make callable from call-back
- char buf[MSG_SIZ], *p, **st=list;
+ char buf[MSG_SIZ], **st=list;
int i;
if(page) *st++ = _("previous page"); else if(listLength > 1000) *st++ = "";
void
GameListPopUp (FILE *fp, char *filename)
{
- char **st;
-
if (glc == NULL) {
glc = (GameListClosure *) calloc(1, sizeof(GameListClosure));
glc->x = glc->y = -1;
void
ShowGameListProc ()
{
- Arg args[16];
- int j;
-
if (glc == NULL) {
DisplayError(_("There is no game list"), 0);
return;
void
GetActualPlacement (Widget wg, WindowPlacement *wp)
{
- Arg args[16];
- Dimension w, h;
- Position x, y;
XWindowAttributes winAt;
Window win, dummy;
- int i, rx, ry;
+ int rx, ry;
if(!wg) return;
- win = XtWindow(wg);
- XGetWindowAttributes(xDisplay, win, &winAt); // this works, where XtGetValues on XtNx, XtNy does not!
- XTranslateCoordinates (xDisplay, win, winAt.root, -winAt.border_width, -winAt.border_width, &rx, &ry, &dummy);
- wp->x = rx - winAt.x;
- wp->y = ry - winAt.y;
- wp->height = winAt.height;
- wp->width = winAt.width;
- frameX = winAt.x; frameY = winAt.y; // remember to decide if windows touch
+ win = XtWindow(wg);
+ XGetWindowAttributes(xDisplay, win, &winAt); // this works, where XtGetValues on XtNx, XtNy does not!
+ XTranslateCoordinates (xDisplay, win, winAt.root, -winAt.border_width, -winAt.border_width, &rx, &ry, &dummy);
+ wp->x = rx - winAt.x;
+ wp->y = ry - winAt.y;
+ wp->height = winAt.height;
+ wp->width = winAt.width;
+ frameX = winAt.x; frameY = winAt.y; // remember to decide if windows touch
}
void
void
InitDrawingSizes (BoardSize boardSize, int flags)
{ // [HGM] resize is functional now, but for board format changes only (nr of ranks, files)
- Dimension timerWidth, boardWidth, boardHeight, w, h, sep, bor, wr, hr;
- Arg args[16];
- XtGeometryResult gres;
+ Dimension boardWidth, boardHeight, w, h;
int i;
static Dimension oldWidth, oldHeight;
static VariantClass oldVariant;
void
InitializeFonts (int clockFontPxlSize, int coordFontPxlSize, int fontPxlSize)
-{ // determine what fonts to use, and create them
- XrmValue vFrom, vTo;
+{ // detervtomine what fonts to use, and create them
+ XrmValue vTo;
XrmDatabase xdb;
if(!fontIsSet[CLOCK_FONT] && fontValid[CLOCK_FONT][squareSize])
int
main (int argc, char **argv)
{
- int i, j, clockFontPxlSize, coordFontPxlSize, fontPxlSize;
+ int i, clockFontPxlSize, coordFontPxlSize, fontPxlSize;
XSetWindowAttributes window_attributes;
Arg args[16];
- Dimension timerWidth, boardWidth, boardHeight, w, h, sep, bor, wr, hr;
- XtGeometryResult gres;
+ Dimension boardWidth, boardHeight, w, h;
char *p;
int forceMono = False;
static void
CreateGCs (int redo)
{
- XtGCMask value_mask = GCLineWidth | GCLineStyle | GCForeground
- | GCBackground | GCFunction | GCPlaneMask;
XGCValues gc_values;
GC copyInvertedGC;
Pixel white = XWhitePixel(xDisplay, xScreen);
void
KeyBindingProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
{ // [HGM] new method of key binding: specify MenuItem(FlipView) in stead of FlipViewProc in translation string
- int i;
- char *p;
MenuItem *item;
if(*nprms == 0) return;
item = MenuNameToItem(prms[0]);
fileProc = proc; /* I can't see a way not */
fileOpenMode = openMode; /* to use globals here */
{ // [HGM] use file-selector dialog stolen from Ghostview
- int index; // this is not supported yet
+ // int index; // this is not supported yet
Browse(BoardWindow, label, (def[0] ? def : NULL), filter, False, openMode, &openName, &openFP);
}
}
void
EditTagsProc ()
{
- Arg args[5];
- int j;
- if (bookUp || !PopDown(TagsDlg)) EditTagsEvent();
+ if (bookUp || !PopDown(TagsDlg)) EditTagsEvent();
}
void
EvalGraphPopUp ()
{
- Arg args[16];
- int j;
-
if (GenericPopUp(graphOptions, _(title), EvalGraphDlg, BoardWindow, NONMODAL, 1)) {
InitializeEvalGraph(&graphOptions[0]); // first time: add callbacks and initialize pens
} else {
static Widget
CreateComboPopup (Widget parent, Option *opt, int n, int fromList, int def)
{ // fromList determines if the item texts are taken from a list of strings, or from a menu table
- int i, j;
+ int i;
Widget menu, entry;
Arg arg;
MenuItem *mb = (MenuItem *) opt->choice;
for (i=0; 1; i++)
{
- char *msg = fromList ? list[i] : mb[i].string, *msg2;
+ char *msg = fromList ? list[i] : mb[i].string;
if(!msg) break;
entry = CreateMenuItem(menu, opt->min & NO_GETTEXT ? msg : _(msg), (XtCallbackProc) ComboSelect, (n<<16)+i);
if(!fromList) mb[i].handle = (void*) entry; // save item ID, for enabling / checkmarking
int j=0, n = atoi(prms[0]);
static char *params[3] = { "", "Continuous", "Proportional" };
Arg args[16];
- float f, h, top;
+ float h, top;
Widget v;
if(!n) { // transient dialogs also use this for list-selection callback
n = prms[1][0]-'0';
static void
SqueezeIntoBox (Option *opt, int nr, int width)
{ // size buttons in bar to fit, clipping button names where necessary
- int i, j, wtot = 0;
+ int i, wtot = 0;
Dimension widths[20], oldWidths[20];
Arg arg;
for(i=1; i<nr; i++) {
char def[MSG_SIZ], *msg, engineDlg = (currentCps != NULL && dlgNr != BrowserDlg);
static char pane[6] = "paneX";
Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL, browse = NULL;
- Dimension bWidth = 50, m;
+ Dimension bWidth = 50;
if(dlgNr < PromoDlg && shellUp[dlgNr]) return 0; // already up
if(dlgNr && dlgNr < PromoDlg && shells[dlgNr]) { // reusable, and used before (but popped down)