Redo Engine Output window with generic popup
[xboard.git] / xoptions.c
index 99ca568..f87176e 100644 (file)
@@ -387,11 +387,12 @@ char moveTypeInTranslations[] =
     "<Key>Escape: TypeInProc(0) \n";
 extern char filterTranslations[];
 extern char gameListTranslations[];
+extern char memoTranslations[];
 
 
-char *translationTable[] = {
+char *translationTable[] = { // beware: order is essential!
    historyTranslations, commentTranslations, moveTypeInTranslations, ICSInputTranslations,
-   filterTranslations, gameListTranslations,
+   filterTranslations, gameListTranslations, memoTranslations
 };
 
 void
@@ -676,13 +677,19 @@ SetPositionAndSize (Arg *args, Widget leftNeigbor, Widget topNeigbor, int b, int
     // set size (if given)
     if(w) XtSetArg(args[j], XtNwidth, w), j++;
     if(h) XtSetArg(args[j], XtNheight, h),  j++;
+    // color
+    if(!appData.monoMode) {
+       if(!b && appData.dialogColor[0]) XtSetArg(args[j], XtNbackground, dialogColor),  j++;
+       if(b == 3 && appData.buttonColor[0]) XtSetArg(args[j], XtNbackground, buttonColor),  j++;
+       if(b == 3) b = 1;
+    }
     // border
     XtSetArg(args[j], XtNborderWidth, b);  j++;
     return j;
 }
 
 int
-GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent, int modal)
+GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent, int modal, int top)
 {
     Arg args[24];
     Widget popup, layout, dialog=NULL, edit=NULL, form,  last, b_ok, b_cancel, previousPane = NULL, textField = NULL, oldForm, oldLastRow, oldForeLast;
@@ -720,16 +727,15 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
     shells[BoardWindow] = shellWidget; parents[dlgNr] = parent;
 
     popup = shells[dlgNr] =
-#if TOPLEVEL
-      XtCreatePopupShell(title, modal ? transientShellWidgetClass : topLevelShellWidgetClass,
-#else
-      XtCreatePopupShell(title, transientShellWidgetClass,
-#endif
+      XtCreatePopupShell(title, !top || !appData.topLevel ? transientShellWidgetClass : topLevelShellWidgetClass,
                                                            shells[parent], args, i);
 
     layout =
       XtCreateManagedWidget(layoutName, formWidgetClass, popup,
                            layoutArgs, XtNumber(layoutArgs));
+    if(!appData.monoMode && appData.dialogColor[0]) XtSetArg(args[0], XtNbackground, dialogColor);
+    XtSetValues(layout, args, 1);
+
   for(c=0; c<width; c++) {
     pane[4] = 'A'+c;
     form =
@@ -737,6 +743,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
                            formArgs, XtNumber(formArgs));
     j=0;
     XtSetArg(args[j], stack ? XtNfromVert : XtNfromHoriz, previousPane);  j++;
+    if(!appData.monoMode && appData.dialogColor[0]) XtSetArg(args[j], XtNbackground, dialogColor),  j++;
     XtSetValues(form, args, j);
     lastrow = forelast = NULL;
     previousPane = form;
@@ -801,7 +808,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
            } else {
                w = 20; msg = "+"; j = textHeight/2; // spin button
            }
-           j = SetPositionAndSize(args, last, edit, 1 /* border */,
+           j = SetPositionAndSize(args, last, edit, 3 /* border */,
                                   w /* w */, j /* h */, 0x31 /* chain to right edge */);
            edit = XtCreateManagedWidget(msg, commandWidgetClass, form, args, j);
            XtAddCallback(edit, XtNcallback, SpinCallback, (XtPointer)(intptr_t) i + 256*dlgNr);
@@ -809,7 +816,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
 
            if(option[i].type != Spin) break;
 
-           j = SetPositionAndSize(args, last, edit, 1 /* border */,
+           j = SetPositionAndSize(args, last, edit, 3 /* border */,
                                   20 /* w */, textHeight/2 /* h */, 0x31 /* chain to right edge */);
            XtSetArg(args[j], XtNvertDistance, -1);  j++;
            last = XtCreateManagedWidget("-", commandWidgetClass, form, args, j);
@@ -858,7 +865,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
                chain = 0x31; // 0011.0001 = both left and right side to right edge
                forelast = lastrow;
            } else chain = 0, shrink = FALSE;
-           j = SetPositionAndSize(args, last, lastrow, 1 /* border */,
+           j = SetPositionAndSize(args, last, lastrow, 3 /* border */,
                                   option[i].max /* w */, shrink ? textHeight : 0 /* h */, chain /* chain */);
            XtSetArg(args[j], XtNlabel, _(option[i].name));  j++;
            if(option[i].textValue) { // special for buttons of New Variant dialog
@@ -1034,7 +1041,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
        }
        lastrow = forelast;
     } else shrink = FALSE, lastrow = last, last = widest ? widest : dialog;
-    j = SetPositionAndSize(args, last, anchor ? anchor : lastrow, 1 /* border */,
+    j = SetPositionAndSize(args, last, anchor ? anchor : lastrow, 3 /* border */,
                           0 /* w */, shrink ? textHeight : 0 /* h */, 0x37 /* chain: right, bottom and use both neighbors */);
 
   if(!(option[i].min & NO_OK)) {