Move DisplayMessage to dialogs.c
[xboard.git] / xoptions.c
index 1c711bb..15362a5 100644 (file)
@@ -130,6 +130,16 @@ int dialogError;
 static Boolean browserUp;
 Option *dialogOptions[NrOfDialogs];
 
+static Arg layoutArgs[] = {
+    { XtNborderWidth, 0 },
+    { XtNdefaultDistance, 0 },
+};
+
+static Arg formArgs[] = {
+    { XtNborderWidth, 0 },
+    { XtNresizable, (XtArgVal) True },
+};
+
 void
 GetWidgetText (Option *opt, char **buf)
 {
@@ -387,11 +397,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
@@ -407,7 +418,8 @@ AddHandler (Option *opt, int nr)
 Widget shells[NrOfDialogs];
 DialogClass parents[NrOfDialogs];
 WindowPlacement *wp[NrOfDialogs] = { // Beware! Order must correspond to DialogClass enum
-    NULL, &wpComment, &wpTags, NULL, NULL, NULL, NULL, &wpMoveHistory, &wpGameList, &wpEngineOutput
+    NULL, &wpComment, &wpTags, NULL, NULL, NULL, NULL, &wpMoveHistory, &wpGameList, &wpEngineOutput, &wpEvalGraph,
+    NULL, NULL, NULL, NULL, &wpMain
 };
 
 int
@@ -676,6 +688,12 @@ 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;
@@ -719,6 +737,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
     XtSetArg(args[i], XtNresizable, True); i++;
     shells[BoardWindow] = shellWidget; parents[dlgNr] = parent;
 
+    if(dlgNr == BoardWindow) popup = shellWidget; else
     popup = shells[dlgNr] =
       XtCreatePopupShell(title, !top || !appData.topLevel ? transientShellWidgetClass : topLevelShellWidgetClass,
                                                            shells[parent], args, i);
@@ -726,6 +745,9 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
     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 =
@@ -733,6 +755,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;
@@ -797,7 +820,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);
@@ -805,7 +828,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);
@@ -854,7 +877,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
@@ -1030,7 +1053,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)) {
@@ -1044,16 +1067,17 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent
   }
 
     XtRealizeWidget(popup);
-    XSetWMProtocols(xDisplay, XtWindow(popup), &wm_delete_window, 1);
-    snprintf(def, MSG_SIZ, "<Message>WM_PROTOCOLS: GenericPopDown(\"%d\") \n", dlgNr);
-    XtAugmentTranslations(popup, XtParseTranslationTable(def));
-    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);
-
+    if(dlgNr != BoardWindow) { // assign close button, and position w.r.t. pointer, if not main window
+       XSetWMProtocols(xDisplay, XtWindow(popup), &wm_delete_window, 1);
+       snprintf(def, MSG_SIZ, "<Message>WM_PROTOCOLS: GenericPopDown(\"%d\") \n", dlgNr);
+       XtAugmentTranslations(popup, XtParseTranslationTable(def));
+       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, modal ? XtGrabExclusive : XtGrabNone);
     shellUp[dlgNr]++; // count rather than flag
     previous = NULL;