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.
92 #include "xgamelist.h"
94 #include "xedittags.h"
99 # define _(s) gettext (s)
100 # define N_(s) gettext_noop (s)
106 MenuItem fileMenu[] = {
107 {N_("New Game Ctrl+N"), "New Game", ResetGameEvent},
108 {N_("New Shuffle Game ..."), "New Shuffle Game", ShuffleMenuProc},
109 {N_("New Variant ... Alt+Shift+V"), "New Variant", NewVariantProc}, // [HGM] variant: not functional yet
110 {"----", NULL, NothingProc},
111 {N_("Load Game Ctrl+O"), "Load Game", LoadGameProc},
112 {N_("Load Position Ctrl+Shift+O"), "Load Position", LoadPositionProc},
113 // {N_("Load Next Game"), "Load Next Game", LoadNextGameProc},
114 // {N_("Load Previous Game"), "Load Previous Game", LoadPrevGameProc},
115 // {N_("Reload Same Game"), "Reload Same Game", ReloadGameProc},
116 {N_("Next Position Shift+PgDn"), "Load Next Position", LoadNextPositionProc},
117 {N_("Prev Position Shift+PgUp"), "Load Previous Position", LoadPrevPositionProc},
118 {"----", NULL, NothingProc},
119 // {N_("Reload Same Position"), "Reload Same Position", ReloadPositionProc},
120 {N_("Save Game Ctrl+S"), "Save Game", SaveGameProc},
121 {N_("Save Position Ctrl+Shift+S"), "Save Position", SavePositionProc},
122 {"----", NULL, NothingProc},
123 {N_("Mail Move"), "Mail Move", MailMoveEvent},
124 {N_("Reload CMail Message"), "Reload CMail Message", ReloadCmailMsgProc},
125 {"----", NULL, NothingProc},
126 {N_("Quit Ctr+Q"), "Exit", QuitProc},
130 MenuItem editMenu[] = {
131 {N_("Copy Game Ctrl+C"), "Copy Game", CopyGameProc},
132 {N_("Copy Position Ctrl+Shift+C"), "Copy Position", CopyPositionProc},
133 {N_("Copy Game List"), "Copy Game List", CopyGameListProc},
134 {"----", NULL, NothingProc},
135 {N_("Paste Game Ctrl+V"), "Paste Game", PasteGameProc},
136 {N_("Paste Position Ctrl+Shift+V"), "Paste Position", PastePositionProc},
137 {"----", NULL, NothingProc},
138 {N_("Edit Game Ctrl+E"), "Edit Game", EditGameEvent},
139 {N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionEvent},
140 {N_("Edit Tags"), "Edit Tags", EditTagsProc},
141 {N_("Edit Comment"), "Edit Comment", EditCommentProc},
142 {N_("Edit Book"), "Edit Book", EditBookEvent},
143 {"----", NULL, NothingProc},
144 {N_("Revert Home"), "Revert", RevertProc},
145 {N_("Annotate"), "Annotate", AnnotateProc},
146 {N_("Truncate Game End"), "Truncate Game", TruncateGameEvent},
147 {"----", NULL, NothingProc},
148 {N_("Backward Alt+Left"), "Backward", BackwardEvent},
149 {N_("Forward Alt+Right"), "Forward", ForwardEvent},
150 {N_("Back to Start Alt+Home"), "Back to Start", ToStartEvent},
151 {N_("Forward to End Alt+End"), "Forward to End", ToEndEvent},
155 MenuItem viewMenu[] = {
156 {N_("Flip View F2"), "Flip View", FlipViewProc},
157 {"----", NULL, NothingProc},
158 {N_("Engine Output Alt+Shift+O"), "Show Engine Output", EngineOutputProc},
159 {N_("Move History Alt+Shift+H"), "Show Move History", HistoryShowProc}, // [HGM] hist: activate 4.2.7 code
160 {N_("Evaluation Graph Alt+Shift+E"), "Show Evaluation Graph", EvalGraphProc},
161 {N_("Game List Alt+Shift+G"), "Show Game List", ShowGameListProc},
162 {N_("ICS text menu"), "ICStex", IcsTextProc},
163 {"----", NULL, NothingProc},
164 {N_("Tags"), "Show Tags", EditTagsProc},
165 {N_("Comments"), "Show Comments", EditCommentProc},
166 {N_("ICS Input Box"), "ICS Input Box", IcsInputBoxProc},
167 {"----", NULL, NothingProc},
168 {N_("Board..."), "Board Options", BoardOptionsProc},
169 {N_("Game List Tags..."), "Game List", GameListOptionsPopUp},
173 MenuItem modeMenu[] = {
174 {N_("Machine White Ctrl+W"), "Machine White", MachineWhiteEvent},
175 {N_("Machine Black Ctrl+B"), "Machine Black", MachineBlackEvent},
176 {N_("Two Machines Ctrl+T"), "Two Machines", TwoMachinesEvent},
177 {N_("Analysis Mode Ctrl+A"), "Analysis Mode", AnalyzeModeProc},
178 {N_("Analyze Game Ctrl+G"), "Analyze File", AnalyzeFileProc },
179 {N_("Edit Game Ctrl+E"), "Edit Game", EditGameEvent},
180 {N_("Edit Position Ctrl+Shift+E"), "Edit Position", EditPositionEvent},
181 {N_("Training"), "Training", TrainingEvent},
182 {N_("ICS Client"), "ICS Client", IcsClientEvent},
183 {"----", NULL, NothingProc},
184 {N_("Machine Match"), "Machine Match", MatchProc},
185 {N_("Pause Pause"), "Pause", PauseEvent},
189 MenuItem actionMenu[] = {
190 {N_("Accept F3"), "Accept", AcceptEvent},
191 {N_("Decline F4"), "Decline", DeclineEvent},
192 {N_("Rematch F12"), "Rematch", RematchEvent},
193 {"----", NULL, NothingProc},
194 {N_("Call Flag F5"), "Call Flag", CallFlagEvent},
195 {N_("Draw F6"), "Draw", DrawEvent},
196 {N_("Adjourn F7"), "Adjourn", AdjournEvent},
197 {N_("Abort F8"),"Abort", AbortEvent},
198 {N_("Resign F9"), "Resign", ResignEvent},
199 {"----", NULL, NothingProc},
200 {N_("Stop Observing F10"), "Stop Observing", StopObservingEvent},
201 {N_("Stop Examining F11"), "Stop Examining", StopExaminingEvent},
202 {N_("Upload to Examine"), "Upload to Examine", UploadGameEvent},
203 {"----", NULL, NothingProc},
204 {N_("Adjudicate to White"), "Adjudicate to White", AdjuWhiteProc},
205 {N_("Adjudicate to Black"), "Adjudicate to Black", AdjuBlackProc},
206 {N_("Adjudicate Draw"), "Adjudicate Draw", AdjuDrawProc},
210 MenuItem engineMenu[] = {
211 {N_("Load New Engine ..."), "Load Engine", LoadEngineProc},
212 {"----", NULL, NothingProc},
213 {N_("Engine #1 Settings ..."), "Engine #1 Settings", FirstSettingsProc},
214 {N_("Engine #2 Settings ..."), "Engine #2 Settings", SecondSettingsProc},
215 {"----", NULL, NothingProc},
216 {N_("Hint"), "Hint", HintEvent},
217 {N_("Book"), "Book", BookEvent},
218 {"----", NULL, NothingProc},
219 {N_("Move Now Ctrl+M"), "Move Now", MoveNowEvent},
220 {N_("Retract Move Ctrl+X"), "Retract Move", RetractMoveEvent},
224 MenuItem optionsMenu[] = {
226 {N_("General ..."), "General", OptionsProc},
228 {N_("Time Control ... Alt+Shift+T"), "Time Control", TimeControlProc},
229 {N_("Common Engine ... Alt+Shift+U"), "Common Engine", UciMenuProc},
230 {N_("Adjudications ... Alt+Shift+J"), "Adjudications", EngineMenuProc},
231 {N_("ICS ..."), "ICS", IcsOptionsProc},
232 {N_("Match ..."), "Match", MatchOptionsProc},
233 {N_("Load Game ..."), "Load Game", LoadOptionsProc},
234 {N_("Save Game ..."), "Save Game", SaveOptionsProc},
235 // {N_(" ..."), "", OptionsProc},
236 {N_("Game List ..."), "Game List", GameListOptionsPopUp},
237 {N_("Sounds ..."), "Sounds", SoundOptionsProc},
238 {"----", NULL, NothingProc},
239 #ifndef OPTIONSDIALOG
240 {N_("Always Queen Ctrl+Shift+Q"), "Always Queen", AlwaysQueenProc},
241 {N_("Animate Dragging"), "Animate Dragging", AnimateDraggingProc},
242 {N_("Animate Moving Ctrl+Shift+A"), "Animate Moving", AnimateMovingProc},
243 {N_("Auto Flag Ctrl+Shift+F"), "Auto Flag", AutoflagProc},
244 {N_("Auto Flip View"), "Auto Flip View", AutoflipProc},
245 {N_("Blindfold"), "Blindfold", BlindfoldProc},
246 {N_("Flash Moves"), "Flash Moves", FlashMovesProc},
248 {N_("Highlight Dragging"), "Highlight Dragging", HighlightDraggingProc},
250 {N_("Highlight Last Move"), "Highlight Last Move", HighlightLastMoveProc},
251 {N_("Highlight With Arrow"), "Arrow", HighlightArrowProc},
252 {N_("Move Sound"), "Move Sound", MoveSoundProc},
253 // {N_("ICS Alarm"), "ICS Alarm", IcsAlarmProc},
254 {N_("One-Click Moving"), "OneClick", OneClickProc},
255 {N_("Periodic Updates"), "Periodic Updates", PeriodicUpdatesProc},
256 {N_("Ponder Next Move Ctrl+Shift+P"), "Ponder Next Move", PonderNextMoveProc},
257 {N_("Popup Exit Message"), "Popup Exit Message", PopupExitMessageProc},
258 {N_("Popup Move Errors"), "Popup Move Errors", PopupMoveErrorsProc},
259 // {N_("Premove"), "Premove", PremoveProc},
260 {N_("Show Coords"), "Show Coords", ShowCoordsProc},
261 {N_("Hide Thinking Ctrl+Shift+H"), "Hide Thinking", HideThinkingProc},
262 {N_("Test Legality Ctrl+Shift+L"), "Test Legality", TestLegalityProc},
263 {"----", NULL, NothingProc},
265 {N_("Save Settings Now"), "Save Settings Now", SaveSettingsProc},
266 {N_("Save Settings on Exit"), "Save Settings on Exit", SaveOnExitProc},
270 MenuItem helpMenu[] = {
271 {N_("Info XBoard"), "Info XBoard", InfoProc},
272 {N_("Man XBoard F1"), "Man XBoard", ManProc},
273 {"----", NULL, NothingProc},
274 {N_("XBoard Home Page"), "Home Page", HomePageProc},
275 {N_("On-line User Guide"), "User Guide", GuideProc},
276 {N_("Development News"), "News Page", NewsPageProc},
277 {N_("e-Mail Bug Report"), "Bug Report", BugReportProc},
278 {"----", NULL, NothingProc},
279 {N_("About XBoard"), "About XBoard", AboutProc},
284 {N_("File"), "File", fileMenu},
285 {N_("Edit"), "Edit", editMenu},
286 {N_("View"), "View", viewMenu},
287 {N_("Mode"), "Mode", modeMenu},
288 {N_("Action"), "Action", actionMenu},
289 {N_("Engine"), "Engine", engineMenu},
290 {N_("Options"), "Options", optionsMenu},
291 {N_("Help"), "Help", helpMenu},
296 AppendEnginesToMenu (char *list)
301 if(appData.icsActive || appData.recentEngines <= 0) return;
302 recentEngines = strdup(list);
304 p = strchr(list, '\n'); if(p == NULL) break;
305 if(i == 0) AppendMenuItem("----", "----", NULL); // at least one valid item to add
307 AppendMenuItem(list, "recent", (MenuProc *) i);
308 i++; *p = '\n'; list = p + 1;
313 AddPullDownMenu (char *name, Menu *mb)
317 CreateMenuButton(name, mb);
320 while (mi->string != NULL) {
321 AppendMenuItem(mi->string, mi->ref, mi->proc);
322 menuItemList[nrOfMenuItems].name = mi->ref;
323 menuItemList[nrOfMenuItems].proc = mi->proc;
328 if(!strcmp(mb->name, "Engine")) AppendEnginesToMenu(appData.recentEngineList);
332 CreateMainMenus (Menu *mb)
334 char menuName[MSG_SIZ];
336 while (mb->name != NULL) {
337 safeStrCpy(menuName, "menu", sizeof(menuName)/sizeof(menuName[0]) );
338 strncat(menuName, mb->ref, MSG_SIZ - strlen(menuName) - 1);
339 AddPullDownMenu(menuName, mb++);