2 * menus.c -- platform-indendent menu handling code for XBoard
4 * Copyright 1991 by Digital Equipment Corporation, Maynard,
7 * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
8 * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
10 * The following terms apply to Digital Equipment Corporation's copyright
12 * ------------------------------------------------------------------------
15 * Permission to use, copy, modify, and distribute this software and its
16 * documentation for any purpose and without fee is hereby granted,
17 * provided that the above copyright notice appear in all copies and that
18 * both that copyright notice and this permission notice appear in
19 * supporting documentation, and that the name of Digital not be
20 * used in advertising or publicity pertaining to distribution of the
21 * software without specific, written prior permission.
23 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
24 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
25 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
26 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
27 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
28 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
30 * ------------------------------------------------------------------------
32 * The following terms apply to the enhanced version of XBoard
33 * distributed by the Free Software Foundation:
34 * ------------------------------------------------------------------------
36 * GNU XBoard is free software: you can redistribute it and/or modify
37 * it under the terms of the GNU General Public License as published by
38 * the Free Software Foundation, either version 3 of the License, or (at
39 * your option) any later version.
41 * GNU XBoard is distributed in the hope that it will be useful, but
42 * WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44 * General Public License for more details.
46 * You should have received a copy of the GNU General Public License
47 * along with this program. If not, see http://www.gnu.org/licenses/. *
49 *------------------------------------------------------------------------
50 ** See the file ChangeLog for a revision history. */
60 #include <sys/types.h>
68 #else /* not STDC_HEADERS */
69 extern char *getenv();
72 # else /* not HAVE_STRING_H */
74 # endif /* not HAVE_STRING_H */
75 #endif /* not STDC_HEADERS */
85 // [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
93 #include "xedittags.h"
98 # define _(s) gettext (s)
99 # define N_(s) gettext_noop (s)
106 * Button/menu procedures
109 char *gameCopyFilename, *gamePasteFilename;
110 Boolean saveSettingsOnExit;
111 char *settingsFileName;
116 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
119 FileNamePopUp(_("Load game file name?"), "", ".pgn .game", LoadGamePopUp, "rb");
141 LoadNextPositionProc ()
147 LoadPrevPositionProc ()
153 ReloadPositionProc ()
161 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
164 FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb");
170 FileNamePopUp(_("Save game file name?"),
171 DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"),
172 appData.oldSaveStyle ? ".game" : ".pgn",
179 FileNamePopUp(_("Save position file name?"),
180 DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"),
181 appData.oldSaveStyle ? ".pos" : ".fen",
186 ReloadCmailMsgProc ()
188 ReloadCmailMsgEvent(FALSE);
192 CopyFENToClipboard ()
193 { // wrapper to make call from back-end possible
200 static char *selected_fen_position=NULL;
201 if(gameMode == EditPosition) EditPositionDone(TRUE);
202 if (selected_fen_position) free(selected_fen_position);
203 selected_fen_position = (char *)PositionToFEN(currentMove, NULL);
204 if (!selected_fen_position) return;
205 CopySomething(selected_fen_position);
213 ret = SaveGameToFile(gameCopyFilename, FALSE);
222 if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return;
244 if (!first.analysisSupport) {
245 snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
246 DisplayError(buf, 0);
249 /* [DM] icsEngineAnalyze [HGM] This is horrible code; reverse the gameMode and isEngineAnalyze tests! */
250 if (appData.icsActive) {
251 if (gameMode != IcsObserving) {
252 snprintf(buf, MSG_SIZ, _("You are not observing a game"));
253 DisplayError(buf, 0);
255 if (appData.icsEngineAnalyze) {
256 if (appData.debugMode)
257 fprintf(debugFP, _("Found unexpected active ICS engine analyze \n"));
263 /* if enable, use want disable icsEngineAnalyze */
264 if (appData.icsEngineAnalyze) {
269 appData.icsEngineAnalyze = TRUE;
270 if (appData.debugMode)
271 fprintf(debugFP, _("ICS engine analyze starting... \n"));
273 #ifndef OPTIONSDIALOG
274 if (!appData.showThinking)
284 if (!first.analysisSupport) {
286 snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
287 DisplayError(buf, 0);
290 // Reset(FALSE, TRUE);
291 #ifndef OPTIONSDIALOG
292 if (!appData.showThinking)
296 // FileNamePopUp(_("File to analyze"), "", ".pgn .game", LoadGamePopUp, "rb");
297 AnalysisPeriodicEvent(1);
309 UserAdjudicationEvent(+1);
315 UserAdjudicationEvent(-1);
321 UserAdjudicationEvent(0);
339 flipView = !flipView;
340 DrawPosition(True, NULL);
348 saveSettingsOnExit = !saveSettingsOnExit;
350 MarkMenuItem("Save Settings on Exit", saveSettingsOnExit);
356 SaveSettings(settingsFileName);
363 snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
370 { // called from menu
371 ManInner(NULL, NULL, NULL, NULL);
378 snprintf(buf, MSG_SIZ, "%s mailto:bug-xboard@gnu.org", appData.sysOpen);
386 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/user_guide/UserGuide.html", appData.sysOpen);
394 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/", appData.sysOpen);
402 snprintf(buf, MSG_SIZ, "%s http://www.gnu.org/software/xboard/whats_new/portal.html", appData.sysOpen);
409 char buf[2 * MSG_SIZ];
411 char *zippy = _(" (with Zippy code)");
415 snprintf(buf, sizeof(buf),
417 "Copyright 1991 Digital Equipment Corporation\n"
418 "Enhancements Copyright 1992-2012 Free Software Foundation\n"
419 "Enhancements Copyright 2005 Alessandro Scotti\n\n"
420 "%s is free software and carries NO WARRANTY;"
421 "see the file COPYING for more information.\n\n"
422 "Visit XBoard on the web at: http://www.gnu.org/software/xboard/\n"
423 "Check out the newest features at: http://www.gnu.org/software/xboard/whats_new.html\n\n"
424 "Report bugs via email at: <bug-xboard@gnu.org>\n\n"
426 programVersion, zippy, PACKAGE);
427 ErrorPopUp(_("About XBoard"), buf, FALSE);
433 appData.debugMode = !appData.debugMode;
443 # define MARK_MENU_ITEM(X,Y)
445 # define MARK_MENU_ITEM(X,Y) MarkMenuItem(X, Y)
449 PonderNextMoveProc ()
453 PonderNextMoveEvent(!appData.ponderNextMove);
454 MARK_MENU_ITEM("Ponder Next Move", appData.ponderNextMove);
460 appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen;
461 MARK_MENU_ITEM("Always Queen", appData.alwaysPromoteToQueen);
465 AnimateDraggingProc ()
467 appData.animateDragging = !appData.animateDragging;
469 if (appData.animateDragging) CreateAnimVars();
470 MARK_MENU_ITEM("Animate Dragging", appData.animateDragging);
476 appData.animate = !appData.animate;
477 if (appData.animate) CreateAnimVars();
478 MARK_MENU_ITEM("Animate Moving", appData.animate);
484 appData.autoCallFlag = !appData.autoCallFlag;
485 MARK_MENU_ITEM("Auto Flag", appData.autoCallFlag);
491 appData.autoFlipView = !appData.autoFlipView;
492 MARK_MENU_ITEM("Auto Flip View", appData.autoFlipView);
498 appData.blindfold = !appData.blindfold;
499 MARK_MENU_ITEM("Blindfold", appData.blindfold);
500 DrawPosition(True, NULL);
506 appData.testLegality = !appData.testLegality;
507 MARK_MENU_ITEM("Test Legality", appData.testLegality);
514 if (appData.flashCount == 0) {
515 appData.flashCount = 3;
517 appData.flashCount = -appData.flashCount;
519 MARK_MENU_ITEM("Flash Moves", appData.flashCount > 0);
524 HighlightDraggingProc ()
526 appData.highlightDragging = !appData.highlightDragging;
527 MARK_MENU_ITEM("Highlight Dragging", appData.highlightDragging);
532 HighlightLastMoveProc ()
534 appData.highlightLastMove = !appData.highlightLastMove;
535 MARK_MENU_ITEM("Highlight Last Move", appData.highlightLastMove);
539 HighlightArrowProc ()
541 appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow;
542 MARK_MENU_ITEM("Arrow", appData.highlightMoveWithArrow);
548 appData.icsAlarm = !appData.icsAlarm;
549 // MARK_MENU_ITEM("ICS Alarm", appData.icsAlarm);
555 appData.ringBellAfterMoves = !appData.ringBellAfterMoves;
556 MARK_MENU_ITEM("Move Sound", appData.ringBellAfterMoves);
562 appData.oneClick = !appData.oneClick;
563 MARK_MENU_ITEM("OneClick", appData.oneClick);
567 PeriodicUpdatesProc ()
569 PeriodicUpdatesEvent(!appData.periodicUpdates);
570 MARK_MENU_ITEM("Periodic Updates", appData.periodicUpdates);
574 PopupExitMessageProc ()
576 appData.popupExitMessage = !appData.popupExitMessage;
577 MARK_MENU_ITEM("Popup Exit Message", appData.popupExitMessage);
581 PopupMoveErrorsProc ()
583 appData.popupMoveErrors = !appData.popupMoveErrors;
584 MARK_MENU_ITEM("Popup Move Errors", appData.popupMoveErrors);
590 appData.premove = !appData.premove;
591 // MARK_MENU_ITEM("Premove", appData.premove);
597 appData.showCoords = !appData.showCoords;
598 MARK_MENU_ITEM("Show Coords", appData.showCoords);
599 DrawPosition(True, NULL);
605 appData.showThinking = !appData.showThinking; // [HGM] thinking: taken out of ShowThinkingEvent
614 appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent
617 MARK_MENU_ITEM("Hide Thinking", appData.hideThinkingFromHuman);
621 * Menu definition tables
624 MenuItem fileMenu[] = {
625 {N_("New Game Ctrl+N"), "New Game", ResetGameEvent},
626 {N_("New Shuffle Game ..."), "New Shuffle Game", ShuffleMenuProc},
627 {N_("New Variant ... Alt+Shift+V"), "New Variant", NewVariantProc}, // [HGM] variant: not functional yet
628 {"----", NULL, NothingProc},
629 {N_("Load Game Ctrl+O"), "Load Game", LoadGameProc},
630 {N_("Load Position Ctrl+Shift+O"), "Load Position", LoadPositionProc},
631 // {N_("Load Next Game"), "Load Next Game", LoadNextGameProc},
632 // {N_("Load Previous Game"), "Load Previous Game", LoadPrevGameProc},
633 // {N_("Reload Same Game"), "Reload Same Game", ReloadGameProc},
634 {N_("Next Position Shift+PgDn"), "Load Next Position", LoadNextPositionProc},
635 {N_("Prev Position Shift+PgUp"), "Load Previous Position", LoadPrevPositionProc},
636 {"----", NULL, NothingProc},
637 // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc},
638 {N_("Save Game Ctrl+S"), "Save Game", SaveGameProc},
639 {N_("Save Position Ctrl+Shift+S"), "Save Position", SavePositionProc},
640 {"----", NULL, NothingProc},
641 {N_("Mail Move"), "Mail Move", MailMoveEvent},
642 {N_("Reload CMail Message"), "Reload CMail Message", ReloadCmailMsgProc},
643 {"----", NULL, NothingProc},
644 {N_("Quit Ctr+Q"), "Exit", QuitProc},
648 MenuItem editMenu[] = {
649 {N_("Copy Game Ctrl+C"), "Copy Game", CopyGameProc},
650 {N_("Copy Position Ctrl+Shift+C"), "Copy Position", CopyPositionProc},
651 {N_("Copy Game List"), "Copy Game List", CopyGameListProc},
652 {"----", NULL, NothingProc},
653 {N_("Paste Game Ctrl+V"), "Paste Game", PasteGameProc},
654 {N_("Paste Position Ctrl+Shift+V"), "Paste Position", PastePositionProc},
655 {"----", NULL, NothingProc},
656 {N_("Edit Game Ctrl+E"), "Edit Game 2", EditGameEvent},
657 {N_("Edit Position Ctrl+Shift+E"), "Edit Position 2", EditPositionEvent},
658 {N_("Edit Tags"), "Edit Tags", EditTagsProc},
659 {N_("Edit Comment"), "Edit Comment", EditCommentProc},
660 {N_("Edit Book"), "Edit Book", EditBookEvent},
661 {"----", NULL, NothingProc},
662 {N_("Revert Home"), "Revert", RevertProc},
663 {N_("Annotate"), "Annotate", AnnotateProc},
664 {N_("Truncate Game End"), "Truncate Game", TruncateGameEvent},
665 {"----", NULL, NothingProc},
666 {N_("Backward Alt+Left"), "Backward", BackwardEvent},
667 {N_("Forward Alt+Right"), "Forward", ForwardEvent},
668 {N_("Back to Start Alt+Home"), "Back to Start", ToStartEvent},
669 {N_("Forward to End Alt+End"), "Forward to End", ToEndEvent},
673 MenuItem viewMenu[] = {
674 {N_("Flip View F2"), "Flip View", FlipViewProc},
675 {"----", NULL, NothingProc},
676 {N_("Engine Output Alt+Shift+O"), "Show Engine Output", EngineOutputProc},
677 {N_("Move History Alt+Shift+H"), "Show Move History", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code
678 {N_("Evaluation Graph Alt+Shift+E"), "Show Evaluation Graph", EvalGraphProc},
679 {N_("Game List Alt+Shift+G"), "Show Game List", ShowGameListProc},
680 {N_("ICS text menu"), "ICStex", IcsTextProc},
681 {"----", NULL, NothingProc},
682 {N_("Tags"), "Show Tags", EditTagsProc},
683 {N_("Comments"), "Show Comments", EditCommentProc},
684 {N_("ICS Input Box"), "ICS Input Box", IcsInputBoxProc},
685 {"----", NULL, NothingProc},
686 {N_("Board..."), "Board Options", BoardOptionsProc},
687 {N_("Game List Tags..."), "Game List", GameListOptionsProc},
691 MenuItem modeMenu[] = {
692 {N_("Machine White Ctrl+W"), "Machine White", MachineWhiteEvent},
693 {N_("Machine Black Ctrl+B"), "Machine Black", MachineBlackEvent},
694 {N_("Two Machines Ctrl+T"), "Two Machines", TwoMachinesEvent},
695 {N_("Analysis Mode Ctrl+A"), "Analysis Mode", AnalyzeModeProc},
696 {N_("Analyze Game Ctrl+G"), "Analyze File", AnalyzeFileProc },
697 {N_("Edit Game Ctrl+E"), "Edit Game", EditGameEvent},
698 {N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionEvent},
699 {N_("Training"), "Training", TrainingEvent},
700 {N_("ICS Client"), "ICS Client", IcsClientEvent},
701 {"----", NULL, NothingProc},
702 {N_("Machine Match"), "Machine Match", MatchProc},
703 {N_("Pause Pause"), "Pause", PauseEvent},
707 MenuItem actionMenu[] = {
708 {N_("Accept F3"), "Accept", AcceptEvent},
709 {N_("Decline F4"), "Decline", DeclineEvent},
710 {N_("Rematch F12"), "Rematch", RematchEvent},
711 {"----", NULL, NothingProc},
712 {N_("Call Flag F5"), "Call Flag", CallFlagEvent},
713 {N_("Draw F6"), "Draw", DrawEvent},
714 {N_("Adjourn F7"), "Adjourn", AdjournEvent},
715 {N_("Abort F8"),"Abort", AbortEvent},
716 {N_("Resign F9"), "Resign", ResignEvent},
717 {"----", NULL, NothingProc},
718 {N_("Stop Observing F10"), "Stop Observing", StopObservingEvent},
719 {N_("Stop Examining F11"), "Stop Examining", StopExaminingEvent},
720 {N_("Upload to Examine"), "Upload to Examine", UploadGameEvent},
721 {"----", NULL, NothingProc},
722 {N_("Adjudicate to White"), "Adjudicate to White", AdjuWhiteProc},
723 {N_("Adjudicate to Black"), "Adjudicate to Black", AdjuBlackProc},
724 {N_("Adjudicate Draw"), "Adjudicate Draw", AdjuDrawProc},
728 MenuItem engineMenu[] = {
729 {N_("Load New Engine ..."), "Load Engine", LoadEngineProc},
730 {"----", NULL, NothingProc},
731 {N_("Engine #1 Settings ..."), "Engine #1 Settings", FirstSettingsProc},
732 {N_("Engine #2 Settings ..."), "Engine #2 Settings", SecondSettingsProc},
733 {"----", NULL, NothingProc},
734 {N_("Hint"), "Hint", HintEvent},
735 {N_("Book"), "Book", BookEvent},
736 {"----", NULL, NothingProc},
737 {N_("Move Now Ctrl+M"), "Move Now", MoveNowEvent},
738 {N_("Retract Move Ctrl+X"), "Retract Move", RetractMoveEvent},
742 MenuItem optionsMenu[] = {
744 {N_("General ..."), "General", OptionsProc},
746 {N_("Time Control ... Alt+Shift+T"), "Time Control", TimeControlProc},
747 {N_("Common Engine ... Alt+Shift+U"), "Common Engine", UciMenuProc},
748 {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc},
749 {N_("ICS ..."), "ICS", IcsOptionsProc},
750 {N_("Match ..."), "Match", MatchOptionsProc},
751 {N_("Load Game ..."), "Load Game", LoadOptionsProc},
752 {N_("Save Game ..."), "Save Game", SaveOptionsProc},
753 // {N_(" ..."), "", OptionsProc},
754 {N_("Game List ..."), "Game List", GameListOptionsProc},
755 {N_("Sounds ..."), "Sounds", SoundOptionsProc},
756 {"----", NULL, NothingProc},
757 #ifndef OPTIONSDIALOG
758 {N_("Always Queen Ctrl+Shift+Q"), "Always Queen", AlwaysQueenProc},
759 {N_("Animate Dragging"), "Animate Dragging", AnimateDraggingProc},
760 {N_("Animate Moving Ctrl+Shift+A"), "Animate Moving", AnimateMovingProc},
761 {N_("Auto Flag Ctrl+Shift+F"), "Auto Flag", AutoflagProc},
762 {N_("Auto Flip View"), "Auto Flip View", AutoflipProc},
763 {N_("Blindfold"), "Blindfold", BlindfoldProc},
764 {N_("Flash Moves"), "Flash Moves", FlashMovesProc},
766 {N_("Highlight Dragging"), "Highlight Dragging", HighlightDraggingProc},
768 {N_("Highlight Last Move"), "Highlight Last Move", HighlightLastMoveProc},
769 {N_("Highlight With Arrow"), "Arrow", HighlightArrowProc},
770 {N_("Move Sound"), "Move Sound", MoveSoundProc},
771 // {N_("ICS Alarm"), "ICS Alarm", IcsAlarmProc},
772 {N_("One-Click Moving"), "OneClick", OneClickProc},
773 {N_("Periodic Updates"), "Periodic Updates", PeriodicUpdatesProc},
774 {N_("Ponder Next Move Ctrl+Shift+P"), "Ponder Next Move", PonderNextMoveProc},
775 {N_("Popup Exit Message"), "Popup Exit Message", PopupExitMessageProc},
776 {N_("Popup Move Errors"), "Popup Move Errors", PopupMoveErrorsProc},
777 // {N_("Premove"), "Premove", PremoveProc},
778 {N_("Show Coords"), "Show Coords", ShowCoordsProc},
779 {N_("Hide Thinking Ctrl+Shift+H"), "Hide Thinking", HideThinkingProc},
780 {N_("Test Legality Ctrl+Shift+L"), "Test Legality", TestLegalityProc},
781 {"----", NULL, NothingProc},
783 {N_("Save Settings Now"), "Save Settings Now", SaveSettingsProc},
784 {N_("Save Settings on Exit"), "Save Settings on Exit", SaveOnExitProc},
788 MenuItem helpMenu[] = {
789 {N_("Info XBoard"), "Info XBoard", InfoProc},
790 {N_("Man XBoard F1"), "Man XBoard", ManProc},
791 {"----", NULL, NothingProc},
792 {N_("XBoard Home Page"), "Home Page", HomePageProc},
793 {N_("On-line User Guide"), "User Guide", GuideProc},
794 {N_("Development News"), "News Page", NewsPageProc},
795 {N_("e-Mail Bug Report"), "Bug Report", BugReportProc},
796 {"----", NULL, NothingProc},
797 {N_("About XBoard"), "About XBoard", AboutProc},
802 {N_("File"), "File", fileMenu},
803 {N_("Edit"), "Edit", editMenu},
804 {N_("View"), "View", viewMenu},
805 {N_("Mode"), "Mode", modeMenu},
806 {N_("Action"), "Action", actionMenu},
807 {N_("Engine"), "Engine", engineMenu},
808 {N_("Options"), "Options", optionsMenu},
809 {N_("Help"), "Help", helpMenu},
814 MenuToNumber(char *menuName)
817 for(i=0; i<nrOfMenuItems; i++)
818 if(!strcmp(menuName, menuItemList[i].name)) return i;
823 AppendEnginesToMenu (char *list)
828 if(appData.icsActive || appData.recentEngines <= 0) return;
829 recentEngines = strdup(list);
831 p = strchr(list, '\n'); if(p == NULL) break;
832 if(i == 0) AppendMenuItem("----", "----", NULL); // at least one valid item to add
834 AppendMenuItem(list, "recent", (MenuProc *) i);
835 i++; *p = '\n'; list = p + 1;
840 AddPullDownMenu (char *name, Menu *mb)
844 CreateMenuButton(name, mb);
847 while (mi->string != NULL) {
848 AppendMenuItem(mi->string, mi->ref, mi->proc);
849 menuItemList[nrOfMenuItems].name = mi->ref;
850 menuItemList[nrOfMenuItems].proc = mi->proc;
851 if(strcmp(mi->string, "----")) nrOfMenuItems++;
855 if(!strcmp(mb->name, "Engine")) AppendEnginesToMenu(appData.recentEngineList);
859 CreateMainMenus (Menu *mb)
861 char menuName[MSG_SIZ];
863 while(menuItemList[nrOfMenuItems].name) nrOfMenuItems++; // skip any predefined items
865 while (mb->name != NULL) {
866 safeStrCpy(menuName, "menu", sizeof(menuName)/sizeof(menuName[0]) );
867 strncat(menuName, mb->ref, MSG_SIZ - strlen(menuName) - 1);
868 AddPullDownMenu(menuName, mb++);
872 Enables icsEnables[] = {
873 { "Mail Move", False },
874 { "Reload CMail Message", False },
875 { "Machine Black", False },
876 { "Machine White", False },
877 { "Analysis Mode", False },
878 { "Analyze File", False },
879 { "Two Machines", False },
880 { "Machine Match", False },
884 { "Move Now", False },
885 #ifndef OPTIONSDIALOG
886 { "Periodic Updates", False },
887 { "Hide Thinking", False },
888 { "Ponder Next Move", False },
891 { "Engine #1 Settings", False },
892 { "Engine #2 Settings", False },
893 { "Load Engine", False },
894 { "Annotate", False },
899 Enables ncpEnables[] = {
900 { "Mail Move", False },
901 { "Reload CMail Message", False },
902 { "Machine White", False },
903 { "Machine Black", False },
904 { "Analysis Mode", False },
905 { "Analyze File", False },
906 { "Two Machines", False },
907 { "Machine Match", False },
908 { "ICS Client", False },
910 { "ICS Input Box", False },
913 { "Annotate", False },
914 { "Engine #1 Settings", False },
915 { "Engine #2 Settings", False },
916 { "Move Now", False },
917 { "Retract Move", False },
919 #ifndef OPTIONSDIALOG
920 { "Auto Flag", False },
921 { "Auto Flip View", False },
922 // { "ICS Alarm", False },
923 { "Move Sound", False },
924 { "Hide Thinking", False },
925 { "Periodic Updates", False },
926 { "Ponder Next Move", False },
933 Enables gnuEnables[] = {
934 { "ICS Client", False },
936 { "ICS Input Box", False },
938 { "Decline", False },
939 { "Rematch", False },
940 { "Adjourn", False },
941 { "Stop Examining", False },
942 { "Stop Observing", False },
943 { "Upload to Examine", False },
945 { "Annotate", False },
948 /* The next two options rely on SetCmailMode being called *after* */
949 /* SetGNUMode so that when GNU is being used to give hints these */
950 /* menu options are still available */
952 { "Mail Move", False },
953 { "Reload CMail Message", False },
954 // [HGM] The following have been added to make a switch from ncp to GNU mode possible
955 { "Machine White", True },
956 { "Machine Black", True },
957 { "Analysis Mode", True },
958 { "Analyze File", True },
959 { "Two Machines", True },
960 { "Machine Match", True },
961 { "Engine #1 Settings", True },
962 { "Engine #2 Settings", True },
965 { "Move Now", True },
966 { "Retract Move", True },
971 Enables cmailEnables[] = {
973 { "Call Flag", False },
975 { "Adjourn", False },
977 { "Stop Observing", False },
978 { "Stop Examining", False },
979 { "Mail Move", True },
980 { "Reload CMail Message", True },
984 Enables trainingOnEnables[] = {
985 { "Edit Comment", False },
987 { "Forward", False },
988 { "Backward", False },
989 { "Forward to End", False },
990 { "Back to Start", False },
991 { "Move Now", False },
992 { "Truncate Game", False },
996 Enables trainingOffEnables[] = {
997 { "Edit Comment", True },
1000 { "Backward", True },
1001 { "Forward to End", True },
1002 { "Back to Start", True },
1003 { "Move Now", True },
1004 { "Truncate Game", True },
1008 Enables machineThinkingEnables[] = {
1009 { "Load Game", False },
1010 // { "Load Next Game", False },
1011 // { "Load Previous Game", False },
1012 // { "Reload Same Game", False },
1013 { "Paste Game", False },
1014 { "Load Position", False },
1015 // { "Load Next Position", False },
1016 // { "Load Previous Position", False },
1017 // { "Reload Same Position", False },
1018 { "Paste Position", False },
1019 { "Machine White", False },
1020 { "Machine Black", False },
1021 { "Two Machines", False },
1022 // { "Machine Match", False },
1023 { "Retract Move", False },
1027 Enables userThinkingEnables[] = {
1028 { "Load Game", True },
1029 // { "Load Next Game", True },
1030 // { "Load Previous Game", True },
1031 // { "Reload Same Game", True },
1032 { "Paste Game", True },
1033 { "Load Position", True },
1034 // { "Load Next Position", True },
1035 // { "Load Previous Position", True },
1036 // { "Reload Same Position", True },
1037 { "Paste Position", True },
1038 { "Machine White", True },
1039 { "Machine Black", True },
1040 { "Two Machines", True },
1041 // { "Machine Match", True },
1042 { "Retract Move", True },
1049 SetMenuEnables(icsEnables);
1052 if (appData.zippyPlay && !appData.noChessProgram) { /* [DM] icsEngineAnalyze */
1053 EnableMenuItem("Analysis Mode", True);
1054 EnableMenuItem("Engine #1 Settings", True);
1062 SetMenuEnables(ncpEnables);
1068 SetMenuEnables(gnuEnables);
1074 SetMenuEnables(cmailEnables);
1078 SetTrainingModeOn ()
1080 SetMenuEnables(trainingOnEnables);
1081 if (appData.showButtonBar) {
1082 EnableButtonBar(False);
1088 SetTrainingModeOff ()
1090 SetMenuEnables(trainingOffEnables);
1091 if (appData.showButtonBar) {
1092 EnableButtonBar(True);
1097 SetUserThinkingEnables ()
1099 if (appData.noChessProgram) return;
1100 SetMenuEnables(userThinkingEnables);
1104 SetMachineThinkingEnables ()
1106 if (appData.noChessProgram) return;
1107 SetMenuEnables(machineThinkingEnables);
1109 case MachinePlaysBlack:
1110 case MachinePlaysWhite:
1111 case TwoMachinesPlay:
1112 EnableMenuItem(ModeToWidgetName(gameMode), True);
1120 GreyRevert (Boolean grey)
1122 MarkMenuItem("Revert", !grey);
1123 MarkMenuItem("Annotate", !grey);
1127 ModeToWidgetName (GameMode mode)
1130 case BeginningOfGame:
1131 if (appData.icsActive)
1132 return "ICS Client";
1133 else if (appData.noChessProgram ||
1134 *appData.cmailGameName != NULLCHAR)
1137 return "Machine Black";
1138 case MachinePlaysBlack:
1139 return "Machine Black";
1140 case MachinePlaysWhite:
1141 return "Machine White";
1143 return "Analysis Mode";
1145 return "Analyze File";
1146 case TwoMachinesPlay:
1147 return "Two Machines";
1150 case PlayFromGameFile:
1153 return "Edit Position";
1156 case IcsPlayingWhite:
1157 case IcsPlayingBlack:
1161 return "ICS Client";
1171 #ifndef OPTIONSDIALOG
1172 if (appData.alwaysPromoteToQueen) {
1173 MarkMenuItem("Always Queen", True);
1175 if (appData.animateDragging) {
1176 MarkMenuItem("Animate Dragging", True);
1178 if (appData.animate) {
1179 MarkMenuItem("Animate Moving", True);
1181 if (appData.autoCallFlag) {
1182 MarkMenuItem("Auto Flag", True);
1184 if (appData.autoFlipView) {
1185 XtSetValues(XtNameToWidget(menuBarWidget,"Auto Flip View", True);
1187 if (appData.blindfold) {
1188 MarkMenuItem("Blindfold", True);
1190 if (appData.flashCount > 0) {
1191 MarkMenuItem("Flash Moves", True);
1194 if (appData.highlightDragging) {
1195 MarkMenuItem("Highlight Dragging", True);
1198 if (appData.highlightLastMove) {
1199 MarkMenuItem("Highlight Last Move", True);
1201 if (appData.highlightMoveWithArrow) {
1202 MarkMenuItem("Arrow", True);
1204 // if (appData.icsAlarm) {
1205 // MarkMenuItem("ICS Alarm", True);
1207 if (appData.ringBellAfterMoves) {
1208 MarkMenuItem("Move Sound", True);
1210 if (appData.oneClick) {
1211 MarkMenuItem("OneClick", True);
1213 if (appData.periodicUpdates) {
1214 MarkMenuItem("Periodic Updates", True);
1216 if (appData.ponderNextMove) {
1217 MarkMenuItem("Ponder Next Move", True);
1219 if (appData.popupExitMessage) {
1220 MarkMenuItem("Popup Exit Message", True);
1222 if (appData.popupMoveErrors) {
1223 MarkMenuItem("Popup Move Errors", True);
1225 // if (appData.premove) {
1226 // MarkMenuItem("Premove", True);
1228 if (appData.showCoords) {
1229 MarkMenuItem("Show Coords", True);
1231 if (appData.hideThinkingFromHuman) {
1232 MarkMenuItem("Hide Thinking", True);
1234 if (appData.testLegality) {
1235 MarkMenuItem("Test Legality", True);
1238 if (saveSettingsOnExit) {
1239 MarkMenuItem("Save Settings on Exit", True);