Updated copyright notice to 2012
[xboard.git] / xoptions.c
index 8cc231a..9188fd4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xoptions.c -- Move list window, part of X front end for XBoard
  *
- * Copyright 2000, 2009, 2010, 2011 Free Software Foundation, Inc.
+ * Copyright 2000, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
  * ------------------------------------------------------------------------
  *
  * GNU XBoard is free software: you can redistribute it and/or modify
@@ -595,6 +595,8 @@ Option loadOptions[] = {
 { 0, 0, 0, NULL, (void*) &appData.autoDisplayComment, "", NULL, CheckBox, N_("Auto-Display Comment") },
 { 0, 0, 0, NULL, NULL, NULL, NULL, Label, N_("Auto-Play speed of loaded games\n(0 = instant, -1 = off):") },
 { 0, -1, 10000000, NULL, (void*) &appData.timeDelay, "", NULL, Fractional, N_("Seconds per Move:") },
+{   0,  0,    0, NULL, NULL, NULL, NULL, Label,  N_("\noptions to use in game-viewer mode:") },
+{ 0, 0, 300, NULL, (void*) &appData.viewerOptions, "", NULL, TextBox,  "" },
 {   0,  0,    0, NULL, NULL, NULL, NULL, Label,  N_("\nThresholds for position filtering in game list:") },
 { 0, 0, 5000, NULL, (void*) &appData.eloThreshold1, "", NULL, Spin, N_("Elo of strongest player at least:") },
 { 0, 0, 5000, NULL, (void*) &appData.eloThreshold2, "", NULL, Spin, N_("Elo of weakest player at least:") },
@@ -813,7 +815,7 @@ int GenericReadout(int selected)
     String val;
     Arg args[16];
     char buf[MSG_SIZ], **dest;
-    float x = 0.0; // Initialise because sscanf() will fail if non-numeric text is entered
+    float x;
        for(i=0; ; i++) { // send all options that had to be OK-ed to engine
            if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; }
            switch(currentOption[i].type) {
@@ -838,6 +840,7 @@ int GenericReadout(int selected)
                case Fractional:
                    XtSetArg(args[0], XtNstring, &val);
                    XtGetValues(currentOption[i].handle, args, 1);
+                   x = 0.0; // Initialise because sscanf() will fail if non-numeric text is entered
                    sscanf(val, "%f", &x);
                    if(x > currentOption[i].max) x = currentOption[i].max;
                    if(x < currentOption[i].min) x = currentOption[i].min;
@@ -935,7 +938,8 @@ GenericPopUp(Option *option, char *title, int dlgNr)
     unsigned int mask;
     char def[MSG_SIZ], *msg;
     static char pane[6] = "paneX";
-    Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL;
+    Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL, browse = NULL;
+    Dimension bWidth = 50;
 
     if(shellUp[dlgNr]) return 0; // already up         
     if(dlgNr && shells[dlgNr]) {
@@ -1044,7 +1048,7 @@ GenericPopUp(Option *option, char *title, int dlgNr)
            XtSetArg(args[j], XtNleft, XtChainRight); j++;
            XtSetArg(args[j], XtNright, XtChainRight); j++;
            if(option[i].type == FileName || option[i].type == PathName) {
-               msg = _("browse");
+               msg = _("browse"); w = 0;
                /* automatically scale to width of text */
                XtSetArg(args[j], XtNwidth, (XtArgVal) NULL );  j++;
            } else {
@@ -1054,6 +1058,7 @@ GenericPopUp(Option *option, char *title, int dlgNr)
            }
            edit = XtCreateManagedWidget(msg, commandWidgetClass, form, args, j);
            XtAddCallback(edit, XtNcallback, SpinCallback, (XtPointer)(intptr_t) i);
+           if(w == 0) browse = edit;
 
            if(option[i].type != Spin) break;
 
@@ -1161,6 +1166,11 @@ GenericPopUp(Option *option, char *title, int dlgNr)
 
     // make an attempt to align all spins and textbox controls
     maxWidth = maxTextWidth = 0;
+    if(browse != NULL) {
+       j=0;
+       XtSetArg(args[j], XtNwidth, &bWidth);  j++;
+       XtGetValues(browse, args, j);
+    }
     for(h=0; h<height; h++) {
        i = h + c*height;
        if(option[i].type == EndMark) break;
@@ -1195,6 +1205,12 @@ GenericPopUp(Option *option, char *title, int dlgNr)
        if(option[i].type == TextBox || option[i].type == ComboBox || option[i].type == PathName || option[i].type == FileName) {
            XtSetArg(args[j], XtNwidth, maxTextWidth);  j++;
            XtSetValues(texts[h], args, j);
+           if(bWidth != 50 && (option[i].type == FileName || option[i].type == PathName)) {
+               int tWidth = (option[i].max ? option[i].max : 205) - 5 - bWidth;
+               j = 0;
+               XtSetArg(args[j], XtNwidth, tWidth);  j++;
+               XtSetValues(option[i].handle, args, j);
+           }
        }
     }
   }
@@ -1590,16 +1606,16 @@ void MoveTypeInProc(Widget widget, caddr_t unused, XEvent *event)
 {
     char buf[10], keys[32];
     KeySym sym;
-    KeyCode metaL, metaR, ctrlL, ctrlR;
+    KeyCode metaL, metaR; //, ctrlL, ctrlR;
     int n = XLookupString(&(event->xkey), buf, 10, &sym, NULL);
     XQueryKeymap(xDisplay,keys);
     metaL = XKeysymToKeycode(xDisplay, XK_Meta_L);
     metaR = XKeysymToKeycode(xDisplay, XK_Meta_R);
-    ctrlL = XKeysymToKeycode(xDisplay, XK_Control_L);
-    ctrlR = XKeysymToKeycode(xDisplay, XK_Control_R);
+//    ctrlL = XKeysymToKeycode(xDisplay, XK_Control_L);
+//    ctrlR = XKeysymToKeycode(xDisplay, XK_Control_R);
     if ( n == 1 && *buf >= 32 // printable
         && !(keys[metaL>>3]&1<<(metaL&7)) && !(keys[metaR>>3]&1<<(metaR&7)) // no alt key pressed
-        && !(keys[ctrlL>>3]&1<<(ctrlL&7)) && !(keys[ctrlR>>3]&1<<(ctrlR&7)) // no ctrl key pressed
+//      && !(keys[ctrlL>>3]&1<<(ctrlL&7)) && !(keys[ctrlR>>3]&1<<(ctrlR&7)) // no ctrl key pressed
        )
       {
        if(appData.icsActive) { // text typed to board in ICS mode: divert to ICS input box