Use ListBox in stead of ComboBox in Load Engine dialog
[xboard.git] / dialogs.c
index af8e354..91a2e5a 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -382,7 +382,10 @@ OptionsProc ()
 
 static void Pick P((int n));
 
+static char warning[MSG_SIZ];
+
 static Option variantDescriptors[] = {
+{ 0, 0, 275, NULL, NULL, NULL, NULL, Label, warning },
 { 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")},
@@ -463,6 +466,7 @@ Pick (int n)
 void
 NewVariantProc ()
 {
+   sprintf(warning, _("All variants not supported by first engine\n(currently %s) are disabled"), first.tidy);
    GenericPopUp(variantDescriptors, _("New Variant"), TransientDlg, BoardWindow, MODAL, 0);
 }
 
@@ -890,7 +894,7 @@ IcsTextProc ()
    textOptions[i].type = EndMark;
    textOptions[i].target = NULL;
    textOptions[i].min = 2;
-   MarkMenu("ICStex", TextMenuDlg);
+   MarkMenu("View.ICStextmenu", TextMenuDlg);
    GenericPopUp(textOptions, _("ICS text menu"), TextMenuDlg, BoardWindow, NONMODAL, 1);
 }
 
@@ -937,7 +941,7 @@ NewCommentPopup (char *title, char *text, int index)
     }
     if(commentText) free(commentText); commentText = strdup(text);
     commentIndex = index;
-    MarkMenu("Show Comments", CommentDlg);
+    MarkMenu("View.Comments", CommentDlg);
     if(GenericPopUp(commentOptions, title, CommentDlg, BoardWindow, NONMODAL, 1))
        AddHandler(&commentOptions[0], 1);
 }
@@ -947,8 +951,8 @@ EditCommentProc ()
 {
     int j;
     if (PopDown(CommentDlg)) { // popdown succesful
-       MarkMenuItem("Edit Comment", False);
-       MarkMenuItem("Show Comments", False);
+//     MarkMenuItem("Edit.EditComment", False);
+//     MarkMenuItem("View.Comments", False);
     } else // was not up
        EditCommentEvent();
 }
@@ -991,7 +995,7 @@ NewTagsPopup (char *text, char *msg)
     }
     if(tagsText) free(tagsText); tagsText = strdup(text);
     tagsOptions[0].name = msg;
-    MarkMenu("Show Tags", TagsDlg);
+    MarkMenu("View.Tags", TagsDlg);
     GenericPopUp(tagsOptions, title, TagsDlg, BoardWindow, NONMODAL, 1);
 }
 
@@ -1097,7 +1101,7 @@ PutText (char *text, int pos)
 void
 ICSInputBoxPopUp ()
 {
-    MarkMenu("ICS Input Box", InputBoxDlg);
+    MarkMenu("View.ICSInputBox", InputBoxDlg);
     if(GenericPopUp(boxOptions, _("ICS input box"), InputBoxDlg, BoardWindow, NONMODAL, 0))
        AddHandler(&boxOptions[0], 3);
 }
@@ -1173,19 +1177,15 @@ SecondSettingsProc ()
 //----------------------------------------------- Load Engine --------------------------------------
 
 char *engineDir, *engineLine, *nickName, *params;
-Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick;
-static char *engineNr[] = { N_("First Engine"), N_("Second Engine"), NULL };
+Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick, secondEng;
 
-static int
-InstallOK (int n)
-{
-    PopDown(TransientDlg); // early popdown, to allow FreezeUI to instate grab
-    if(engineChoice[0] == engineNr[0][0])  Load(&first, 0); else Load(&second, 1);
-    return FALSE; // no double PopDown!
-}
+static void EngSel P((int n, int sel));
+static int InstallOK P((int n));
 
 static Option installOptions[] = {
-{   0,  NO_GETTEXT, 0, NULL, (void*) &engineLine, (char*) engineList, engineMnemonic, ComboBox, N_("Select engine from list:") },
+{   0,LR|T2T, 0, NULL, NULL, NULL, NULL, Label, N_("Select engine from list:") },
+{ 300,LR|TB,200, NULL, (void*) engineMnemonic, (char*) &EngSel, NULL, ListBox, "" },
+{ 0,SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, NULL },
 {   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") },
@@ -1197,21 +1197,51 @@ static Option installOptions[] = {
 {   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,SAME_ROW, 0, NULL, (void*) &InstallOK, "", NULL, EndMark , "" }
+{   0,  0,    0, NULL, (void*) &InstallOK, "", NULL, EndMark , "" }
 };
 
-void
-LoadEngineProc ()
+static int
+InstallOK (int n)
+{
+    if(n && (n = SelectedListBoxItem(&installOptions[1])) > 0) { // called by pressing OK, and engine selected
+       ASSIGN(engineLine, engineList[n]);
+    }
+    PopDown(TransientDlg); // early popdown, to allow FreezeUI to instate grab
+    if(!secondEng) Load(&first, 0); else Load(&second, 1);
+    return FALSE; // no double PopDown!
+}
+
+static void
+EngSel (int n, int sel)
+{
+    if(sel < 1) return;
+    ASSIGN(engineLine, engineList[sel]);
+    InstallOK(0);
+}
+
+static void
+LoadEngineProc (int engineNr, char *title)
 {
    isUCI = storeVariant = v1 = useNick = False; addToList = hasBook = True; // defaults
-   if(engineChoice) free(engineChoice); engineChoice = strdup(engineNr[0]);
+   secondEng = engineNr;
    if(engineLine)   free(engineLine);   engineLine = strdup("");
    if(engineDir)    free(engineDir);    engineDir = strdup("");
    if(nickName)     free(nickName);     nickName = strdup("");
    if(params)       free(params);       params = strdup("");
    NamesToList(firstChessProgramNames, engineList, engineMnemonic, "all");
-   GenericPopUp(installOptions, _("Load engine"), TransientDlg, BoardWindow, MODAL, 0);
+   GenericPopUp(installOptions, title, TransientDlg, BoardWindow, MODAL, 0);
+}
+
+void
+LoadEngine1Proc ()
+{
+    LoadEngineProc (0, _("Load first engine"));
+}
+
+void
+LoadEngine2Proc ()
+{
+    LoadEngineProc (1, _("Load second engine"));
 }
 
 //----------------------------------------------------- Edit Book -----------------------------------------
@@ -1918,4 +1948,35 @@ BoardPopUp (int squareSize, int lineGap, void *clockFontThingy)
     return mainOptions;
 }
 
+void
+DisplayMessage (char *message, char *extMessage)
+{
+  /* display a message in the message widget */
+
+  char buf[MSG_SIZ];
+
+  if (extMessage)
+    {
+      if (*message)
+       {
+         snprintf(buf, sizeof(buf), "%s  %s", message, extMessage);
+         message = buf;
+       }
+      else
+       {
+         message = extMessage;
+       };
+    };
+
+    safeStrCpy(lastMsg, message, MSG_SIZ); // [HGM] make available
+
+  /* need to test if messageWidget already exists, since this function
+     can also be called during the startup, if for example a Xresource
+     is not set up correctly */
+  if(mainOptions[14].handle)
+    SetWidgetLabel(&mainOptions[14], message);
+
+  return;
+}
+