Major refactoring of GenericPopUp
[xboard.git] / dialogs.c
index 16cf978..ba47eac 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -65,7 +65,6 @@ extern char *getenv();
 
 int values[MAX_OPTIONS];
 ChessProgramState *currentCps;
-ButtonCallback *comboCallback;
 
 //----------------------------Generic dialog --------------------------------------------
 
@@ -89,6 +88,18 @@ AddLine (Option *opt, char *s)
 
 //---------------------------------------------- Update dialog controls ------------------------------------
 
+int
+SetCurrentComboSelection (Option *opt)
+{
+    int j;
+    if(!opt->textValue) opt->value = *(int*)opt->target; /* numeric */else {
+       for(j=0; opt->choice[j]; j++) // look up actual value in list of possible values, to get selection nr
+           if(*(char**)opt->target && !strcmp(*(char**)opt->target, ((char**)opt->textValue)[j])) break;
+       opt->value = j + (opt->choice[j] == NULL);
+    }
+    return opt->value;
+}
+
 void
 GenericUpdate (Option *opts, int selected)
 {
@@ -115,15 +126,15 @@ GenericUpdate (Option *opts, int selected)
                    SetWidgetState(&opts[i],  *(Boolean*) opts[i].target);
                    break;
                case ComboBox:
-                   for(j=0; opts[i].choice[j]; j++)
-                       if(*(char**)opts[i].target && !strcmp(*(char**)opts[i].target, opts[i].choice[j])) break;
-                   values[i] = opts[i].value = j + (opts[i].choice[j] == NULL);
-                   // TODO: actually display this
+                 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:
@@ -190,12 +201,13 @@ GenericReadout (Option *opts, int selected)
                    }
                    break;
                case ComboBox:
-                   val = ((char**)opts[i].choice)[values[i]];
+                   if(opts[i].min & COMBO_CALLBACK) break;
+                   if(!opts[i].textValue) { *(int*)opts[i].target == opts[i].value; break; } // numeric
+                   val = ((char**)opts[i].textValue)[values[i]];
                    if(currentCps) {
                        if(opts[i].value == values[i]) break; // not changed
                        opts[i].value = values[i];
-                       snprintf(buf, MSG_SIZ,  "option %s=%s\n", opts[i].name,
-                               ((char**)opts[i].textValue)[values[i]]);
+                       snprintf(buf, MSG_SIZ,  "option %s=%s\n", opts[i].name, opts[i].choice[values[i]]);
                        SendToProgram(buf, currentCps);
                    } else if(val && (*(char**) opts[i].target == NULL || strcmp(*(char**) opts[i].target, val))) {
                      if(*(char**) opts[i].target) free(*(char**) opts[i].target);
@@ -208,6 +220,7 @@ GenericReadout (Option *opts, int selected)
                    break;
            default:
                printf("GenericReadout: unexpected case in switch.\n");
+               case ListBox:
                case Button:
                case SaveButton:
                case Label:
@@ -243,9 +256,10 @@ static Option matchOptions[] = {
 { 0,  0,          0, NULL, (void*) &tfName, ".trn", NULL, FileName, N_("Tournament file:") },
 { 0,  0,          0, NULL, (void*) &appData.roundSync, "", NULL, CheckBox, N_("Sync after round    (for concurrent playing of a single") },
 { 0,  0,          0, NULL, (void*) &appData.cycleSync, "", NULL, CheckBox, N_("Sync after cycle      tourney with multiple XBoards)") },
-{ 0xD, 150,       0, NULL, (void*) &engineName, "", NULL, TextBox, N_("Tourney participants:") },
+{ 150, T_VSCRL | T_FILL | T_WRAP,
+                  0, NULL, (void*) &engineName, "", NULL, TextBox, N_("Tourney participants:") },
 { 0,  COMBO_CALLBACK | NO_GETTEXT,
-                 0, NULL, (void*) &engineChoice, (char*) (engineMnemonic+1), (engineMnemonic+1), ComboBox, N_("Select Engine:") },
+                 0, NULL, (void*) &AddToTourney, (char*) (engineMnemonic+1), (engineMnemonic+1), ComboBox, N_("Select Engine:") },
 { 0,  0,         10, NULL, (void*) &appData.tourneyType, "", NULL, Spin, N_("Tourney type (0 = round-robin, 1 = gauntlet):") },
 { 0,  1, 1000000000, NULL, (void*) &appData.tourneyCycles, "", NULL, Spin, N_("Number of tourney cycles (or Swiss rounds):") },
 { 0,  1, 1000000000, NULL, (void*) &appData.defaultMatchGames, "", NULL, Spin, N_("Default Number of Games in Match (or Pairing):") },
@@ -258,9 +272,9 @@ static Option matchOptions[] = {
 { 0,  0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, N_("Rewind Index after this many Games (0 = never):") },
 { 0,  0,          0, NULL, (void*) &appData.defNoBook, "", NULL, CheckBox, N_("Disable own engine books by default") },
 { 0,  0,          0, NULL, (void*) &ReplaceParticipant, NULL, NULL, Button, N_("Replace Engine") },
-{ 0,  1,          0, NULL, (void*) &UpgradeParticipant, NULL, NULL, Button, N_("Upgrade Engine") },
-{ 0,  1,          0, NULL, (void*) &CloneTourney, NULL, NULL, Button, N_("Clone Tourney") },
-{ 0, 1, 0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" }
+{ 0, SAME_ROW,    0, NULL, (void*) &UpgradeParticipant, NULL, NULL, Button, N_("Upgrade Engine") },
+{ 0, SAME_ROW,    0, NULL, (void*) &CloneTourney, NULL, NULL, Button, N_("Clone Tourney") },
+{ 0, SAME_ROW,    0, NULL, (void*) &MatchOK, "", NULL, EndMark , "" }
 };
 
 static void
@@ -295,19 +309,17 @@ CloneTourney ()
 static void
 AddToTourney (int n)
 {
-    GenericReadout(matchOptions, 4);  // selected engine
-    AddLine(&matchOptions[3], engineChoice);
+    AddLine(&matchOptions[3], engineMnemonic[values[4]+1]);
 }
 
 void
 MatchOptionsProc ()
 {
    NamesToList(firstChessProgramNames, engineList, engineMnemonic, "all");
-   comboCallback = &AddToTourney;
    matchOptions[5].min = -(appData.pairingEngine[0] != NULLCHAR); // with pairing engine, allow Swiss
    ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName));
    ASSIGN(engineName, appData.participants);
-   GenericPopUp(matchOptions, _("Match Options"), TransientDlg);
+   GenericPopUp(matchOptions, _("Match Options"), TransientDlg, BoardWindow, MODAL);
 }
 
 // ------------------------------------------- General Options --------------------------------------------------
@@ -348,10 +360,10 @@ static Option generalOptions[] = {
 { 0,  0, 0, NULL, (void*) &appData.markers, "", NULL, CheckBox, N_("Show Target Squares") },
 { 0,  0, 0, NULL, (void*) &appData.useStickyWindows, "", NULL, CheckBox, N_("Sticky Windows") },
 { 0,  0, 0, NULL, (void*) &appData.testLegality, "", NULL, CheckBox, N_("Test Legality") },
-{ 0, 0, 10, NULL, (void*) &appData.flashCount, "", NULL, Spin, N_("Flash Moves (0 = no flashing):") },
-{ 0, 1, 10, NULL, (void*) &appData.flashRate, "", NULL, Spin, N_("Flash Rate (high = fast):") },
-{ 0, 5, 100,NULL, (void*) &appData.animSpeed, "", NULL, Spin, N_("Animation Speed (high = slow):") },
-{ 0,  1, 5, NULL, (void*) &appData.zoom, "", NULL, Spin, N_("Zoom factor in Evaluation Graph:") },
+{ 0, 0,10,  NULL, (void*) &appData.flashCount, "", NULL, Spin, N_("Flash Moves (0 = no flashing):") },
+{ 0, 1,10,  NULL, (void*) &appData.flashRate, "", NULL, Spin, N_("Flash Rate (high = fast):") },
+{ 0, 5,100, NULL, (void*) &appData.animSpeed, "", NULL, Spin, N_("Animation Speed (high = slow):") },
+{ 0, 1,5,   NULL, (void*) &appData.zoom, "", NULL, Spin, N_("Zoom factor in Evaluation Graph:") },
 { 0,  0, 0, NULL, (void*) &GeneralOptionsOK, "", NULL, EndMark , "" }
 };
 
@@ -360,7 +372,7 @@ OptionsProc ()
 {
    oldPonder = appData.ponderNextMove;
    oldShow = appData.showCoords; oldBlind = appData.blindfold;
-   GenericPopUp(generalOptions, _("General Options"), TransientDlg);
+   GenericPopUp(generalOptions, _("General Options"), TransientDlg, BoardWindow, MODAL);
 }
 
 //---------------------------------------------- New Variant ------------------------------------------------
@@ -368,37 +380,37 @@ OptionsProc ()
 static void Pick P((int n));
 
 static Option variantDescriptors[] = {
-{ VariantNormal, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("normal")},
-{ VariantFairy, 1, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("fairy")},
-{ VariantFischeRandom, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("FRC")},
-{ VariantSChess, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Seirawan")},
-{ VariantWildCastle, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("wild castle")},
-{ VariantSuper, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Superchess")},
-{ VariantNoCastle, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("no castle")},
-{ VariantCrazyhouse, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("crazyhouse")},
-{ VariantKnightmate, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("knightmate")},
-{ VariantBughouse, 1, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("bughouse")},
-{ VariantBerolina, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("berolina")},
-{ VariantShogi, 1, 135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("shogi (9x9)")},
-{ VariantCylinder, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("cylinder")},
-{ VariantXiangqi, 1, 135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("xiangqi (9x10)")},
-{ VariantShatranj, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("shatranj")},
-{ VariantCourier, 1, 135, NULL, (void*) &Pick, "#BFFFBF", NULL, Button, N_("courier (12x8)")},
-{ VariantMakruk, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("makruk")},
-{ VariantGreat, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Great Shatranj (10x8)")},
-{ VariantAtomic, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("atomic")},
-{ VariantFalcon, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("falcon (10x8)")},
-{ VariantTwoKings, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("two kings")},
-{ VariantCapablanca, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Capablanca (10x8)")},
-{ Variant3Check, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("3-checks")},
-{ VariantGothic, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Gothic (10x8)")},
-{ VariantSuicide, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("suicide")},
-{ VariantJanus, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("janus (10x8)")},
-{ VariantGiveaway, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("give-away")},
-{ VariantCapaRandom, 1, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("CRC (10x8)")},
-{ VariantLosers, 0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("losers")},
-{ VariantGrand, 1, 135, NULL, (void*) &Pick, "#5070FF", NULL, Button, N_("grand (10x10)")},
-{ VariantSpartan, 0, 135, NULL, (void*) &Pick, "#FF0000", NULL, Button, N_("Spartan")},
+{ VariantNormal,        0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("normal")},
+{ VariantFairy,  SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("fairy")},
+{ VariantFischeRandom,  0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("FRC")},
+{ VariantSChess, SAME_ROW, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Seirawan")},
+{ VariantWildCastle,    0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("wild castle")},
+{ VariantSuper,  SAME_ROW, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Superchess")},
+{ VariantNoCastle,      0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("no castle")},
+{ VariantCrazyhouse,SAME_ROW,135,NULL,(void*) &Pick, "#FFBFBF", NULL, Button, N_("crazyhouse")},
+{ VariantKnightmate,    0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("knightmate")},
+{ VariantBughouse,SAME_ROW,135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("bughouse")},
+{ VariantBerolina,      0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("berolina")},
+{ VariantShogi,  SAME_ROW, 135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("shogi (9x9)")},
+{ VariantCylinder,      0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("cylinder")},
+{ VariantXiangqi, SAME_ROW,135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("xiangqi (9x10)")},
+{ VariantShatranj,      0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("shatranj")},
+{ VariantCourier, SAME_ROW,135, NULL, (void*) &Pick, "#BFFFBF", NULL, Button, N_("courier (12x8)")},
+{ VariantMakruk,        0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("makruk")},
+{ VariantGreat,  SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Great Shatranj (10x8)")},
+{ VariantAtomic,        0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("atomic")},
+{ VariantFalcon, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("falcon (10x8)")},
+{ VariantTwoKings,      0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("two kings")},
+{ VariantCapablanca,SAME_ROW,135,NULL,(void*) &Pick, "#BFBFFF", NULL, Button, N_("Capablanca (10x8)")},
+{ Variant3Check,        0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("3-checks")},
+{ VariantGothic, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Gothic (10x8)")},
+{ VariantSuicide,       0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("suicide")},
+{ VariantJanus,  SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("janus (10x8)")},
+{ VariantGiveaway,      0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("give-away")},
+{ VariantCapaRandom,SAME_ROW,135,NULL,(void*) &Pick, "#BFBFFF", NULL, Button, N_("CRC (10x8)")},
+{ VariantLosers,        0, 135, NULL, (void*) &Pick, "#FFFFBF", NULL, Button, N_("losers")},
+{ VariantGrand,  SAME_ROW, 135, NULL, (void*) &Pick, "#5070FF", NULL, Button, N_("grand (10x10)")},
+{ VariantSpartan,       0, 135, NULL, (void*) &Pick, "#FF0000", NULL, Button, N_("Spartan")},
 { 0, 0, 0, NULL, NULL, NULL, NULL, Label, N_("Board size ( -1 = default for selected variant):")},
 { 0, -1, BOARD_RANKS-1, NULL, (void*) &appData.NrRanks, "", NULL, Spin, N_("Number of Board Ranks:") },
 { 0, -1, BOARD_FILES, NULL, (void*) &appData.NrFiles, "", NULL, Spin, N_("Number of Board Files:") },
@@ -409,7 +421,7 @@ static Option variantDescriptors[] = {
                                  "for -boardSize middling, bulky and\n"
                                  "petite, and substitute king or amazon\n"
                                  "for missing bitmaps. (See manual.)")},
-{ 0, 2, 0, NULL, NULL, "", NULL, EndMark , "" }
+{ 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" }
 };
 
 static void
@@ -448,7 +460,7 @@ Pick (int n)
 void
 NewVariantProc ()
 {
-   GenericPopUp(variantDescriptors, _("New Variant"), TransientDlg);
+   GenericPopUp(variantDescriptors, _("New Variant"), TransientDlg, BoardWindow, MODAL);
 }
 
 //------------------------------------------- Common Engine Options -------------------------------------
@@ -472,19 +484,19 @@ CommonOptionsOK (int n)
 }
 
 static Option commonEngineOptions[] = {
-{ 0,     0, 0, NULL, (void*) &appData.ponderNextMove, "", NULL, CheckBox, N_("Ponder Next Move") },
+{ 0,  0,    0, NULL, (void*) &appData.ponderNextMove, "", NULL, CheckBox, N_("Ponder Next Move") },
 { 0,  0, 1000, NULL, (void*) &appData.smpCores, "", NULL, Spin, N_("Maximum Number of CPUs per Engine:") },
-{ 0,     0, 0, NULL, (void*) &appData.polyglotDir, "", NULL, PathName, N_("Polygot Directory:") },
-{ 0, 0, 16000, NULL, (void*) &appData.defaultHashSize, "", NULL, Spin, N_("Hash-Table Size (MB):") },
-{ 0,     0, 0, NULL, (void*) &appData.defaultPathEGTB, "", NULL, PathName, N_("Nalimov EGTB Path:") },
+{ 0,  0,    0, NULL, (void*) &appData.polyglotDir, "", NULL, PathName, N_("Polygot Directory:") },
+{ 0,  0,16000, NULL, (void*) &appData.defaultHashSize, "", NULL, Spin, N_("Hash-Table Size (MB):") },
+{ 0,  0,    0, NULL, (void*) &appData.defaultPathEGTB, "", NULL, PathName, N_("Nalimov EGTB Path:") },
 { 0,  0, 1000, NULL, (void*) &appData.defaultCacheSizeEGTB, "", NULL, Spin, N_("EGTB Cache Size (MB):") },
-{ 0,     0, 0, NULL, (void*) &appData.usePolyglotBook, "", NULL, CheckBox, N_("Use GUI Book") },
-{ 0,     0, 0, NULL, (void*) &appData.polyglotBook, ".bin", NULL, FileName, N_("Opening-Book Filename:") },
-{ 0,   0, 100, NULL, (void*) &appData.bookDepth, "", NULL, Spin, N_("Book Depth (moves):") },
-{ 0,   0, 100, NULL, (void*) &appData.bookStrength, "", NULL, Spin, N_("Book Variety (0) vs. Strength (100):") },
-{ 0,     0, 0, NULL, (void*) &appData.firstHasOwnBookUCI, "", NULL, CheckBox, N_("Engine #1 Has Own Book") },
-{ 0,     0, 0, NULL, (void*) &appData.secondHasOwnBookUCI, "", NULL, CheckBox, N_("Engine #2 Has Own Book          ") },
-{ 0,     1, 0, NULL, (void*) &CommonOptionsOK, "", NULL, EndMark , "" }
+{ 0,  0,    0, NULL, (void*) &appData.usePolyglotBook, "", NULL, CheckBox, N_("Use GUI Book") },
+{ 0,  0,    0, NULL, (void*) &appData.polyglotBook, ".bin", NULL, FileName, N_("Opening-Book Filename:") },
+{ 0,  0,  100, NULL, (void*) &appData.bookDepth, "", NULL, Spin, N_("Book Depth (moves):") },
+{ 0,  0,  100, NULL, (void*) &appData.bookStrength, "", NULL, Spin, N_("Book Variety (0) vs. Strength (100):") },
+{ 0,  0,    0, NULL, (void*) &appData.firstHasOwnBookUCI, "", NULL, CheckBox, N_("Engine #1 Has Own Book") },
+{ 0,  0,    0, NULL, (void*) &appData.secondHasOwnBookUCI, "", NULL, CheckBox, N_("Engine #2 Has Own Book          ") },
+{ 0,SAME_ROW,0,NULL, (void*) &CommonOptionsOK, "", NULL, EndMark , "" }
 };
 
 void
@@ -492,7 +504,7 @@ UciMenuProc ()
 {
    oldCores = appData.smpCores;
    oldPonder = appData.ponderNextMove;
-   GenericPopUp(commonEngineOptions, _("Common Engine Settings"), TransientDlg);
+   GenericPopUp(commonEngineOptions, _("Common Engine Settings"), TransientDlg, BoardWindow, MODAL);
 }
 
 //------------------------------------------ Adjudication Options --------------------------------------
@@ -502,19 +514,19 @@ static Option adjudicationOptions[] = {
 { 0, 0,    0, NULL, (void*) &appData.testClaims, "", NULL, CheckBox, N_("Verify Engine Result Claims") },
 { 0, 0,    0, NULL, (void*) &appData.materialDraws, "", NULL, CheckBox, N_("Draw if Insufficient Mating Material") },
 { 0, 0,    0, NULL, (void*) &appData.trivialDraws, "", NULL, CheckBox, N_("Adjudicate Trivial Draws (3-Move Delay)") },
-{ 0, 0,  100, NULL, (void*) &appData.ruleMoves, "", NULL, Spin, N_("N-Move Rule:") },
+{ 0, 0,100,   NULL, (void*) &appData.ruleMoves, "", NULL, Spin, N_("N-Move Rule:") },
 { 0, 0,    6, NULL, (void*) &appData.drawRepeats, "", NULL, Spin, N_("N-fold Repeats:") },
-{ 0, 0, 1000, NULL, (void*) &appData.adjudicateDrawMoves, "", NULL, Spin, N_("Draw after N Moves Total:") },
-{ 0,-5000, 0, NULL, (void*) &appData.adjudicateLossThreshold, "", NULL, Spin, N_("Win / Loss Threshold:") },
+{ 0, 0,1000,  NULL, (void*) &appData.adjudicateDrawMoves, "", NULL, Spin, N_("Draw after N Moves Total:") },
+{ 0, -5000,0, NULL, (void*) &appData.adjudicateLossThreshold, "", NULL, Spin, N_("Win / Loss Threshold:") },
 { 0, 0,    0, NULL, (void*) &first.scoreIsAbsolute, "", NULL, CheckBox, N_("Negate Score of Engine #1") },
 { 0, 0,    0, NULL, (void*) &second.scoreIsAbsolute, "", NULL, CheckBox, N_("Negate Score of Engine #2") },
-{ 0, 1,    0, NULL, NULL, "", NULL, EndMark , "" }
+{ 0,SAME_ROW, 0, NULL, NULL, "", NULL, EndMark , "" }
 };
 
 void
 EngineMenuProc ()
 {
-   GenericPopUp(adjudicationOptions, _("Adjudicate non-ICS Games"), TransientDlg);
+   GenericPopUp(adjudicationOptions, _("Adjudicate non-ICS Games"), TransientDlg, BoardWindow, MODAL);
 }
 
 //--------------------------------------------- ICS Options ---------------------------------------------
@@ -542,7 +554,7 @@ Option icsOptions[] = {
 { 0, 0, 0, NULL, (void*) &appData.premoveWhiteText, "", NULL, TextBox, N_("First White Move:") },
 { 0, 0, 0, NULL, (void*) &appData.premoveBlack, "", NULL, CheckBox, N_("Premove for Black") },
 { 0, 0, 0, NULL, (void*) &appData.premoveBlackText, "", NULL, TextBox, N_("First Black Move:") },
-{ 0, 0, 0, NULL, NULL, NULL, NULL, Break, "" },
+{ 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, "" },
 { 0, 0, 0, NULL, (void*) &appData.icsAlarm, "", NULL, CheckBox, N_("Alarm") },
 { 0, 0, 100000000, NULL, (void*) &appData.icsAlarmTime, "", NULL, Spin, N_("Alarm Time (msec):") },
 //{ 0, 0, 0, NULL, (void*) &appData.chatBoxes, "", NULL, TextBox, N_("Startup Chat Boxes:") },
@@ -562,7 +574,7 @@ Option icsOptions[] = {
 void
 IcsOptionsProc ()
 {
-   GenericPopUp(icsOptions, _("ICS Options"), TransientDlg);
+   GenericPopUp(icsOptions, _("ICS Options"), TransientDlg, BoardWindow, MODAL);
 }
 
 //-------------------------------------------- Load Game Options ---------------------------------
@@ -580,28 +592,28 @@ LoadOptionsOK ()
 }
 
 static Option loadOptions[] = {
-{ 0, 0, 0, NULL, (void*) &appData.autoDisplayTags, "", NULL, CheckBox, N_("Auto-Display Tags") },
-{ 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:") },
-{ 0, 0, 5000, NULL, (void*) &appData.dateThreshold, "", NULL, Spin, N_("No games before year:") },
-{ 0, 1, 50, NULL, (void*) &appData.stretch, "", NULL, Spin, N_("Minimum nr consecutive positions:") },
-{ 1, 0, 180, NULL, (void*) &searchMode, (char*) modeNames, modeValues, ComboBox, N_("Search mode:") },
-{ 0, 0, 0, NULL, (void*) &appData.ignoreColors, "", NULL, CheckBox, N_("Also match reversed colors") },
-{ 0, 0, 0, NULL, (void*) &appData.findMirror, "", NULL, CheckBox, N_("Also match left-right flipped position") },
-{ 0,  0, 0, NULL, (void*) &LoadOptionsOK, "", NULL, EndMark , "" }
+{ 0,  0, 0,     NULL, (void*) &appData.autoDisplayTags, "", NULL, CheckBox, N_("Auto-Display Tags") },
+{ 0,  0, 0,     NULL, (void*) &appData.autoDisplayComment, "", NULL, CheckBox, N_("Auto-Display Comment") },
+{ 0, LR, 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, LR, 0,     NULL, NULL, NULL, NULL, Label,  N_("\noptions to use in game-viewer mode:") },
+{ 0, 0,300,     NULL, (void*) &appData.viewerOptions, "", NULL, TextBox,  "" },
+{ 0, LR,  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:") },
+{ 0, 0,5000,    NULL, (void*) &appData.dateThreshold, "", NULL, Spin, N_("No games before year:") },
+{ 0, 1,50,      NULL, (void*) &appData.stretch, "", NULL, Spin, N_("Minimum nr consecutive positions:") },
+{ 0, 0,205,     NULL, (void*) &searchMode, (char*) modeValues, modeNames, ComboBox, N_("Search mode:") },
+{ 0, 0, 0,      NULL, (void*) &appData.ignoreColors, "", NULL, CheckBox, N_("Also match reversed colors") },
+{ 0, 0, 0,      NULL, (void*) &appData.findMirror, "", NULL, CheckBox, N_("Also match left-right flipped position") },
+{ 0,  0, 0,     NULL, (void*) &LoadOptionsOK, "", NULL, EndMark , "" }
 };
 
 void
 LoadOptionsProc ()
 {
    ASSIGN(searchMode, modeValues[appData.searchMode-1]);
-   GenericPopUp(loadOptions, _("Load Game Options"), TransientDlg);
+   GenericPopUp(loadOptions, _("Load Game Options"), TransientDlg, BoardWindow, MODAL);
 }
 
 //------------------------------------------- Save Game Options --------------------------------------------
@@ -615,13 +627,13 @@ static Option saveOptions[] = {
 { 0, 0, 0, NULL, (void*) &appData.numberTag, "", NULL, CheckBox, N_("Include Number Tag in tourney PGN") },
 { 0, 0, 0, NULL, (void*) &appData.saveExtendedInfoInPGN, "", NULL, CheckBox, N_("Save Score/Depth Info in PGN") },
 { 0, 0, 0, NULL, (void*) &appData.saveOutOfBookInfo, "", NULL, CheckBox, N_("Save Out-of-Book Info in PGN           ") },
-{ 0, 1, 0, NULL, NULL, "", NULL, EndMark , "" }
+{ 0, SAME_ROW, 0, NULL, NULL, "", NULL, EndMark , "" }
 };
 
 void
 SaveOptionsProc ()
 {
-   GenericPopUp(saveOptions, _("Save Game Options"), TransientDlg);
+   GenericPopUp(saveOptions, _("Save Game Options"), TransientDlg, BoardWindow, MODAL);
 }
 
 //----------------------------------------------- Sound Options ---------------------------------------------
@@ -669,24 +681,24 @@ static Option soundOptions[] = {
 { 0, 0, 0, NULL, (void*) &appData.soundProgram, "", NULL, TextBox, N_("Sound Program:") },
 { 0, 0, 0, NULL, (void*) &appData.soundDirectory, "", NULL, PathName, N_("Sounds Directory:") },
 { 0, 0, 0, NULL, (void*) (soundFiles+2) /* kludge! */, ".wav", NULL, FileName, N_("User WAV File:") },
-{ 0, 0, 0, NULL, (void*) &trialSound, (char*) soundNames, soundFiles, ComboBox, N_("Try-Out Sound:") },
-{ 0, 1, 0, NULL, (void*) &Test, NULL, NULL, Button, N_("Play") },
-{ 0, 0, 0, NULL, (void*) &appData.soundMove, (char*) soundNames, soundFiles, ComboBox, N_("Move:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundIcsWin, (char*) soundNames, soundFiles, ComboBox, N_("Win:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundIcsLoss, (char*) soundNames, soundFiles, ComboBox, N_("Lose:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundIcsDraw, (char*) soundNames, soundFiles, ComboBox, N_("Draw:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundIcsUnfinished, (char*) soundNames, soundFiles, ComboBox, N_("Unfinished:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundIcsAlarm, (char*) soundNames, soundFiles, ComboBox, N_("Alarm:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundShout, (char*) soundNames, soundFiles, ComboBox, N_("Shout:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundSShout, (char*) soundNames, soundFiles, ComboBox, N_("S-Shout:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundChannel, (char*) soundNames, soundFiles, ComboBox, N_("Channel:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundChannel1, (char*) soundNames, soundFiles, ComboBox, N_("Channel 1:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundTell, (char*) soundNames, soundFiles, ComboBox, N_("Tell:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundKibitz, (char*) soundNames, soundFiles, ComboBox, N_("Kibitz:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundChallenge, (char*) soundNames, soundFiles, ComboBox, N_("Challenge:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundRequest, (char*) soundNames, soundFiles, ComboBox, N_("Request:") },
-{ 0, 0, 0, NULL, (void*) &appData.soundSeek, (char*) soundNames, soundFiles, ComboBox, N_("Seek:") },
-{ 0, 1, 0, NULL, NULL, "", NULL, EndMark , "" }
+{ 0, 0, 0, NULL, (void*) &trialSound, (char*) soundFiles, soundNames, ComboBox, N_("Try-Out Sound:") },
+{ 0, SAME_ROW, 0, NULL, (void*) &Test, NULL, NULL, Button, N_("Play") },
+{ 0, 0, 0, NULL, (void*) &appData.soundMove, (char*) soundFiles, soundNames, ComboBox, N_("Move:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundIcsWin, (char*) soundFiles, soundNames, ComboBox, N_("Win:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundIcsLoss, (char*) soundFiles, soundNames, ComboBox, N_("Lose:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundIcsDraw, (char*) soundFiles, soundNames, ComboBox, N_("Draw:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundIcsUnfinished, (char*) soundFiles, soundNames, ComboBox, N_("Unfinished:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundIcsAlarm, (char*) soundFiles, soundNames, ComboBox, N_("Alarm:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundShout, (char*) soundFiles, soundNames, ComboBox, N_("Shout:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundSShout, (char*) soundFiles, soundNames, ComboBox, N_("S-Shout:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundChannel, (char*) soundFiles, soundNames, ComboBox, N_("Channel:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundChannel1, (char*) soundFiles, soundNames, ComboBox, N_("Channel 1:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundTell, (char*) soundFiles, soundNames, ComboBox, N_("Tell:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundKibitz, (char*) soundFiles, soundNames, ComboBox, N_("Kibitz:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundChallenge, (char*) soundFiles, soundNames, ComboBox, N_("Challenge:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundRequest, (char*) soundFiles, soundNames, ComboBox, N_("Request:") },
+{ 0, 0, 0, NULL, (void*) &appData.soundSeek, (char*) soundFiles, soundNames, ComboBox, N_("Seek:") },
+{ 0, SAME_ROW, 0, NULL, NULL, "", NULL, EndMark , "" }
 };
 
 static void
@@ -701,7 +713,7 @@ SoundOptionsProc ()
 {
    free(soundFiles[2]);
    soundFiles[2] = strdup("*");
-   GenericPopUp(soundOptions, _("Sound Options"), TransientDlg);
+   GenericPopUp(soundOptions, _("Sound Options"), TransientDlg, BoardWindow, MODAL);
 }
 
 //--------------------------------------------- Board Options --------------------------------------
@@ -721,46 +733,46 @@ BoardOptionsOK (int n)
 }
 
 static Option boardOptions[] = {
-{ 0,   0, 70, NULL, (void*) &appData.whitePieceColor, "", NULL, TextBox, N_("White Piece Color:") },
-{ 1000, 1, 0, NULL, (void*) &DefColor, NULL, (char**) "#FFFFCC", Button, "      " },
+{ 0,          0, 70, NULL, (void*) &appData.whitePieceColor, "", NULL, TextBox, N_("White Piece Color:") },
+{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#FFFFCC", Button, "      " },
 /* TRANSLATORS: R = single letter for the color red */
-{    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
+{    1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
 /* TRANSLATORS: G = single letter for the color green */
-{    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
+{    2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
 /* TRANSLATORS: B = single letter for the color blue */
-{    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
+{    3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
 /* TRANSLATORS: D = single letter to make a color darker */
-{    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
-{ 0,   0, 70, NULL, (void*) &appData.blackPieceColor, "", NULL, TextBox, N_("Black Piece Color:") },
-{ 1000, 1, 0, NULL, (void*) &DefColor, NULL, (char**) "#202020", Button, "      " },
-{    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
-{    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
-{    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
-{    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
-{ 0,   0, 70, NULL, (void*) &appData.lightSquareColor, "", NULL, TextBox, N_("Light Square Color:") },
-{ 1000, 1, 0, NULL, (void*) &DefColor, NULL, (char**) "#C8C365", Button, "      " },
-{    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
-{    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
-{    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
-{    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
-{ 0,   0, 70, NULL, (void*) &appData.darkSquareColor, "", NULL, TextBox, N_("Dark Square Color:") },
-{ 1000, 1, 0, NULL, (void*) &DefColor, NULL, (char**) "#77A26D", Button, "      " },
-{    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
-{    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
-{    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
-{    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
-{ 0,   0, 70, NULL, (void*) &appData.highlightSquareColor, "", NULL, TextBox, N_("Highlight Color:") },
-{ 1000, 1, 0, NULL, (void*) &DefColor, NULL, (char**) "#FFFF00", Button, "      " },
-{    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
-{    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
-{    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
-{    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
-{ 0,   0, 70, NULL, (void*) &appData.premoveHighlightColor, "", NULL, TextBox, N_("Premove Highlight Color:") },
-{ 1000, 1, 0, NULL, (void*) &DefColor, NULL, (char**) "#FF0000", Button, "      " },
-{    1, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
-{    2, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
-{    3, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
-{    4, 1, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
+{    4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
+{ 0,          0, 70, NULL, (void*) &appData.blackPieceColor, "", NULL, TextBox, N_("Black Piece Color:") },
+{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#202020", Button, "      " },
+{    1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
+{    2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
+{    3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
+{    4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
+{ 0,          0, 70, NULL, (void*) &appData.lightSquareColor, "", NULL, TextBox, N_("Light Square Color:") },
+{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#C8C365", Button, "      " },
+{    1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
+{    2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
+{    3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
+{    4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
+{ 0,          0, 70, NULL, (void*) &appData.darkSquareColor, "", NULL, TextBox, N_("Dark Square Color:") },
+{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#77A26D", Button, "      " },
+{    1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
+{    2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
+{    3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
+{    4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
+{ 0,          0, 70, NULL, (void*) &appData.highlightSquareColor, "", NULL, TextBox, N_("Highlight Color:") },
+{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#FFFF00", Button, "      " },
+{    1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
+{    2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
+{    3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
+{    4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
+{ 0,          0, 70, NULL, (void*) &appData.premoveHighlightColor, "", NULL, TextBox, N_("Premove Highlight Color:") },
+{ 1000, SAME_ROW, 0, NULL, (void*) &DefColor, NULL, (char**) "#FF0000", Button, "      " },
+{    1, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("R") },
+{    2, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("G") },
+{    3, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("B") },
+{    4, SAME_ROW, 0, NULL, (void*) &AdjustColor, NULL, NULL, Button, N_("D") },
 { 0, 0, 0, NULL, (void*) &appData.upsideDown, "", NULL, CheckBox, N_("Flip Pieces Shogi Style        (Colored buttons restore default)") },
 //{ 0, 0, 0, NULL, (void*) &appData.allWhite, "", NULL, CheckBox, N_("Use Outline Pieces for Black") },
 { 0, 0, 0, NULL, (void*) &appData.monoMode, "", NULL, CheckBox, N_("Mono Mode") },
@@ -818,7 +830,7 @@ AdjustColor (int i)
 void
 BoardOptionsProc ()
 {
-   GenericPopUp(boardOptions, _("Board Options"), TransientDlg);
+   GenericPopUp(boardOptions, _("Board Options"), TransientDlg, BoardWindow, MODAL);
 }
 
 //-------------------------------------------- ICS Text Menu Options ------------------------------
@@ -870,7 +882,7 @@ IcsTextProc ()
    textOptions[i].target = NULL;
    textOptions[i].min = 2;
    MarkMenu("ICStex", TextMenuDlg);
-   GenericPopUp(textOptions, _("ICS text menu"), TextMenuDlg);
+   GenericPopUp(textOptions, _("ICS text menu"), TextMenuDlg, BoardWindow, NONMODAL);
 }
 
 //---------------------------------------------------- Edit Comment -----------------------------------
@@ -888,10 +900,10 @@ NewComCallback (int n)
 }
 
 Option commentOptions[] = {
-{ 0xD, 200, 250, NULL, (void*) &commentText, "", NULL, TextBox, "" },
-{   0,  0,   50, NULL, (void*) &ClearComment, NULL, NULL, Button, N_("clear") },
-{   0,  1,  100, NULL, (void*) &SaveChanges, NULL, NULL, Button, N_("save changes") },
-{   0,  1,    0, NULL, (void*) &NewComCallback, "", NULL, EndMark , "" }
+{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 250, NULL, (void*) &commentText, "", NULL, TextBox, "" },
+{ 0,     0,     50, NULL, (void*) &ClearComment, NULL, NULL, Button, N_("clear") },
+{ 0, SAME_ROW, 100, NULL, (void*) &SaveChanges, NULL, NULL, Button, N_("save changes") },
+{ 0, SAME_ROW,  0,  NULL, (void*) &NewComCallback, "", NULL, EndMark , "" }
 };
 
 static void
@@ -917,7 +929,7 @@ NewCommentPopup (char *title, char *text, int index)
     if(commentText) free(commentText); commentText = strdup(text);
     commentIndex = index;
     MarkMenu("Show Comments", CommentDlg);
-    if(GenericPopUp(commentOptions, title, CommentDlg))
+    if(GenericPopUp(commentOptions, title, CommentDlg, BoardWindow, NONMODAL))
        AddHandler(&commentOptions[0], 1);
 }
 
@@ -945,10 +957,10 @@ NewTagsCallback (int n)
 }
 
 static Option tagsOptions[] = {
-{   0,  0,    0, NULL, NULL, NULL, NULL, Label,  "" },
-{ 0xD, 200, 200, NULL, (void*) &tagsText, "", NULL, TextBox, "" },
-{   0,  0,  100, NULL, (void*) &changeTags, NULL, NULL, Button, N_("save changes") },
-{   0,  1,    0, NULL, (void*) &NewTagsCallback, "", NULL, EndMark , "" }
+{   0,   0,   0, NULL, NULL, NULL, NULL, Label,  NULL },
+{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 200, NULL, (void*) &tagsText, "", NULL, TextBox, "" },
+{   0,   0, 100, NULL, (void*) &changeTags, NULL, NULL, Button, N_("save changes") },
+{ 0,SAME_ROW, 0, NULL, (void*) &NewTagsCallback, "", NULL, EndMark , "" }
 };
 
 static void
@@ -969,9 +981,9 @@ NewTagsPopup (char *text, char *msg)
        SetDialogTitle(TagsDlg, title);
     }
     if(tagsText) free(tagsText); tagsText = strdup(text);
-    tagsOptions[0].textValue = msg;
+    tagsOptions[0].name = msg;
     MarkMenu("Show Tags", TagsDlg);
-    GenericPopUp(tagsOptions, title, TagsDlg);
+    GenericPopUp(tagsOptions, title, TagsDlg, BoardWindow, NONMODAL);
 }
 
 //---------------------------------------------- ICS Input Box ----------------------------------
@@ -1023,6 +1035,11 @@ NextInHistory ()
 }
 // end of borrowed code
 
+Option boxOptions[] = {
+{  30,  0,  400, NULL, (void*) &icsText, "", NULL, TextBox, "" },
+{  0,SAME_ROW | NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" }
+};
+
 void
 ICSInputSendText ()
 {
@@ -1054,11 +1071,6 @@ IcsKey (int n)
     SetWidgetText(&boxOptions[0], val ? val : "", InputBoxDlg);
 }
 
-Option boxOptions[] = {
-{   0, 30,  400, NULL, (void*) &icsText, "", NULL, TextBox, "" },
-{   0,  3,    0, NULL, NULL, "", NULL, EndMark , "" }
-};
-
 static void
 PutText (char *text, int pos)
 {
@@ -1077,7 +1089,7 @@ void
 ICSInputBoxPopUp ()
 {
     MarkMenu("ICS Input Box", InputBoxDlg);
-    if(GenericPopUp(boxOptions, _("ICS input box"), InputBoxDlg))
+    if(GenericPopUp(boxOptions, _("ICS input box"), InputBoxDlg, BoardWindow, NONMODAL))
        AddHandler(&boxOptions[0], 3);
 }
 
@@ -1089,13 +1101,27 @@ IcsInputBoxProc ()
 
 //--------------------------------------------- Move Type In ------------------------------------------
 
+static int TypeInOK P((int n));
+
+Option typeOptions[] = {
+{ 30,  0,            400, NULL, (void*) &icsText, "", NULL, TextBox, "" },
+{ 0, SAME_ROW | NO_OK, 0, NULL, (void*) &TypeInOK, "", NULL, EndMark , "" }
+};
+
+static int
+TypeInOK (int n)
+{
+    TypeInDoneEvent(icsText);
+    return TRUE;
+}
+
 void
 PopUpMoveDialog (char firstchar)
 {
     static char buf[2];
-    buf[0] = firstchar; icsText = buf;
-    if(GenericPopUp(boxOptions, _("Type a move"), TransientDlg))
-       AddHandler(&boxOptions[0], 2);
+    buf[0] = firstchar; ASSIGN(icsText, buf);
+    if(GenericPopUp(typeOptions, _("Type a move"), TransientDlg, BoardWindow, MODAL))
+       AddHandler(&typeOptions[0], 2);
 }
 
 void
@@ -1119,7 +1145,7 @@ void
 SettingsPopUp (ChessProgramState *cps)
 {
    currentCps = cps;
-   GenericPopUp(cps->option, _("Engine Settings"), TransientDlg);
+   GenericPopUp(cps->option, _("Engine Settings"), TransientDlg, BoardWindow, MODAL);
 }
 
 void
@@ -1150,20 +1176,20 @@ InstallOK (int n)
 }
 
 static Option installOptions[] = {
-{   0,  NO_GETTEXT, 0, NULL, (void*) &engineLine, (char*) engineMnemonic, engineList, ComboBox, N_("Select engine from list:") },
-{   0,  0,    0, NULL, NULL, NULL, NULL, Label, N_("or specify one below:") },
+{   0,  NO_GETTEXT, 0, NULL, (void*) &engineLine, (char*) engineList, engineMnemonic, ComboBox, N_("Select engine from list:") },
+{   0,  LR,   0, NULL, NULL, NULL, NULL, Label, N_("or specify one below:") },
 {   0,  0,    0, NULL, (void*) &nickName, NULL, NULL, TextBox, N_("Nickname (optional):") },
 {   0,  0,    0, NULL, (void*) &useNick, NULL, NULL, CheckBox, N_("Use nickname in PGN player tags of engine-engine games") },
 {   0,  0,    0, NULL, (void*) &engineDir, NULL, NULL, PathName, N_("Engine Directory:") },
 {   0,  0,    0, NULL, (void*) &engineName, NULL, NULL, FileName, N_("Engine Command:") },
-{   0,  0,    0, NULL, NULL, NULL, NULL, Label, N_("(Directory will be derived from engine path when empty)") },
+{   0,  LR,   0, NULL, NULL, NULL, NULL, Label, N_("(Directory will be derived from engine path when empty)") },
 {   0,  0,    0, NULL, (void*) &isUCI, NULL, NULL, CheckBox, N_("UCI") },
 {   0,  0,    0, NULL, (void*) &v1, NULL, NULL, CheckBox, N_("WB protocol v1 (do not wait for engine features)") },
 {   0,  0,    0, NULL, (void*) &hasBook, NULL, NULL, CheckBox, N_("Must not use GUI book") },
 {   0,  0,    0, NULL, (void*) &addToList, NULL, NULL, CheckBox, N_("Add this engine to the list") },
 {   0,  0,    0, NULL, (void*) &storeVariant, NULL, NULL, CheckBox, N_("Force current variant with this engine") },
 {   0,  0,    0, NULL, (void*) &engineChoice, (char*) engineNr, engineNr, ComboBox, N_("Load mentioned engine as") },
-{   0,  1,    0, NULL, (void*) &InstallOK, "", NULL, EndMark , "" }
+{ 0,SAME_ROW, 0, NULL, (void*) &InstallOK, "", NULL, EndMark , "" }
 };
 
 void
@@ -1176,7 +1202,7 @@ LoadEngineProc ()
    if(nickName)     free(nickName);     nickName = strdup("");
    if(params)       free(params);       params = strdup("");
    NamesToList(firstChessProgramNames, engineList, engineMnemonic, "all");
-   GenericPopUp(installOptions, _("Load engine"), TransientDlg);
+   GenericPopUp(installOptions, _("Load engine"), TransientDlg, BoardWindow, MODAL);
 }
 
 //----------------------------------------------------- Edit Book -----------------------------------------
@@ -1202,8 +1228,8 @@ static Option shuffleOptions[] = {
   {   0,  0,   50, NULL, (void*) &shuffleOpenings, NULL, NULL, CheckBox, N_("shuffle") },
   { 0,-1,2000000000, NULL, (void*) &appData.defaultFrcPosition, "", NULL, Spin, N_("Start-position number:") },
   {   0,  0,    0, NULL, (void*) &SetRandom, NULL, NULL, Button, N_("randomize") },
-  {   0,  1,    0, NULL, (void*) &SetRandom, NULL, NULL, Button, N_("pick fixed") },
-  {   0,  1,    0, NULL, (void*) &ShuffleOK, "", NULL, EndMark , "" }
+  {   0,  SAME_ROW,    0, NULL, (void*) &SetRandom, NULL, NULL, Button, N_("pick fixed") },
+  { 0,SAME_ROW, 0, NULL, (void*) &ShuffleOK, "", NULL, EndMark , "" }
 };
 
 static void
@@ -1219,7 +1245,7 @@ SetRandom (int n)
 void
 ShuffleMenuProc ()
 {
-    GenericPopUp(shuffleOptions, _("New Shuffle Game"), TransientDlg);
+    GenericPopUp(shuffleOptions, _("New Shuffle Game"), TransientDlg, BoardWindow, MODAL);
 }
 
 //------------------------------------------------------ Time Control -----------------------------------
@@ -1244,11 +1270,11 @@ Value (int n)
 
 static Option tcOptions[] = {
 {   0,  0,    0, NULL, (void*) &SetTcType, NULL, NULL, Button, N_("classical") },
-{   0,  1,    0, NULL, (void*) &SetTcType, NULL, NULL, Button, N_("incremental") },
-{   0,  1,    0, NULL, (void*) &SetTcType, NULL, NULL, Button, N_("fixed max") },
+{   0,SAME_ROW,0,NULL, (void*) &SetTcType, NULL, NULL, Button, N_("incremental") },
+{   0,SAME_ROW,0,NULL, (void*) &SetTcType, NULL, NULL, Button, N_("fixed max") },
 {   0,  0,  200, NULL, (void*) &tmpMoves, NULL, NULL, Spin, N_("Moves per session:") },
-{   0,  0,10000, NULL, (void*) &tmpTc, NULL, NULL, Spin, N_("Initial time (min):") },
-{   0, 0, 10000, NULL, (void*) &tmpInc, NULL, NULL, Spin, N_("Increment or max (sec/move):") },
+{   0,  0,10000, NULL, (void*) &tmpTc,    NULL, NULL, Spin, N_("Initial time (min):") },
+{   0, 0, 10000, NULL, (void*) &tmpInc,   NULL, NULL, Spin, N_("Increment or max (sec/move):") },
 {   0,  0,    0, NULL, NULL, NULL, NULL, Label, N_("Time-Odds factors:") },
 {   0,  1, 1000, NULL, (void*) &tmpOdds1, NULL, NULL, Spin, N_("Engine #1") },
 {   0,  1, 1000, NULL, (void*) &tmpOdds2, NULL, NULL, Spin, N_("Engine #2 / Human") },
@@ -1312,7 +1338,7 @@ TimeControlProc ()
    tmpInc = appData.timeIncrement; if(tmpInc < 0) tmpInc = 0;
    tmpOdds1 = tmpOdds2 = 1; tcType = 0;
    tmpTc = atoi(appData.timeControl);
-   GenericPopUp(tcOptions, _("Time Control"), TransientDlg);
+   GenericPopUp(tcOptions, _("Time Control"), TransientDlg, BoardWindow, MODAL);
 }
 
 //---------------------------- Chat Windows ----------------------------------------------