GenericPopUp(tcOptions, _("Time Control"), TransientDlg, BoardWindow, MODAL);
}
+//------------------------------- Ask Question -----------------------------------------
+
+int SendReply P((int n));
+char pendingReplyPrefix[MSG_SIZ];
+ProcRef pendingReplyPR;
+char *answer;
+
+Option askOptions[] = {
+{ 0, 0, 0, NULL, NULL, NULL, NULL, Label, NULL },
+{ 0, 0, 0, NULL, (void*) &answer, "", NULL, TextBox, "" },
+{ 0, 0, 0, NULL, (void*) &SendReply, "", NULL, EndMark , "" }
+};
+
+int
+SendReply (int n)
+{
+ char buf[MSG_SIZ];
+ int err;
+ char *reply=answer;
+// GetWidgetText(&askOptions[1], &reply);
+ safeStrCpy(buf, pendingReplyPrefix, sizeof(buf)/sizeof(buf[0]) );
+ if (*buf) strncat(buf, " ", MSG_SIZ - strlen(buf) - 1);
+ strncat(buf, reply, MSG_SIZ - strlen(buf) - 1);
+ strncat(buf, "\n", MSG_SIZ - strlen(buf) - 1);
+ OutputToProcess(pendingReplyPR, buf, strlen(buf), &err); // does not go into debug file??? => bug
+ if (err) DisplayFatalError(_("Error writing to chess program"), err, 0);
+ return TRUE;
+}
+
+void
+AskQuestion (char *title, char *question, char *replyPrefix, ProcRef pr)
+{
+ safeStrCpy(pendingReplyPrefix, replyPrefix, sizeof(pendingReplyPrefix)/sizeof(pendingReplyPrefix[0]) );
+ pendingReplyPR = pr;
+ ASSIGN(answer, "");
+ askOptions[0].name = question;
+ if(GenericPopUp(askOptions, title, AskDlg, BoardWindow, MODAL))
+ AddHandler(&askOptions[1], 2);
+}
+
//---------------------------- Chat Windows ----------------------------------------------
void
void ICSInputBoxPopUp P((void));
void FileNamePopUp P((char *label, char *def, char *filter,
FileProc proc, char *openMode));
-void AskQuestionReplyAction P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
-void AskQuestionPopDown P((void));
void PromotionPopDown P((void));
void PromotionCallback P((Widget w, XtPointer client_data,
XtPointer call_data));
whiteTimerWidget, blackTimerWidget, titleWidget, widgetList[16],
commentShell, promotionShell, whitePieceMenu, blackPieceMenu, dropMenu,
menuBarWidget, buttonBarWidget, editShell, errorShell, analysisShell,
- ICSInputShell, fileNameShell, askQuestionShell;
+ ICSInputShell, fileNameShell;
Widget historyShell, evalGraphShell, gameListShell;
XSegment secondSegments[BOARD_RANKS + BOARD_FILES + 2];
XSegment gridSegments[BOARD_RANKS + BOARD_FILES + 2];
int smallLayout = 0, tinyLayout = 0,
marginW, marginH, // [HGM] for run-time resizing
fromX = -1, fromY = -1, toX, toY, commentUp = False, analysisUp = False,
- ICSInputBoxUp = False, askQuestionUp = False,
+ ICSInputBoxUp = False,
filenameUp = False, promotionUp = False, pmFromX = -1, pmFromY = -1,
errorUp = False, errorExitStatus = -1, defaultLineGap;
Dimension textHeight;
{ "HandlePV", HandlePV },
{ "SelectPV", SelectPV },
{ "StopPV", StopPV },
- { "AskQuestionReplyAction", AskQuestionReplyAction },
{ "PieceMenuPopup", PieceMenuPopup },
{ "WhiteClock", WhiteClock },
{ "BlackClock", BlackClock },
{ "TempForwardProc", TempForwardProc },
{ "CommentClick", (XtActionProc) CommentClick },
{ "ErrorPopDown", (XtActionProc) ErrorPopDown },
- { "AskQuestionPopDown", (XtActionProc) AskQuestionPopDown },
{ "GameListPopDown", (XtActionProc) GameListPopDown },
{ "GameListOptionsPopDown", (XtActionProc) GameListOptionsPopDown },
{ "PromotionPopDown", (XtActionProc) PromotionPopDown },
char commentTranslations[] = "<Btn3Down>: extend-end() select-start() CommentClick() \n";
String xboardResources[] = {
- "*question*value.translations: #override\\n <Key>Return: AskQuestionReplyAction()",
"*errorpopup*translations: #override\\n <Key>Return: ErrorPopDown()",
NULL
};
fflush(stdout);
}
-char pendingReplyPrefix[MSG_SIZ];
-ProcRef pendingReplyPR;
-
-void
-AskQuestionPopDown ()
-{
- if (!askQuestionUp) return;
- XtPopdown(askQuestionShell);
- XtDestroyWidget(askQuestionShell);
- askQuestionUp = False;
-}
-
-void
-AskQuestionReplyAction (Widget w, XEvent *event, String *prms, Cardinal *nprms)
-{
- char buf[MSG_SIZ];
- int err;
- String reply;
-
- reply = XawDialogGetValueString(w = XtParent(w));
- safeStrCpy(buf, pendingReplyPrefix, sizeof(buf)/sizeof(buf[0]) );
- if (*buf) strncat(buf, " ", MSG_SIZ - strlen(buf) - 1);
- strncat(buf, reply, MSG_SIZ - strlen(buf) - 1);
- strncat(buf, "\n", MSG_SIZ - strlen(buf) - 1);
- OutputToProcess(pendingReplyPR, buf, strlen(buf), &err);
- AskQuestionPopDown();
-
- if (err) DisplayFatalError(_("Error writing to chess program"), err, 0);
-}
-
-void
-AskQuestionCallback (Widget w, XtPointer client_data, XtPointer call_data)
-{
- String name;
- Arg args[16];
-
- XtSetArg(args[0], XtNlabel, &name);
- XtGetValues(w, args, 1);
-
- if (strcmp(name, _("cancel")) == 0) {
- AskQuestionPopDown();
- } else {
- AskQuestionReplyAction(w, NULL, NULL, NULL);
- }
-}
-
-void
-AskQuestion (char *title, char *question, char *replyPrefix, ProcRef pr)
-{
- Arg args[16];
- Widget popup, layout, dialog, edit;
- Window root, child;
- int x, y, i;
- int win_x, win_y;
- unsigned int mask;
-
- safeStrCpy(pendingReplyPrefix, replyPrefix, sizeof(pendingReplyPrefix)/sizeof(pendingReplyPrefix[0]) );
- pendingReplyPR = pr;
-
- i = 0;
- XtSetArg(args[i], XtNresizable, True); i++;
- XtSetArg(args[i], XtNwidth, DIALOG_SIZE); i++;
- askQuestionShell = popup =
- XtCreatePopupShell(title, transientShellWidgetClass,
- shellWidget, args, i);
-
- layout =
- XtCreateManagedWidget(layoutName, formWidgetClass, popup,
- layoutArgs, XtNumber(layoutArgs));
-
- i = 0;
- XtSetArg(args[i], XtNlabel, question); i++;
- XtSetArg(args[i], XtNvalue, ""); i++;
- XtSetArg(args[i], XtNborderWidth, 0); i++;
- dialog = XtCreateManagedWidget("question", dialogWidgetClass,
- layout, args, i);
-
- XawDialogAddButton(dialog, _("enter"), AskQuestionCallback,
- (XtPointer) dialog);
- XawDialogAddButton(dialog, _("cancel"), AskQuestionCallback,
- (XtPointer) dialog);
-
- XtRealizeWidget(popup);
- CatchDeleteWindow(popup, "AskQuestionPopDown");
-
- 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, XtGrabExclusive);
- askQuestionUp = True;
-
- edit = XtNameToWidget(dialog, "*value");
- XtSetKeyboardFocus(popup, edit);
-}
-
XtIntervalId delayedEventTimerXID = 0;
DelayedEventCallback delayedEventCallback = 0;