From: H.G. Muller Date: Sat, 31 Mar 2012 08:54:22 +0000 (+0200) Subject: Switch back two two-part menu names X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=86932d68dc115d304fddb290947fd04323d62cbd;p=xboard.git Switch back two two-part menu names The menu code is again completely changed; a handle field is added to the MenuItem tables to store the widget for the item, and this info is used to alter sensitivity or marking. MenuToNr is replaced by MenuNameToItem, which looks up the two-level name directly in the menu tables. Put all currently unused MenuProcs in noMenu table, so they are available for key binding through the new method. --- diff --git a/board.c b/board.c index dd0e7ab..2b0c624 100644 --- a/board.c +++ b/board.c @@ -896,7 +896,7 @@ DrawPosition (int repaint, Board board) board = lastBoard[nr]; } if (!lastBoardValid[nr] || (nr == 0 && lastFlipView != flipView)) { - MarkMenuItem("Flip View", flipView); + MarkMenuItem("View.Flip View", flipView); } /* diff --git a/dialogs.c b/dialogs.c index af8e354..03c56ea 100644 --- a/dialogs.c +++ b/dialogs.c @@ -890,7 +890,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 +937,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 +947,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 +991,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 +1097,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); } diff --git a/menus.c b/menus.c index eb4441d..f802215 100644 --- a/menus.c +++ b/menus.c @@ -347,7 +347,7 @@ SaveOnExitProc () saveSettingsOnExit = !saveSettingsOnExit; - MarkMenuItem("Save Settings on Exit", saveSettingsOnExit); + MarkMenuItem("Options.SaveSettingsonExit", saveSettingsOnExit); } void @@ -451,14 +451,14 @@ PonderNextMoveProc () Arg args[16]; PonderNextMoveEvent(!appData.ponderNextMove); - MARK_MENU_ITEM("Ponder Next Move", appData.ponderNextMove); + MARK_MENU_ITEM("Options.PonderNextMove", appData.ponderNextMove); } void AlwaysQueenProc () { appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen; - MARK_MENU_ITEM("Always Queen", appData.alwaysPromoteToQueen); + MARK_MENU_ITEM("Options.AlwaysQueen", appData.alwaysPromoteToQueen); } void @@ -467,7 +467,7 @@ AnimateDraggingProc () appData.animateDragging = !appData.animateDragging; if (appData.animateDragging) CreateAnimVars(); - MARK_MENU_ITEM("Animate Dragging", appData.animateDragging); + MARK_MENU_ITEM("Options.AnimateDragging", appData.animateDragging); } void @@ -475,28 +475,28 @@ AnimateMovingProc () { appData.animate = !appData.animate; if (appData.animate) CreateAnimVars(); - MARK_MENU_ITEM("Animate Moving", appData.animate); + MARK_MENU_ITEM("Options.AnimateMoving", appData.animate); } void AutoflagProc () { appData.autoCallFlag = !appData.autoCallFlag; - MARK_MENU_ITEM("Auto Flag", appData.autoCallFlag); + MARK_MENU_ITEM("Options.AutoFlag", appData.autoCallFlag); } void AutoflipProc () { appData.autoFlipView = !appData.autoFlipView; - MARK_MENU_ITEM("Auto Flip View", appData.autoFlipView); + MARK_MENU_ITEM("Options.AutoFlipView", appData.autoFlipView); } void BlindfoldProc () { appData.blindfold = !appData.blindfold; - MARK_MENU_ITEM("Blindfold", appData.blindfold); + MARK_MENU_ITEM("Options.Blindfold", appData.blindfold); DrawPosition(True, NULL); } @@ -504,7 +504,7 @@ void TestLegalityProc () { appData.testLegality = !appData.testLegality; - MARK_MENU_ITEM("Test Legality", appData.testLegality); + MARK_MENU_ITEM("Options.TestLegality", appData.testLegality); } @@ -516,7 +516,7 @@ FlashMovesProc () } else { appData.flashCount = -appData.flashCount; } - MARK_MENU_ITEM("Flash Moves", appData.flashCount > 0); + MARK_MENU_ITEM("Options.FlashMoves", appData.flashCount > 0); } #if HIGHDRAG @@ -524,7 +524,7 @@ void HighlightDraggingProc () { appData.highlightDragging = !appData.highlightDragging; - MARK_MENU_ITEM("Highlight Dragging", appData.highlightDragging); + MARK_MENU_ITEM("Options.HighlightDragging", appData.highlightDragging); } #endif @@ -532,70 +532,70 @@ void HighlightLastMoveProc () { appData.highlightLastMove = !appData.highlightLastMove; - MARK_MENU_ITEM("Highlight Last Move", appData.highlightLastMove); + MARK_MENU_ITEM("Options.HighlightLastMove", appData.highlightLastMove); } void HighlightArrowProc () { appData.highlightMoveWithArrow = !appData.highlightMoveWithArrow; - MARK_MENU_ITEM("Arrow", appData.highlightMoveWithArrow); + MARK_MENU_ITEM("Options.HighlightWithArrow", appData.highlightMoveWithArrow); } void IcsAlarmProc () { appData.icsAlarm = !appData.icsAlarm; -// MARK_MENU_ITEM("ICS Alarm", appData.icsAlarm); +// MARK_MENU_ITEM("Options.ICSAlarm", appData.icsAlarm); } void MoveSoundProc () { appData.ringBellAfterMoves = !appData.ringBellAfterMoves; - MARK_MENU_ITEM("Move Sound", appData.ringBellAfterMoves); + MARK_MENU_ITEM("Options.MoveSound", appData.ringBellAfterMoves); } void OneClickProc () { appData.oneClick = !appData.oneClick; - MARK_MENU_ITEM("OneClick", appData.oneClick); + MARK_MENU_ITEM("Options.OneClickMoving", appData.oneClick); } void PeriodicUpdatesProc () { PeriodicUpdatesEvent(!appData.periodicUpdates); - MARK_MENU_ITEM("Periodic Updates", appData.periodicUpdates); + MARK_MENU_ITEM("Options.PeriodicUpdates", appData.periodicUpdates); } void PopupExitMessageProc () { appData.popupExitMessage = !appData.popupExitMessage; - MARK_MENU_ITEM("Popup Exit Message", appData.popupExitMessage); + MARK_MENU_ITEM("Options.PopupExitMessage", appData.popupExitMessage); } void PopupMoveErrorsProc () { appData.popupMoveErrors = !appData.popupMoveErrors; - MARK_MENU_ITEM("Popup Move Errors", appData.popupMoveErrors); + MARK_MENU_ITEM("Options.PopupMoveErrors", appData.popupMoveErrors); } void PremoveProc () { appData.premove = !appData.premove; -// MARK_MENU_ITEM("Premove", appData.premove); +// MARK_MENU_ITEM("Options.Premove", appData.premove); } void ShowCoordsProc () { appData.showCoords = !appData.showCoords; - MARK_MENU_ITEM("Show Coords", appData.showCoords); + MARK_MENU_ITEM("Options.ShowCoords", appData.showCoords); DrawPosition(True, NULL); } @@ -614,7 +614,7 @@ HideThinkingProc () appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman; // [HGM] thinking: taken out of ShowThinkingEvent ShowThinkingEvent(); - MARK_MENU_ITEM("Hide Thinking", appData.hideThinkingFromHuman); + MARK_MENU_ITEM("Options.HideThinking", appData.hideThinkingFromHuman); } /* @@ -622,84 +622,84 @@ HideThinkingProc () */ MenuItem fileMenu[] = { - {N_("New Game Ctrl+N"), "New Game", ResetGameEvent}, - {N_("New Shuffle Game ..."), "New Shuffle Game", ShuffleMenuProc}, - {N_("New Variant ... Alt+Shift+V"), "New Variant", NewVariantProc}, // [HGM] variant: not functional yet + {N_("New Game Ctrl+N"), "NewGame", ResetGameEvent}, + {N_("New Shuffle Game ..."), "NewShuffleGame", ShuffleMenuProc}, + {N_("New Variant ... Alt+Shift+V"), "NewVariant", NewVariantProc}, // [HGM] variant: not functional yet {"----", NULL, NothingProc}, - {N_("Load Game Ctrl+O"), "Load Game", LoadGameProc}, - {N_("Load Position Ctrl+Shift+O"), "Load Position", LoadPositionProc}, -// {N_("Load Next Game"), "Load Next Game", LoadNextGameProc}, -// {N_("Load Previous Game"), "Load Previous Game", LoadPrevGameProc}, -// {N_("Reload Same Game"), "Reload Same Game", ReloadGameProc}, - {N_("Next Position Shift+PgDn"), "Load Next Position", LoadNextPositionProc}, - {N_("Prev Position Shift+PgUp"), "Load Previous Position", LoadPrevPositionProc}, + {N_("Load Game Ctrl+O"), "LoadGame", LoadGameProc}, + {N_("Load Position Ctrl+Shift+O"), "LoadPosition", LoadPositionProc}, +// {N_("Load Next Game"), "LoadNextGame", LoadNextGameProc}, +// {N_("Load Previous Game"), "LoadPreviousGame", LoadPrevGameProc}, +// {N_("Reload Same Game"), "ReloadSameGame", ReloadGameProc}, + {N_("Next Position Shift+PgDn"), "LoadNextPosition", LoadNextPositionProc}, + {N_("Prev Position Shift+PgUp"), "LoadPreviousPosition", LoadPrevPositionProc}, {"----", NULL, NothingProc}, // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc}, - {N_("Save Game Ctrl+S"), "Save Game", SaveGameProc}, - {N_("Save Position Ctrl+Shift+S"), "Save Position", SavePositionProc}, + {N_("Save Game Ctrl+S"), "SaveGame", SaveGameProc}, + {N_("Save Position Ctrl+Shift+S"), "SavePosition", SavePositionProc}, {"----", NULL, NothingProc}, - {N_("Mail Move"), "Mail Move", MailMoveEvent}, - {N_("Reload CMail Message"), "Reload CMail Message", ReloadCmailMsgProc}, + {N_("Mail Move"), "MailMove", MailMoveEvent}, + {N_("Reload CMail Message"), "ReloadCMailMessage", ReloadCmailMsgProc}, {"----", NULL, NothingProc}, - {N_("Quit Ctr+Q"), "Exit", QuitProc}, + {N_("Quit Ctr+Q"), "Quit", QuitProc}, {NULL, NULL, NULL} }; MenuItem editMenu[] = { - {N_("Copy Game Ctrl+C"), "Copy Game", CopyGameProc}, - {N_("Copy Position Ctrl+Shift+C"), "Copy Position", CopyPositionProc}, - {N_("Copy Game List"), "Copy Game List", CopyGameListProc}, + {N_("Copy Game Ctrl+C"), "CopyGame", CopyGameProc}, + {N_("Copy Position Ctrl+Shift+C"), "CopyPosition", CopyPositionProc}, + {N_("Copy Game List"), "CopyGameList", CopyGameListProc}, {"----", NULL, NothingProc}, - {N_("Paste Game Ctrl+V"), "Paste Game", PasteGameProc}, - {N_("Paste Position Ctrl+Shift+V"), "Paste Position", PastePositionProc}, + {N_("Paste Game Ctrl+V"), "PasteGame", PasteGameProc}, + {N_("Paste Position Ctrl+Shift+V"), "PastePosition", PastePositionProc}, {"----", NULL, NothingProc}, - {N_("Edit Game Ctrl+E"), "Edit Game 2", EditGameEvent}, - {N_("Edit Position Ctrl+Shift+E"), "Edit Position 2", EditPositionEvent}, - {N_("Edit Tags"), "Edit Tags", EditTagsProc}, - {N_("Edit Comment"), "Edit Comment", EditCommentProc}, - {N_("Edit Book"), "Edit Book", EditBookEvent}, + {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent}, + {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent}, + {N_("Edit Tags"), "EditTags", EditTagsProc}, + {N_("Edit Comment"), "EditComment", EditCommentProc}, + {N_("Edit Book"), "EditBook", EditBookEvent}, {"----", NULL, NothingProc}, {N_("Revert Home"), "Revert", RevertProc}, {N_("Annotate"), "Annotate", AnnotateProc}, - {N_("Truncate Game End"), "Truncate Game", TruncateGameEvent}, + {N_("Truncate Game End"), "TruncateGame", TruncateGameEvent}, {"----", NULL, NothingProc}, {N_("Backward Alt+Left"), "Backward", BackwardEvent}, {N_("Forward Alt+Right"), "Forward", ForwardEvent}, - {N_("Back to Start Alt+Home"), "Back to Start", ToStartEvent}, - {N_("Forward to End Alt+End"), "Forward to End", ToEndEvent}, + {N_("Back to Start Alt+Home"), "BacktoStart", ToStartEvent}, + {N_("Forward to End Alt+End"), "ForwardtoEnd", ToEndEvent}, {NULL, NULL, NULL} }; MenuItem viewMenu[] = { - {N_("Flip View F2"), "Flip View", FlipViewProc}, + {N_("Flip View F2"), "FlipView", FlipViewProc}, {"----", NULL, NothingProc}, - {N_("Engine Output Alt+Shift+O"), "Show Engine Output", EngineOutputProc}, - {N_("Move History Alt+Shift+H"), "Show Move History", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code - {N_("Evaluation Graph Alt+Shift+E"), "Show Evaluation Graph", EvalGraphProc}, - {N_("Game List Alt+Shift+G"), "Show Game List", ShowGameListProc}, - {N_("ICS text menu"), "ICStex", IcsTextProc}, + {N_("Engine Output Alt+Shift+O"), "EngineOutput", EngineOutputProc}, + {N_("Move History Alt+Shift+H"), "MoveHistory", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code + {N_("Evaluation Graph Alt+Shift+E"), "EvaluationGraph", EvalGraphProc}, + {N_("Game List Alt+Shift+G"), "GameList", ShowGameListProc}, + {N_("ICS text menu"), "ICStextmenu", IcsTextProc}, {"----", NULL, NothingProc}, - {N_("Tags"), "Show Tags", EditTagsProc}, - {N_("Comments"), "Show Comments", EditCommentProc}, - {N_("ICS Input Box"), "ICS Input Box", IcsInputBoxProc}, + {N_("Tags"), "Tags", EditTagsProc}, + {N_("Comments"), "Comments", EditCommentProc}, + {N_("ICS Input Box"), "ICSInputBox", IcsInputBoxProc}, {"----", NULL, NothingProc}, - {N_("Board..."), "Board Options", BoardOptionsProc}, - {N_("Game List Tags..."), "Game List", GameListOptionsProc}, + {N_("Board..."), "Board", BoardOptionsProc}, + {N_("Game List Tags..."), "GameListTags", GameListOptionsProc}, {NULL, NULL, NULL} }; MenuItem modeMenu[] = { - {N_("Machine White Ctrl+W"), "Machine White", MachineWhiteEvent}, - {N_("Machine Black Ctrl+B"), "Machine Black", MachineBlackEvent}, - {N_("Two Machines Ctrl+T"), "Two Machines", TwoMachinesEvent}, - {N_("Analysis Mode Ctrl+A"), "Analysis Mode", AnalyzeModeProc}, - {N_("Analyze Game Ctrl+G"), "Analyze File", AnalyzeFileProc }, - {N_("Edit Game Ctrl+E"), "Edit Game", EditGameEvent}, - {N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionEvent}, + {N_("Machine White Ctrl+W"), "MachineWhite", MachineWhiteEvent}, + {N_("Machine Black Ctrl+B"), "MachineBlack", MachineBlackEvent}, + {N_("Two Machines Ctrl+T"), "TwoMachines", TwoMachinesEvent}, + {N_("Analysis Mode Ctrl+A"), "AnalysisMode", AnalyzeModeProc}, + {N_("Analyze Game Ctrl+G"), "AnalyzeFile", AnalyzeFileProc }, + {N_("Edit Game Ctrl+E"), "EditGame", EditGameEvent}, + {N_("Edit Position Ctrl+Shift+E"), "EditPosition", EditPositionEvent}, {N_("Training"), "Training", TrainingEvent}, - {N_("ICS Client"), "ICS Client", IcsClientEvent}, + {N_("ICS Client"), "ICSClient", IcsClientEvent}, {"----", NULL, NothingProc}, - {N_("Machine Match"), "Machine Match", MatchProc}, + {N_("Machine Match"), "MachineMatch", MatchProc}, {N_("Pause Pause"), "Pause", PauseEvent}, {NULL, NULL, NULL} }; @@ -709,33 +709,33 @@ MenuItem actionMenu[] = { {N_("Decline F4"), "Decline", DeclineEvent}, {N_("Rematch F12"), "Rematch", RematchEvent}, {"----", NULL, NothingProc}, - {N_("Call Flag F5"), "Call Flag", CallFlagEvent}, + {N_("Call Flag F5"), "CallFlag", CallFlagEvent}, {N_("Draw F6"), "Draw", DrawEvent}, {N_("Adjourn F7"), "Adjourn", AdjournEvent}, {N_("Abort F8"),"Abort", AbortEvent}, {N_("Resign F9"), "Resign", ResignEvent}, {"----", NULL, NothingProc}, - {N_("Stop Observing F10"), "Stop Observing", StopObservingEvent}, - {N_("Stop Examining F11"), "Stop Examining", StopExaminingEvent}, - {N_("Upload to Examine"), "Upload to Examine", UploadGameEvent}, + {N_("Stop Observing F10"), "StopObserving", StopObservingEvent}, + {N_("Stop Examining F11"), "StopExamining", StopExaminingEvent}, + {N_("Upload to Examine"), "UploadtoExamine", UploadGameEvent}, {"----", NULL, NothingProc}, - {N_("Adjudicate to White"), "Adjudicate to White", AdjuWhiteProc}, - {N_("Adjudicate to Black"), "Adjudicate to Black", AdjuBlackProc}, - {N_("Adjudicate Draw"), "Adjudicate Draw", AdjuDrawProc}, + {N_("Adjudicate to White"), "AdjudicatetoWhite", AdjuWhiteProc}, + {N_("Adjudicate to Black"), "AdjudicatetoBlack", AdjuBlackProc}, + {N_("Adjudicate Draw"), "AdjudicateDraw", AdjuDrawProc}, {NULL, NULL, NULL} }; MenuItem engineMenu[] = { - {N_("Load New Engine ..."), "Load Engine", LoadEngineProc}, + {N_("Load New Engine ..."), "LoadEngine", LoadEngineProc}, {"----", NULL, NothingProc}, - {N_("Engine #1 Settings ..."), "Engine #1 Settings", FirstSettingsProc}, - {N_("Engine #2 Settings ..."), "Engine #2 Settings", SecondSettingsProc}, + {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc}, + {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc}, {"----", NULL, NothingProc}, {N_("Hint"), "Hint", HintEvent}, {N_("Book"), "Book", BookEvent}, {"----", NULL, NothingProc}, - {N_("Move Now Ctrl+M"), "Move Now", MoveNowEvent}, - {N_("Retract Move Ctrl+X"), "Retract Move", RetractMoveEvent}, + {N_("Move Now Ctrl+M"), "MoveNow", MoveNowEvent}, + {N_("Retract Move Ctrl+X"), "RetractMove", RetractMoveEvent}, {NULL, NULL, NULL} }; @@ -743,58 +743,92 @@ MenuItem optionsMenu[] = { #ifdef OPTIONSDIALOG {N_("General ..."), "General", OptionsProc}, #endif - {N_("Time Control ... Alt+Shift+T"), "Time Control", TimeControlProc}, - {N_("Common Engine ... Alt+Shift+U"), "Common Engine", UciMenuProc}, + {N_("Time Control ... Alt+Shift+T"), "TimeControl", TimeControlProc}, + {N_("Common Engine ... Alt+Shift+U"), "CommonEngine", UciMenuProc}, {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc}, {N_("ICS ..."), "ICS", IcsOptionsProc}, {N_("Match ..."), "Match", MatchOptionsProc}, - {N_("Load Game ..."), "Load Game", LoadOptionsProc}, - {N_("Save Game ..."), "Save Game", SaveOptionsProc}, + {N_("Load Game ..."), "LoadGame", LoadOptionsProc}, + {N_("Save Game ..."), "SaveGame", SaveOptionsProc}, // {N_(" ..."), "", OptionsProc}, - {N_("Game List ..."), "Game List", GameListOptionsProc}, + {N_("Game List ..."), "GameList", GameListOptionsProc}, {N_("Sounds ..."), "Sounds", SoundOptionsProc}, {"----", NULL, NothingProc}, #ifndef OPTIONSDIALOG - {N_("Always Queen Ctrl+Shift+Q"), "Always Queen", AlwaysQueenProc}, - {N_("Animate Dragging"), "Animate Dragging", AnimateDraggingProc}, - {N_("Animate Moving Ctrl+Shift+A"), "Animate Moving", AnimateMovingProc}, - {N_("Auto Flag Ctrl+Shift+F"), "Auto Flag", AutoflagProc}, - {N_("Auto Flip View"), "Auto Flip View", AutoflipProc}, + {N_("Always Queen Ctrl+Shift+Q"), "AlwaysQueen", AlwaysQueenProc}, + {N_("Animate Dragging"), "AnimateDragging", AnimateDraggingProc}, + {N_("Animate Moving Ctrl+Shift+A"), "AnimateMoving", AnimateMovingProc}, + {N_("Auto Flag Ctrl+Shift+F"), "AutoFlag", AutoflagProc}, + {N_("Auto Flip View"), "AutoFlipView", AutoflipProc}, {N_("Blindfold"), "Blindfold", BlindfoldProc}, - {N_("Flash Moves"), "Flash Moves", FlashMovesProc}, + {N_("Flash Moves"), "FlashMoves", FlashMovesProc}, #if HIGHDRAG - {N_("Highlight Dragging"), "Highlight Dragging", HighlightDraggingProc}, + {N_("Highlight Dragging"), "HighlightDragging", HighlightDraggingProc}, #endif - {N_("Highlight Last Move"), "Highlight Last Move", HighlightLastMoveProc}, - {N_("Highlight With Arrow"), "Arrow", HighlightArrowProc}, - {N_("Move Sound"), "Move Sound", MoveSoundProc}, -// {N_("ICS Alarm"), "ICS Alarm", IcsAlarmProc}, - {N_("One-Click Moving"), "OneClick", OneClickProc}, - {N_("Periodic Updates"), "Periodic Updates", PeriodicUpdatesProc}, - {N_("Ponder Next Move Ctrl+Shift+P"), "Ponder Next Move", PonderNextMoveProc}, - {N_("Popup Exit Message"), "Popup Exit Message", PopupExitMessageProc}, - {N_("Popup Move Errors"), "Popup Move Errors", PopupMoveErrorsProc}, + {N_("Highlight Last Move"), "HighlightLastMove", HighlightLastMoveProc}, + {N_("Highlight With Arrow"), "HighlightWithArrow", HighlightArrowProc}, + {N_("Move Sound"), "MoveSound", MoveSoundProc}, +// {N_("ICS Alarm"), "ICSAlarm", IcsAlarmProc}, + {N_("One-Click Moving"), "OneClickMoving", OneClickProc}, + {N_("Periodic Updates"), "PeriodicUpdates", PeriodicUpdatesProc}, + {N_("Ponder Next Move Ctrl+Shift+P"), "PonderNextMove", PonderNextMoveProc}, + {N_("Popup Exit Message"), "PopupExitMessage", PopupExitMessageProc}, + {N_("Popup Move Errors"), "PopupMoveErrors", PopupMoveErrorsProc}, // {N_("Premove"), "Premove", PremoveProc}, - {N_("Show Coords"), "Show Coords", ShowCoordsProc}, - {N_("Hide Thinking Ctrl+Shift+H"), "Hide Thinking", HideThinkingProc}, - {N_("Test Legality Ctrl+Shift+L"), "Test Legality", TestLegalityProc}, + {N_("Show Coords"), "ShowCoords", ShowCoordsProc}, + {N_("Hide Thinking Ctrl+Shift+H"), "HideThinking", HideThinkingProc}, + {N_("Test Legality Ctrl+Shift+L"), "TestLegality", TestLegalityProc}, {"----", NULL, NothingProc}, #endif - {N_("Save Settings Now"), "Save Settings Now", SaveSettingsProc}, - {N_("Save Settings on Exit"), "Save Settings on Exit", SaveOnExitProc}, + {N_("Save Settings Now"), "SaveSettingsNow", SaveSettingsProc}, + {N_("Save Settings on Exit"), "SaveSettingsonExit", SaveOnExitProc}, {NULL, NULL, NULL} }; MenuItem helpMenu[] = { - {N_("Info XBoard"), "Info XBoard", InfoProc}, - {N_("Man XBoard F1"), "Man XBoard", ManProc}, + {N_("Info XBoard"), "InfoXBoard", InfoProc}, + {N_("Man XBoard F1"), "ManXBoard", ManProc}, {"----", NULL, NothingProc}, - {N_("XBoard Home Page"), "Home Page", HomePageProc}, - {N_("On-line User Guide"), "User Guide", GuideProc}, - {N_("Development News"), "News Page", NewsPageProc}, - {N_("e-Mail Bug Report"), "Bug Report", BugReportProc}, + {N_("XBoard Home Page"), "XBoardHomePage", HomePageProc}, + {N_("On-line User Guide"), "On-lineUserGuide", GuideProc}, + {N_("Development News"), "DevelopmentNews", NewsPageProc}, + {N_("e-Mail Bug Report"), "e-MailBugReport", BugReportProc}, {"----", NULL, NothingProc}, - {N_("About XBoard"), "About XBoard", AboutProc}, + {N_("About XBoard"), "AboutXBoard", AboutProc}, + {NULL, NULL, NULL} +}; + +MenuItem noMenu[] = { + { "", "LoadNextGame", LoadNextGameProc }, + { "", "LoadPrevGame", LoadPrevGameProc }, + { "", "ReloadGame", ReloadGameProc }, + { "", "ReloadPosition", ReloadPositionProc }, +#ifndef OPTIONSDIALOG + { "", "AlwaysQueen", AlwaysQueenProc }, + { "", "AnimateDragging", AnimateDraggingProc }, + { "", "AnimateMoving", AnimateMovingProc }, + { "", "Autoflag", AutoflagProc }, + { "", "Autoflip", AutoflipProc }, + { "", "Blindfold", BlindfoldProc }, + { "", "FlashMoves", FlashMovesProc }, +#if HIGHDRAG + { "", "HighlightDragging", HighlightDraggingProc }, +#endif + { "", "HighlightLastMove", HighlightLastMoveProc }, +// { "", "IcsAlarm", IcsAlarmProc }, + { "", "MoveSound", MoveSoundProc }, + { "", "PeriodicUpdates", PeriodicUpdatesProc }, + { "", "PopupExitMessage", PopupExitMessageProc }, + { "", "PopupMoveErrors", PopupMoveErrorsProc }, +// { "", "Premove", PremoveProc }, + { "", "ShowCoords", ShowCoordsProc }, + { "", "ShowThinking", ShowThinkingProc }, + { "", "HideThinking", HideThinkingProc }, + { "", "TestLegality", TestLegalityProc }, +#endif + { "", "AboutGame", AboutGameEvent }, + { "", "Debug", DebugProc }, + { "", "Nothing", NothingProc }, {NULL, NULL, NULL} }; @@ -810,13 +844,27 @@ Menu menuBar[] = { {NULL, NULL, NULL} }; -int -MenuToNumber(char *menuName) +MenuItem * +MenuNameToItem (char *menuName) { int i; - for(i=0; imi; - while (mi->string != NULL) { - AppendMenuItem(mi->string, mi->ref, mi->proc); - menuItemList[nrOfMenuItems].name = mi->ref; - menuItemList[nrOfMenuItems].proc = mi->proc; - if(strcmp(mi->string, "----")) nrOfMenuItems++; - mi++; - } - - if(!strcmp(mb->name, "Engine")) AppendEnginesToMenu(appData.recentEngineList); -} - -void -CreateMainMenus (Menu *mb) -{ - char menuName[MSG_SIZ]; - - while(menuItemList[nrOfMenuItems].name) nrOfMenuItems++; // skip any predefined items - - while (mb->name != NULL) { - safeStrCpy(menuName, "menu", sizeof(menuName)/sizeof(menuName[0]) ); - strncat(menuName, mb->ref, MSG_SIZ - strlen(menuName) - 1); - AddPullDownMenu(menuName, mb++); - } +#endif } Enables icsEnables[] = { - { "Mail Move", False }, - { "Reload CMail Message", False }, - { "Machine Black", False }, - { "Machine White", False }, - { "Analysis Mode", False }, - { "Analyze File", False }, - { "Two Machines", False }, - { "Machine Match", False }, + { "File.MailMove", False }, + { "File.ReloadCMailMessage", False }, + { "Mode.MachineBlack", False }, + { "Mode.MachineWhite", False }, + { "Mode.AnalysisMode", False }, + { "Mode.AnalyzeFile", False }, + { "Mode.TwoMachines", False }, + { "Mode.MachineMatch", False }, #ifndef ZIPPY - { "Hint", False }, - { "Book", False }, - { "Move Now", False }, + { "Engine.Hint", False }, + { "Engine.Book", False }, + { "Engine.MoveNow", False }, #ifndef OPTIONSDIALOG - { "Periodic Updates", False }, - { "Hide Thinking", False }, - { "Ponder Next Move", False }, + { "PeriodicUpdates", False }, + { "HideThinking", False }, + { "PonderNextMove", False }, #endif #endif - { "Engine #1 Settings", False }, - { "Engine #2 Settings", False }, - { "Load Engine", False }, - { "Annotate", False }, - { "Match", False }, + { "Engine.Engine#1Settings", False }, + { "Engine.Engine#2Settings", False }, + { "Engine.LoadEngine", False }, + { "Edit.Annotate", False }, + { "Options.Match", False }, { NULL, False } }; Enables ncpEnables[] = { - { "Mail Move", False }, - { "Reload CMail Message", False }, - { "Machine White", False }, - { "Machine Black", False }, - { "Analysis Mode", False }, - { "Analyze File", False }, - { "Two Machines", False }, - { "Machine Match", False }, - { "ICS Client", False }, - { "ICStex", False }, - { "ICS Input Box", False }, - { "Action", False }, - { "Revert", False }, - { "Annotate", False }, - { "Engine #1 Settings", False }, - { "Engine #2 Settings", False }, - { "Move Now", False }, - { "Retract Move", False }, - { "ICS", False }, + { "File.MailMove", False }, + { "File.ReloadCMailMessage", False }, + { "Mode.MachineWhite", False }, + { "Mode.MachineBlack", False }, + { "Mode.AnalysisMode", False }, + { "Mode.AnalyzeFile", False }, + { "Mode.TwoMachines", False }, + { "Mode.MachineMatch", False }, + { "Mode.ICSClient", False }, + { "View.ICStextmenu", False }, + { "View.ICSInputBox", False }, + { "Action.", False }, + { "Edit.Revert", False }, + { "Edit.Annotate", False }, + { "Engine.Engine#1Settings", False }, + { "Engine.Engine#2Settings", False }, + { "Engine.MoveNow", False }, + { "Engine.RetractMove", False }, + { "Options.ICS", False }, #ifndef OPTIONSDIALOG - { "Auto Flag", False }, - { "Auto Flip View", False }, -// { "ICS Alarm", False }, - { "Move Sound", False }, - { "Hide Thinking", False }, - { "Periodic Updates", False }, - { "Ponder Next Move", False }, + { "Options.AutoFlag", False }, + { "Options.AutoFlip View", False }, +// { "Options.ICSAlarm", False }, + { "Options.MoveSound", False }, + { "Options.HideThinking", False }, + { "Options.PeriodicUpdates", False }, + { "Options.PonderNextMove", False }, #endif - { "Hint", False }, - { "Book", False }, + { "Engine.Hint", False }, + { "Engine.Book", False }, { NULL, False } }; Enables gnuEnables[] = { - { "ICS Client", False }, - { "ICStex", False }, - { "ICS Input Box", False }, - { "Accept", False }, - { "Decline", False }, - { "Rematch", False }, - { "Adjourn", False }, - { "Stop Examining", False }, - { "Stop Observing", False }, - { "Upload to Examine", False }, - { "Revert", False }, - { "Annotate", False }, - { "ICS", False }, + { "Mode.ICSClient", False }, + { "View.ICStextmenu", False }, + { "View.ICSInputBox", False }, + { "Action.Accept", False }, + { "Action.Decline", False }, + { "Action.Rematch", False }, + { "Action.Adjourn", False }, + { "Action.StopExamining", False }, + { "Action.StopObserving", False }, + { "Action.UploadtoExamine", False }, + { "Edit.Revert", False }, + { "Edit.Annotate", False }, + { "Options.ICS", False }, /* The next two options rely on SetCmailMode being called *after* */ /* SetGNUMode so that when GNU is being used to give hints these */ /* menu options are still available */ - { "Mail Move", False }, - { "Reload CMail Message", False }, + { "File.MailMove", False }, + { "File.ReloadCMailMessage", False }, // [HGM] The following have been added to make a switch from ncp to GNU mode possible - { "Machine White", True }, - { "Machine Black", True }, - { "Analysis Mode", True }, - { "Analyze File", True }, - { "Two Machines", True }, - { "Machine Match", True }, - { "Engine #1 Settings", True }, - { "Engine #2 Settings", True }, - { "Hint", True }, - { "Book", True }, - { "Move Now", True }, - { "Retract Move", True }, - { "Action", True }, + { "Mode.MachineWhite", True }, + { "Mode.MachineBlack", True }, + { "Mode.AnalysisMode", True }, + { "Mode.AnalyzeFile", True }, + { "Mode.TwoMachines", True }, + { "Mode.MachineMatch", True }, + { "Engine.Engine#1Settings", True }, + { "Engine.Engine#2Settings", True }, + { "Engine.Hint", True }, + { "Engine.Book", True }, + { "Engine.MoveNow", True }, + { "Engine.RetractMove", True }, + { "Action.", True }, { NULL, False } }; Enables cmailEnables[] = { - { "Action", True }, - { "Call Flag", False }, - { "Draw", True }, - { "Adjourn", False }, - { "Abort", False }, - { "Stop Observing", False }, - { "Stop Examining", False }, - { "Mail Move", True }, - { "Reload CMail Message", True }, + { "Action.", True }, + { "Action.CallFlag", False }, + { "Action.Draw", True }, + { "Action.Adjourn", False }, + { "Action.Abort", False }, + { "Action.StopObserving", False }, + { "Action.StopExamining", False }, + { "File.MailMove", True }, + { "File.ReloadCMailMessage", True }, { NULL, False } }; Enables trainingOnEnables[] = { - { "Edit Comment", False }, - { "Pause", False }, - { "Forward", False }, - { "Backward", False }, - { "Forward to End", False }, - { "Back to Start", False }, - { "Move Now", False }, - { "Truncate Game", False }, + { "Edit.EditComment", False }, + { "Mode.Pause", False }, + { "Edit.Forward", False }, + { "Edit.Backward", False }, + { "Edit.ForwardtoEnd", False }, + { "Edit.BacktoStart", False }, + { "Engine.MoveNow", False }, + { "Edit.TruncateGame", False }, { NULL, False } }; Enables trainingOffEnables[] = { - { "Edit Comment", True }, - { "Pause", True }, - { "Forward", True }, - { "Backward", True }, - { "Forward to End", True }, - { "Back to Start", True }, - { "Move Now", True }, - { "Truncate Game", True }, + { "Edit.EditComment", True }, + { "Mode.Pause", True }, + { "Edit.Forward", True }, + { "Edit.Backward", True }, + { "Edit.ForwardtoEnd", True }, + { "Edit.BacktoStart", True }, + { "Engine.MoveNow", True }, + { "Engine.TruncateGame", True }, { NULL, False } }; Enables machineThinkingEnables[] = { - { "Load Game", False }, -// { "Load Next Game", False }, -// { "Load Previous Game", False }, -// { "Reload Same Game", False }, - { "Paste Game", False }, - { "Load Position", False }, -// { "Load Next Position", False }, -// { "Load Previous Position", False }, -// { "Reload Same Position", False }, - { "Paste Position", False }, - { "Machine White", False }, - { "Machine Black", False }, - { "Two Machines", False }, -// { "Machine Match", False }, - { "Retract Move", False }, + { "File.LoadGame", False }, +// { "LoadNextGame", False }, +// { "LoadPreviousGame", False }, +// { "ReloadSameGame", False }, + { "Edit.PasteGame", False }, + { "File.LoadPosition", False }, +// { "LoadNextPosition", False }, +// { "LoadPreviousPosition", False }, +// { "ReloadSamePosition", False }, + { "Edit.PastePosition", False }, + { "Mode.MachineWhite", False }, + { "Mode.MachineBlack", False }, + { "Mode.TwoMachines", False }, +// { "MachineMatch", False }, + { "Engine.RetractMove", False }, { NULL, False } }; Enables userThinkingEnables[] = { - { "Load Game", True }, -// { "Load Next Game", True }, -// { "Load Previous Game", True }, -// { "Reload Same Game", True }, - { "Paste Game", True }, - { "Load Position", True }, -// { "Load Next Position", True }, -// { "Load Previous Position", True }, -// { "Reload Same Position", True }, - { "Paste Position", True }, - { "Machine White", True }, - { "Machine Black", True }, - { "Two Machines", True }, -// { "Machine Match", True }, - { "Retract Move", True }, + { "File.LoadGame", True }, +// { "LoadNextGame", True }, +// { "LoadPreviousGame", True }, +// { "ReloadSameGame", True }, + { "Edit.PasteGame", True }, + { "File.LoadPosition", True }, +// { "LoadNextPosition", True }, +// { "LoadPreviousPosition", True }, +// { "ReloadSamePosition", True }, + { "Edit.PastePosition", True }, + { "Mode.MachineWhite", True }, + { "Mode.MachineBlack", True }, + { "Mode.TwoMachines", True }, +// { "MachineMatch", True }, + { "Engine.RetractMove", True }, { NULL, False } }; @@ -1119,8 +1135,8 @@ SetMachineThinkingEnables () void GreyRevert (Boolean grey) { - MarkMenuItem("Revert", !grey); - MarkMenuItem("Annotate", !grey); + MarkMenuItem("Edit.Revert", !grey); + MarkMenuItem("Edit.Annotate", !grey); } char * @@ -1129,36 +1145,36 @@ ModeToWidgetName (GameMode mode) switch (mode) { case BeginningOfGame: if (appData.icsActive) - return "ICS Client"; + return "Mode.ICSClient"; else if (appData.noChessProgram || *appData.cmailGameName != NULLCHAR) - return "Edit Game"; + return "Mode.EditGame"; else - return "Machine Black"; + return "Mode.MachineBlack"; case MachinePlaysBlack: - return "Machine Black"; + return "Mode.MachineBlack"; case MachinePlaysWhite: - return "Machine White"; + return "Mode.MachineWhite"; case AnalyzeMode: - return "Analysis Mode"; + return "Mode.AnalysisMode"; case AnalyzeFile: - return "Analyze File"; + return "Mode.AnalyzeFile"; case TwoMachinesPlay: - return "Two Machines"; + return "Mode.TwoMachines"; case EditGame: - return "Edit Game"; + return "Mode.EditGame"; case PlayFromGameFile: - return "Load Game"; + return "File.LoadGame"; case EditPosition: - return "Edit Position"; + return "Mode.EditPosition"; case Training: - return "Training"; + return "Mode.Training"; case IcsPlayingWhite: case IcsPlayingBlack: case IcsObserving: case IcsIdle: case IcsExamining: - return "ICS Client"; + return "Mode.ICSClient"; default: case EndOfGame: return NULL; @@ -1170,73 +1186,73 @@ InitMenuMarkers() { #ifndef OPTIONSDIALOG if (appData.alwaysPromoteToQueen) { - MarkMenuItem("Always Queen", True); + MarkMenuItem("Options.Always Queen", True); } if (appData.animateDragging) { - MarkMenuItem("Animate Dragging", True); + MarkMenuItem("Options.Animate Dragging", True); } if (appData.animate) { - MarkMenuItem("Animate Moving", True); + MarkMenuItem("Options.Animate Moving", True); } if (appData.autoCallFlag) { - MarkMenuItem("Auto Flag", True); + MarkMenuItem("Options.Auto Flag", True); } if (appData.autoFlipView) { - XtSetValues(XtNameToWidget(menuBarWidget,"Auto Flip View", True); + XtSetValues(XtNameToWidget(menuBarWidget,"Options.Auto Flip View", True); } if (appData.blindfold) { - MarkMenuItem("Blindfold", True); + MarkMenuItem("Options.Blindfold", True); } if (appData.flashCount > 0) { - MarkMenuItem("Flash Moves", True); + MarkMenuItem("Options.Flash Moves", True); } #if HIGHDRAG if (appData.highlightDragging) { - MarkMenuItem("Highlight Dragging", True); + MarkMenuItem("Options.Highlight Dragging", True); } #endif if (appData.highlightLastMove) { - MarkMenuItem("Highlight Last Move", True); + MarkMenuItem("Options.Highlight Last Move", True); } if (appData.highlightMoveWithArrow) { - MarkMenuItem("Arrow", True); + MarkMenuItem("Options.Arrow", True); } // if (appData.icsAlarm) { -// MarkMenuItem("ICS Alarm", True); +// MarkMenuItem("Options.ICS Alarm", True); // } if (appData.ringBellAfterMoves) { - MarkMenuItem("Move Sound", True); + MarkMenuItem("Options.Move Sound", True); } if (appData.oneClick) { - MarkMenuItem("OneClick", True); + MarkMenuItem("Options.OneClick", True); } if (appData.periodicUpdates) { - MarkMenuItem("Periodic Updates", True); + MarkMenuItem("Options.Periodic Updates", True); } if (appData.ponderNextMove) { - MarkMenuItem("Ponder Next Move", True); + MarkMenuItem("Options.Ponder Next Move", True); } if (appData.popupExitMessage) { - MarkMenuItem("Popup Exit Message", True); + MarkMenuItem("Options.Popup Exit Message", True); } if (appData.popupMoveErrors) { - MarkMenuItem("Popup Move Errors", True); + MarkMenuItem("Options.Popup Move Errors", True); } // if (appData.premove) { -// MarkMenuItem("Premove", True); +// MarkMenuItem("Options.Premove", True); // } if (appData.showCoords) { - MarkMenuItem("Show Coords", True); + MarkMenuItem("Options.Show Coords", True); } if (appData.hideThinkingFromHuman) { - MarkMenuItem("Hide Thinking", True); + MarkMenuItem("Options.Hide Thinking", True); } if (appData.testLegality) { - MarkMenuItem("Test Legality", True); + MarkMenuItem("Options.Test Legality", True); } #endif if (saveSettingsOnExit) { - MarkMenuItem("Save Settings on Exit", True); + MarkMenuItem("Options.SaveSettingsonExit", True); } } diff --git a/menus.h b/menus.h index 9ed3fc9..fc3d8a3 100644 --- a/menus.h +++ b/menus.h @@ -54,22 +54,16 @@ typedef void MenuProc P((void)); typedef struct { - char *name; - MenuProc *proc; -} MenuListItem; - -typedef struct { String string; String ref; MenuProc *proc; + void *handle; } MenuItem; typedef struct { String name; String ref; MenuItem *mi; - int textWidth; - Widget subMenu; } Menu; typedef struct { @@ -77,8 +71,6 @@ typedef struct { Boolean value; } Enables; -extern int nrOfMenuItems; -extern MenuListItem menuItemList[]; extern Menu menuBar[]; void LoadGameProc P((void)); @@ -173,7 +165,7 @@ void EvalGraphProc P((void)); void CreateMainMenus P((Menu *mb)); void AppendMenuItem P((char *text, char *name, MenuProc *action)); void CreateMenuButton P((char *name, Menu *mb)); -int MenuToNumber P((char *menuName)); +MenuItem *MenuNameToItem P((char *menuName)); void SetMenuEnables P((Enables *enab)); void EnableButtonBar P((int state)); char *ModeToWidgetName P((GameMode mode)); diff --git a/nengineoutput.c b/nengineoutput.c index e17f76b..814a886 100644 --- a/nengineoutput.c +++ b/nengineoutput.c @@ -135,7 +135,7 @@ EngineOutputPopUp () SetDialogTitle(EngOutDlg, _(title)); } - MarkMenu("Show Engine Output", EngOutDlg); + MarkMenu("View.EngineOutput", EngOutDlg); ShowThinkingEvent(); // [HGM] thinking: might need to prompt engine for thinking output } diff --git a/ngamelist.c b/ngamelist.c index 365ed8c..7cdd0b8 100644 --- a/ngamelist.c +++ b/ngamelist.c @@ -239,7 +239,7 @@ GameListPopUp (FILE *fp, char *filename) page = 0; GameListReplace(0); // [HGM] filter: code put in separate routine, and also called to set title - MarkMenu("Show Game List", GameListDlg); + MarkMenu("View.GameList", GameListDlg); } void @@ -274,7 +274,7 @@ ShowGameListProc () return; } GenericPopUp(NULL, NULL, GameListDlg, BoardWindow, NONMODAL, 1); // first two args ignored when shell exists! - MarkMenu("Show Game List", GameListDlg); + MarkMenu("View.GameList", GameListDlg); GameListHighlight(lastLoadGameNumber); } diff --git a/xboard.c b/xboard.c index 035866c..538d55e 100644 --- a/xboard.c +++ b/xboard.c @@ -432,60 +432,60 @@ XtActionsRec boardActions[] = { }; char globalTranslations[] = - ":F9: MenuItem(ResignProc) \n \ - :Ctrln: MenuItem(NewGame) \n \ - :MetaV: MenuItem(NewVariant) \n \ - :Ctrlo: MenuItem(LoadGame) \n \ + ":F9: MenuItem(Actions.Resign) \n \ + :Ctrln: MenuItem(File.NewGame) \n \ + :MetaV: MenuItem(File.NewVariant) \n \ + :Ctrlo: MenuItem(File.LoadGame) \n \ :MetaNext: MenuItem(LoadNextGameProc) \n \ :MetaPrior: MenuItem(LoadPrevGameProc) \n \ :CtrlDown: LoadSelectedProc(3) \n \ :CtrlUp: LoadSelectedProc(-3) \n \ - :Ctrls: MenuItem(SaveGame) \n \ - :Ctrlc: MenuItem(CopyGame) \n \ - :Ctrlv: MenuItem(PasteGame) \n \ - :CtrlO: MenuItem(LoadPosition) \n \ + :Ctrls: MenuItem(File.SaveGame) \n \ + :Ctrlc: MenuItem(Edit.CopyGame) \n \ + :Ctrlv: MenuItem(Edit.PasteGame) \n \ + :CtrlO: MenuItem(File.LoadPosition) \n \ :ShiftNext: MenuItem(LoadNextPositionProc) \n \ :ShiftPrior: MenuItem(LoadPrevPositionProc) \n \ - :CtrlS: MenuItem(SavePosition) \n \ - :CtrlC: MenuItem(CopyPosition) \n \ - :CtrlV: MenuItem(PastePosition) \n \ - :Ctrlq: MenuItem(Exit) \n \ - :Ctrlw: MenuItem(MachineWhite) \n \ - :Ctrlb: MenuItem(MachineBlack) \n \ - :Ctrlt: MenuItem(TwoMachines) \n \ - :Ctrla: MenuItem(AnalysisMode) \n \ - :Ctrlg: MenuItem(AnalyzeFile) \n \ - :Ctrle: MenuItem(EditGame) \n \ - :CtrlE: MenuItem(EditPosition) \n \ - :MetaO: MenuItem(ShowEngineOutput) \n \ - :MetaE: MenuItem(ShowEvaluationGraph) \n \ - :MetaG: MenuItem(ShowGameList) \n \ - :MetaH: MenuItem(ShowMoveHistory) \n \ - :Pause: MenuItem(Pause) \n \ - :F3: MenuItem(Accept) \n \ - :F4: MenuItem(Decline) \n \ - :F12: MenuItem(Rematch) \n \ - :F5: MenuItem(CallFlag) \n \ - :F6: MenuItem(Draw) \n \ - :F7: MenuItem(Adjourn) \n \ - :F8: MenuItem(Abort) \n \ - :F10: MenuItem(StopObserving) \n \ - :F11: MenuItem(StopExamining) \n \ + :CtrlS: MenuItem(File.SavePosition) \n \ + :CtrlC: MenuItem(Edit.CopyPosition) \n \ + :CtrlV: MenuItem(Edit.PastePosition) \n \ + :Ctrlq: MenuItem(File.Quit) \n \ + :Ctrlw: MenuItem(Mode.MachineWhite) \n \ + :Ctrlb: MenuItem(Mode.MachineBlack) \n \ + :Ctrlt: MenuItem(Mode.TwoMachines) \n \ + :Ctrla: MenuItem(Mode.AnalysisMode) \n \ + :Ctrlg: MenuItem(Mode.AnalyzeFile) \n \ + :Ctrle: MenuItem(Mode.EditGame) \n \ + :CtrlE: MenuItem(Mode.EditPosition) \n \ + :MetaO: MenuItem(View.EngineOutput) \n \ + :MetaE: MenuItem(View.EvaluationGraph) \n \ + :MetaG: MenuItem(View.GameList) \n \ + :MetaH: MenuItem(View.MoveHistory) \n \ + :Pause: MenuItem(Mode.Pause) \n \ + :F3: MenuItem(Action.Accept) \n \ + :F4: MenuItem(Action.Decline) \n \ + :F12: MenuItem(Action.Rematch) \n \ + :F5: MenuItem(Action.CallFlag) \n \ + :F6: MenuItem(Action.Draw) \n \ + :F7: MenuItem(Action.Adjourn) \n \ + :F8: MenuItem(Action.Abort) \n \ + :F10: MenuItem(Action.StopObserving) \n \ + :F11: MenuItem(Action.StopExamining) \n \ :Ctrld: MenuItem(DebugProc) \n \ :Meta CtrlF12: MenuItem(DebugProc) \n \ - :MetaEnd: MenuItem(ToEnd) \n \ - :MetaRight: MenuItem(Forward) \n \ - :MetaHome: MenuItem(ToStart) \n \ - :MetaLeft: MenuItem(Backward) \n \ - :Left: MenuItem(Backward) \n \ - :Right: MenuItem(Forward) \n \ - :Home: MenuItem(Revert) \n \ - :End: MenuItem(TruncateGame) \n \ - :Ctrlm: MenuItem(MoveNow) \n \ - :Ctrlx: MenuItem(RetractMove) \n \ - :MetaJ: MenuItem(Adjudications) \n \ - :MetaU: MenuItem(CommonEngine) \n \ - :MetaT: MenuItem(TimeControl) \n \ + :MetaEnd: MenuItem(Edit.ForwardtoEnd) \n \ + :MetaRight: MenuItem(Edit.Forward) \n \ + :MetaHome: MenuItem(Edit.BacktoStart) \n \ + :MetaLeft: MenuItem(Edit.Backward) \n \ + :Left: MenuItem(Edit.Backward) \n \ + :Right: MenuItem(Edit.Forward) \n \ + :Home: MenuItem(Edit.Revert) \n \ + :End: MenuItem(Edit.TruncateGame) \n \ + :Ctrlm: MenuItem(Engine.MoveNow) \n \ + :Ctrlx: MenuItem(Engine.RetractMove) \n \ + :MetaJ: MenuItem(Options.Adjudications) \n \ + :MetaU: MenuItem(Options.CommonEngine) \n \ + :MetaT: MenuItem(Options.TimeControl) \n \ :CtrlP: MenuItem(PonderNextMove) \n " #ifndef OPTIONSDIALOG "\ @@ -496,8 +496,8 @@ char globalTranslations[] = :CtrlH: MenuItem(HideThinkingProc) \n " #endif "\ - :F1: MenuItem(Manual) \n \ - :F2: MenuItem(FlipView) \n \ + :F1: MenuItem(Help.ManXBoard) \n \ + :F2: MenuItem(View.FlipView) \n \ :Return: TempBackwardProc() \n \ :Return: TempForwardProc() \n"; @@ -2268,60 +2268,24 @@ CreateGrid () } } -int nrOfMenuItems = 7; -Widget menuWidget[150]; -MenuListItem menuItemList[150] = { - { "LoadNextGameProc", LoadNextGameProc }, - { "LoadPrevGameProc", LoadPrevGameProc }, - { "ReloadGameProc", ReloadGameProc }, - { "ReloadPositionProc", ReloadPositionProc }, -#ifndef OPTIONSDIALOG - { "AlwaysQueenProc", AlwaysQueenProc }, - { "AnimateDraggingProc", AnimateDraggingProc }, - { "AnimateMovingProc", AnimateMovingProc }, - { "AutoflagProc", AutoflagProc }, - { "AutoflipProc", AutoflipProc }, - { "BlindfoldProc", BlindfoldProc }, - { "FlashMovesProc", FlashMovesProc }, -#if HIGHDRAG - { "HighlightDraggingProc", HighlightDraggingProc }, -#endif - { "HighlightLastMoveProc", HighlightLastMoveProc }, -// { "IcsAlarmProc", IcsAlarmProc }, - { "MoveSoundProc", MoveSoundProc }, - { "PeriodicUpdatesProc", PeriodicUpdatesProc }, - { "PopupExitMessageProc", PopupExitMessageProc }, - { "PopupMoveErrorsProc", PopupMoveErrorsProc }, -// { "PremoveProc", PremoveProc }, - { "ShowCoordsProc", ShowCoordsProc }, - { "ShowThinkingProc", ShowThinkingProc }, - { "HideThinkingProc", HideThinkingProc }, - { "TestLegalityProc", TestLegalityProc }, -#endif - { "AboutGameProc", AboutGameEvent }, - { "DebugProc", DebugProc }, - { "NothingProc", NothingProc }, - {NULL, NothingProc} -}; - void MarkMenuItem (char *menuRef, int state) { - int nr = MenuToNumber(menuRef); -return; - if(nr >= 0) { + MenuItem *item = MenuNameToItem(menuRef); + + if(item) { Arg args[2]; XtSetArg(args[0], XtNleftBitmap, state ? xMarkPixmap : None); - XtSetValues(menuWidget[nr], args, 1); + XtSetValues(item->handle, args, 1); } } void EnableMenuItem (char *menuRef, int state) { - int nr = MenuToNumber(menuRef); -return; - if(nr >= 0) XtSetSensitive(menuWidget[nr], state); + MenuItem *item = MenuNameToItem(menuRef); + + if(item) XtSetSensitive(item->handle, state); } void @@ -2340,28 +2304,15 @@ SetMenuEnables (Enables *enab) } } -int -Equal(char *p, char *s) -{ // compare strings skipping spaces in second - while(*s) { - if(*s == ' ') { s++; continue; } - if(*s++ != *p++) return 0; - } - return !*p; -} - void KeyBindingProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) { // [HGM] new method of key binding: specify MenuItem(FlipView) in stead of FlipViewProc in translation string int i; char *p; + MenuItem *item; if(*nprms == 0) return; - for(i=0; menuItemList[i].name; i++) { - if(Equal(prms[0], menuItemList[i].name)) { - (menuItemList[i].proc) (); - return; - } - } + item = MenuNameToItem(prms[0]); + if(item) ((MenuProc *) item->proc) (); } static void @@ -2378,91 +2329,6 @@ MenuEngineSelect (Widget w, caddr_t addr, caddr_t index) RecentEngineEvent((int) (intptr_t) addr); } -// some stuff that must remain in front-end -static Widget mainBar, currentMenu; -static int wtot, nr = 0, widths[10]; - -void -AppendMenuItem (char *text, char *name, MenuProc *action) -{ - int j; - Widget entry; - Arg args[16]; - - j = 0; - XtSetArg(args[j], XtNleftMargin, 20); j++; - XtSetArg(args[j], XtNrightMargin, 20); j++; - - if (strcmp(text, "----") == 0) { - entry = XtCreateManagedWidget(text, smeLineObjectClass, - currentMenu, args, j); - } else { - XtSetArg(args[j], XtNlabel, XtNewString(_(text))); - entry = XtCreateManagedWidget(name, smeBSBObjectClass, - currentMenu, args, j+1); - XtAddCallback(entry, XtNcallback, - (XtCallbackProc) (strcmp(name, "recent") ? MenuBarSelect : MenuEngineSelect), - (caddr_t) action); - menuWidget[nrOfMenuItems] = entry; - } -} - -void -CreateMenuButton (char *name, Menu *mb) -{ // create menu button on main bar, and shell for pull-down list - int i, j; - Arg args[16]; - Dimension w; - - j = 0; - XtSetArg(args[j], XtNmenuName, XtNewString(name)); j++; - XtSetArg(args[j], XtNlabel, XtNewString(_(mb->name))); j++; - XtSetArg(args[j], XtNborderWidth, 0); j++; - mb->subMenu = XtCreateManagedWidget(mb->name, menuButtonWidgetClass, - mainBar, args, j); - currentMenu = XtCreatePopupShell(name, simpleMenuWidgetClass, - mainBar, NULL, 0); - j = 0; - XtSetArg(args[j], XtNwidth, &w); j++; - XtGetValues(mb->subMenu, args, j); - wtot += mb->textWidth = widths[nr++] = w; -} - -Widget -CreateMenuBar (Menu *mb, int boardWidth) -{ - int i, j; - Arg args[16]; - char menuName[MSG_SIZ]; - Dimension w; - Menu *ma = mb; - - // create bar itself - j = 0; - XtSetArg(args[j], XtNorientation, XtorientHorizontal); j++; - XtSetArg(args[j], XtNvSpace, 0); j++; - XtSetArg(args[j], XtNborderWidth, 0); j++; - mainBar = XtCreateWidget("menuBar", boxWidgetClass, - formWidget, args, j); - - CreateMainMenus(mb); // put menus in bar according to description in back-end - - // size buttons to make menu bar fit, clipping menu names where necessary - while(wtot > boardWidth - 40) { - int wmax=0, imax=0; - for(i=0; i wmax) wmax = widths[imax=i]; - widths[imax]--; - wtot--; - } - for(i=0; i