X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xoptions.c;h=c154030c57119cf043a0b84eac860a86ab71cfbf;hb=6d9218e397e068f6249f19bbcce1ade720cfd791;hp=22737c1f642d614a14045c72a648bfb0fbfbf9da;hpb=21b2748b7e01ca15af0c2dce7102df401dc2666f;p=xboard.git diff --git a/xoptions.c b/xoptions.c index 22737c1..c154030 100644 --- a/xoptions.c +++ b/xoptions.c @@ -45,6 +45,7 @@ extern char *getenv(); #if HAVE_UNISTD_H # include #endif +#include #include #include @@ -78,6 +79,8 @@ extern char *getenv(); # define N_(s) s #endif +extern void SendToProgram P((char *message, ChessProgramState *cps)); + extern Widget formWidget, shellWidget, boardWidget, menuBarWidget; extern Display *xDisplay; extern int squareSize; @@ -140,7 +143,6 @@ void ShuffleCallback(w, client_data, call_data) ShufflePopDown(); shuffleOpenings = False; // [HGM] should be moved to New Variant menu, once we have it! ResetGameEvent(); - AnalysisPopDown(); return; } if (strcmp(name, _("random")) == 0) { @@ -162,7 +164,6 @@ void ShuffleCallback(w, client_data, call_data) shuffleOpenings = True; ShufflePopDown(); ResetGameEvent(); - AnalysisPopDown(); return; } } @@ -958,7 +959,7 @@ void NewVariantCallback(w, client_data, call_data) XtGetValues(w, args, 1); if (strcmp(name, _(" OK ")) == 0) { - int nr = (int) XawToggleGetCurrent(buttonDesc[0].handle) - 1; + int nr = (intptr_t) XawToggleGetCurrent(buttonDesc[0].handle) - 1; if(nr < 0) return; v = buttonDesc[nr].variant; if(!appData.noChessProgram) { @@ -1065,7 +1066,21 @@ void NewVariantPopUp() b_ok= XtCreateManagedWidget(_(" OK "), commandWidgetClass, form, args, j); XtAddCallback(b_ok, XtNcallback, NewVariantCallback, (XtPointer) 0); - XtRealizeWidget(popup); + j=0; + XtSetArg(args[j], XtNfromVert, buttonDesc[14].handle); j++; +// XtSetArg(args[j], XtNheight, 70); j++; + XtSetArg(args[j], XtNbottom, XtChainBottom); j++; + XtSetArg(args[j], XtNtop, XtChainBottom); j++; + XtSetArg(args[j], XtNleft, XtChainLeft); j++; + XtSetArg(args[j], XtNright, XtChainRight); j++; + XtSetArg(args[j], XtNlabel, _("WARNING: variants with un-orthodox\n" + "pieces only have built-in bitmaps\n" + "for -boardSize middling, bulky and\n" + "petite, and substitute king or amazon\n" + "for missing bitmaps. (See manual.)")); j++; + XtCreateManagedWidget("warning", labelWidgetClass, form, args, j); + + XtRealizeWidget(popup); CatchDeleteWindow(popup, "NewVariantPopDown"); XQueryPointer(xDisplay, xBoardWindow, &root, &child, @@ -1324,23 +1339,24 @@ void SpinCallback(w, client_data, call_data) Arg args[16]; char buf[MSG_SIZ]; int i, j; + int data = (intptr_t) client_data; XtSetArg(args[0], XtNlabel, &name); XtGetValues(w, args, 1); j = 0; XtSetArg(args[0], XtNstring, &val); - XtGetValues(currentCps->option[(int)client_data].handle, args, 1); + XtGetValues(currentCps->option[data].handle, args, 1); sscanf(val, "%d", &j); if (strcmp(name, "+") == 0) { - if(++j > currentCps->option[(int)client_data].max) return; + if(++j > currentCps->option[data].max) return; } else if (strcmp(name, "-") == 0) { - if(--j < currentCps->option[(int)client_data].min) return; + if(--j < currentCps->option[data].min) return; } else return; sprintf(buf, "%d", j); XtSetArg(args[0], XtNstring, buf); - XtSetValues(currentCps->option[(int)client_data].handle, args, 1); + XtSetValues(currentCps->option[data].handle, args, 1); } void SettingsCallback(w, client_data, call_data) @@ -1352,6 +1368,7 @@ void SettingsCallback(w, client_data, call_data) Arg args[16]; char buf[MSG_SIZ]; int i, j; + int data = (intptr_t) client_data; XtSetArg(args[0], XtNlabel, &name); XtGetValues(w, args, 1); @@ -1360,7 +1377,7 @@ void SettingsCallback(w, client_data, call_data) SettingsPopDown(); return; } - if (strcmp(name, _("OK")) == 0 || (int)client_data) { // save buttons imply OK + if (strcmp(name, _("OK")) == 0 || data) { // save buttons imply OK int nr; for(i=0; inrOptions; i++) { // send all options that had to be OK-ed to engine @@ -1406,7 +1423,7 @@ void SettingsCallback(w, client_data, call_data) break; } } - if((int)client_data) { // send save-button command to engine + if(data) { // send save-button command to engine sprintf(buf, "option %s\n", name); SendToProgram(buf, currentCps); } @@ -1423,8 +1440,8 @@ void ComboSelect(w, addr, index) // callback for all combo items caddr_t index; { Arg args[16]; - int i = ((int)addr)>>8; - int j = 255 & (int) addr; + int i = ((intptr_t)addr)>>8; + int j = 255 & (intptr_t) addr; values[i] = j; // store in temporary, for transfer at OK XtSetArg(args[0], XtNlabel, ((char**)currentCps->option[i].textValue)[j]); @@ -1451,7 +1468,7 @@ void CreateComboPopup(parent, name, n, mb) menu, args, j); XtAddCallback(entry, XtNcallback, (XtCallbackProc) ComboSelect, - (caddr_t) (256*n+i)); + (caddr_t)(intptr_t) (256*n+i)); i++; } } @@ -1459,18 +1476,21 @@ void CreateComboPopup(parent, name, n, mb) void SettingsPopUp(ChessProgramState *cps) { Arg args[16]; - Widget popup, layout, dialog, edit, form, oldform, last, b_ok, b_cancel; + Widget popup, layout, dialog, edit=NULL, form, oldform, last, b_ok, b_cancel, leftMargin = NULL; Window root, child; - int x, y, i, j; + int x, y, i, j, height, width, h, c; int win_x, win_y; unsigned int mask; char def[80], *p, *q; + static char pane[6] = "paneX"; // to do: start up second engine if needed if(!cps->initDone || !cps->nrOptions) return; // nothing to be done currentCps = cps; - i = 0; + if(cps->nrOptions > 50) width = 4; else if(cps->nrOptions>24) width = 2; else width = 1; + height = cps->nrOptions / width + 1; + i = 0; XtSetArg(args[i], XtNresizable, True); i++; SettingsShell = popup = XtCreatePopupShell(_("Settings Menu"), transientShellWidgetClass, @@ -1479,12 +1499,20 @@ void SettingsPopUp(ChessProgramState *cps) layout = XtCreateManagedWidget(layoutName, formWidgetClass, popup, layoutArgs, XtNumber(layoutArgs)); - + for(c=0; cnrOptions; i++) { + for(h=0; h= cps->nrOptions) break; switch(cps->option[i].type) { case Spin: sprintf(def, "%d", cps->option[i].value); @@ -1518,7 +1546,8 @@ void SettingsPopUp(ChessProgramState *cps) XtSetArg(args[j], XtNheight, 10); j++; XtSetArg(args[j], XtNwidth, 20); j++; edit = XtCreateManagedWidget("+", commandWidgetClass, form, args, j); - XtAddCallback(edit, XtNcallback, SpinCallback, (XtPointer) i); + XtAddCallback(edit, XtNcallback, SpinCallback, + (XtPointer)(intptr_t) i); j=0; XtSetArg(args[j], XtNfromVert, edit); j++; @@ -1526,7 +1555,8 @@ void SettingsPopUp(ChessProgramState *cps) XtSetArg(args[j], XtNheight, 10); j++; XtSetArg(args[j], XtNwidth, 20); j++; last = XtCreateManagedWidget("-", commandWidgetClass, form, args, j); - XtAddCallback(last, XtNcallback, SpinCallback, (XtPointer) i); + XtAddCallback(last, XtNcallback, SpinCallback, + (XtPointer)(intptr_t) i); break; case CheckBox: j=0; @@ -1550,7 +1580,8 @@ void SettingsPopUp(ChessProgramState *cps) XtSetArg(args[j], XtNstate, cps->option[i].value); j++; cps->option[i].handle = (void*) (last = XtCreateManagedWidget(cps->option[i].name, commandWidgetClass, form, args, j)); - XtAddCallback(last, XtNcallback, SettingsCallback, (XtPointer) (cps->option[i].type == SaveButton)); + XtAddCallback(last, XtNcallback, SettingsCallback, + (XtPointer)(intptr_t) (cps->option[i].type == SaveButton)); break; case ComboBox: j=0; @@ -1572,7 +1603,7 @@ void SettingsPopUp(ChessProgramState *cps) break; } } - + } j=0; XtSetArg(args[j], XtNfromVert, last); j++; XtSetArg(args[j], XtNbottom, XtChainBottom); j++; @@ -1600,7 +1631,7 @@ void SettingsPopUp(ChessProgramState *cps) SettingsUp = True; previous = NULL; - SetFocus(edit, popup, (XEvent*) NULL, False); + if(edit)SetFocus(edit, popup, (XEvent*) NULL, False); } void FirstSettingsProc(w, event, prms, nprms) @@ -1621,108 +1652,10 @@ void SecondSettingsProc(w, event, prms, nprms) SettingsPopUp(&second); } -//--------------------------- General Popup for Cloning ---------------------------------- -#if 0 -int XXXUp; -Widget XXXShell; +//---------------------------- Chat Windows ---------------------------------------------- -void XXXPopDown() +void OutputChatMessage(int partner, char *mess) { - if (!XXXUp) return; - XtPopdown(XXXShell); - XtDestroyWidget(XXXShell); - XXXUp = False; - ModeHighlight(); -} - -void XXXCallback(w, client_data, call_data) - Widget w; - XtPointer client_data, call_data; -{ - String name; - Widget w2; - Arg args[16]; - char buf[80]; - - XtSetArg(args[0], XtNlabel, &name); - XtGetValues(w, args, 1); - - if (strcmp(name, _("cancel")) == 0) { - XXXPopDown(); - return; - } - if (strcmp(name, _("ok")) == 0) { - int nr; String name; - name = XawDialogGetValueString(w2 = XtParent(w)); - if(sscanf(name ,"%d",&nr) != 1) { - sprintf(buf, "%d", appData.defaultFrcPosition); - XtSetArg(args[0],XtNvalue, buf); // erase bad (non-numeric) value - XtSetValues(w2, args, 1); - return; - } - XXXPopDown(); - return; - } + return; // dummy } -void XXXPopUp() -{ - Arg args[16]; - Widget popup, layout, dialog, edit; - Window root, child; - int x, y, i; - int win_x, win_y; - unsigned int mask; - char def[80]; - - i = 0; - XtSetArg(args[i], XtNresizable, True); i++; - XtSetArg(args[i], XtNwidth, DIALOG_SIZE); i++; - XXXShell = popup = - XtCreatePopupShell(_("XXX Menu"), transientShellWidgetClass, - shellWidget, args, i); - - layout = - XtCreateManagedWidget(layoutName, formWidgetClass, popup, - layoutArgs, XtNumber(layoutArgs)); - - sprintf(def, "%d\n", appData.defaultFrcPosition); - i = 0; - XtSetArg(args[i], XtNlabel, ""); i++; - XtSetArg(args[i], XtNvalue, def); i++; - XtSetArg(args[i], XtNborderWidth, 0); i++; - dialog = XtCreateManagedWidget("XXX", dialogWidgetClass, - layout, args, i); - - XawDialogAddButton(dialog, _("ok"), XXXCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, _("cancel"), XXXCallback, (XtPointer) dialog); - - XtRealizeWidget(popup); - CatchDeleteWindow(popup, "XXXPopDown"); - - XQueryPointer(xDisplay, xBoardWindow, &root, &child, - &x, &y, &win_x, &win_y, &mask); - - XtSetArg(args[0], XtNx, x - 10); - XtSetArg(args[1], XtNy, y - 30); - XtSetValues(popup, args, 2); - - XtPopup(popup, XtGrabExclusive); - XXXUp = True; - - edit = XtNameToWidget(dialog, "*value"); - - previous = NULL; - SetFocus(engThreshold, popup, (XEvent*) NULL, False); -} - -void XXXMenuProc(w, event, prms, nprms) - Widget w; - XEvent *event; - String *prms; - Cardinal *nprms; -{ - XXXPopUp(); -} -#endif -