1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
21 #include <X11/Intrinsic.h>
22 #include <X11/StringDefs.h>
23 #include <X11/Xaw/MenuButton.h>
24 #include <X11/Xaw/SimpleMenu.h>
25 #include <X11/Xaw/SmeBSB.h>
26 #include <X11/Xaw/SmeLine.h>
37 #include "government.h"
45 #include "client_main.h"
46 #include "climisc.h" /* can_units_do_connect */
48 #include "control.h" /* request_xxx and get_unit_in_focus */
53 #include "gui_stuff.h"
56 #include "messagedlg.h"
57 #include "messagewin.h"
58 #include "optiondlg.h"
64 #include "spaceshipdlg.h"
69 /* stuff for run-time mutable menu text */
71 #define MAX_LEN_TERR_NAME_DISP 9
72 #define MAX_VARIANTS 3
75 #define TEXT_ORDER_CITY_BUILD 0
76 #define TEXT_ORDER_CITY_ADD_TO 1
78 #define TEXT_ORDER_IRRIGATE 0
79 #define TEXT_ORDER_IRRIGATE_GENERIC 1
80 #define TEXT_ORDER_IRRIGATE_CHANGE_TO 2
82 #define TEXT_ORDER_MINE 0
83 #define TEXT_ORDER_MINE_GENERIC 1
84 #define TEXT_ORDER_MINE_CHANGE_TO 2
86 #define TEXT_ORDER_TRANSFORM_TERRAIN 0
87 #define TEXT_ORDER_TRANSFORM_TRANSFORM_TO 1
89 #define TEXT_ORDER_POLLUTION_POLLUTION 0
90 #define TEXT_ORDER_POLLUTION_PARADROP 1
92 /* The acel strings, is the string that show which is the acelerator key
93 * in the menus. No check is made to ensure that this is the acelerator
94 * key. This is use for translation-layout porpouses in i18n texts
98 char *text
[MAX_VARIANTS
+1];
99 char *acel
; /* Acelerator key */
105 Widget button
, shell
;
108 struct MenuEntry
*entries
;
111 static struct Menu
*menus
[MENU_LAST
];
113 static struct MenuEntry game_menu_entries
[]={
114 { { N_("Local Options"), 0 }, "", MENU_GAME_OPTIONS
, 0 },
115 { { N_("Message Options"), 0 }, "", MENU_GAME_MSG_OPTIONS
, 0 },
116 { { N_("Save Settings"), 0 }, "", MENU_GAME_SAVE_SETTINGS
, 0 },
117 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
118 { { N_("Server Options"), 0 }, "", MENU_GAME_SERVER_OPTIONS
, 0 },
119 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
120 { { N_("Export Log"), 0 }, "", MENU_GAME_OUTPUT_LOG
, 0 },
121 { { N_("Clear Log"), 0 }, "", MENU_GAME_CLEAR_OUTPUT
, 0 },
122 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
123 { { N_("Disconnect"), 0 }, "", MENU_GAME_DISCONNECT
, 0 },
124 { { N_("Quit"), 0 }, "Ctl-Q", MENU_GAME_QUIT
, 0 },
125 { { 0, }, 0, MENU_END_OF_LIST
, 0 }
128 static struct MenuEntry government_menu_entries
[]={
129 { { N_("Tax Rates..."), 0 }, "Ctl-T", MENU_GOVERNMENT_RATES
, 0 },
130 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
131 { { N_("Find City"), 0 }, "Ctl-F", MENU_GOVERNMENT_FIND_CITY
, 0 },
132 { { N_("Worklists"), 0 }, "Ctl-L", MENU_GOVERNMENT_WORKLISTS
, 0 },
133 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
134 { { N_("Revolution..."), 0 }, "Ctl-Shift-R", MENU_GOVERNMENT_REVOLUTION
, 0 },
135 { { 0, }, 0, MENU_END_OF_LIST
, 0 }
138 /* One entry for every government, appended to the government menu. */
139 static int num_government_entries
= 0;
140 static Widget government_widgets
[G_LAST
];
142 static struct MenuEntry view_menu_entries
[]={
143 { { N_("Map Grid"), 0 }, "ctl-g", MENU_VIEW_SHOW_MAP_GRID
, 0 },
144 { { N_("National Borders"), 0 }, "ctl-b",
145 MENU_VIEW_SHOW_NATIONAL_BORDERS
, 0 },
146 { { N_("City Names"), 0 }, "ctl-n", MENU_VIEW_SHOW_CITY_NAMES
, 0 },
147 { { N_("City Growth"), 0 }, "ctl-r",
148 MENU_VIEW_SHOW_CITY_GROWTH
, 0 },
149 { { N_("City Production Levels"), 0 }, "ctl-p", MENU_VIEW_SHOW_CITY_PRODUCTIONS
, 0 },
150 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
151 { { N_("Terrain"), 0 }, "", MENU_VIEW_SHOW_TERRAIN
, 0 },
152 { { N_("Coastline"), 0 }, "", MENU_VIEW_SHOW_COASTLINE
, 0 },
153 { { N_("Paths"), 0 }, "", MENU_VIEW_SHOW_PATHS
, 0 },
154 { { N_("Irrigation"), 0 }, "", MENU_VIEW_SHOW_IRRIGATION
, 0 },
155 { { N_("Mines"), 0 }, "", MENU_VIEW_SHOW_MINES
, 0 },
156 { { N_("Bases"), 0 }, "", MENU_VIEW_SHOW_BASES
, 0 },
157 { { N_("Resources"), 0 }, "", MENU_VIEW_SHOW_RESOURCES
, 0 },
158 { { N_("Huts"), 0 }, "", MENU_VIEW_SHOW_HUTS
, 0 },
159 { { N_("Pollution & Fallout"), 0 }, "", MENU_VIEW_SHOW_POLLUTION
, 0 },
160 { { N_("Cities"), 0 }, "", MENU_VIEW_SHOW_CITIES
, 0 },
161 { { N_("Units"), 0 }, "", MENU_VIEW_SHOW_UNITS
, 0 },
162 { { N_("Focus Unit"), 0 }, "", MENU_VIEW_SHOW_FOCUS_UNIT
, 0 },
163 { { N_("Fog of War"), 0 }, "", MENU_VIEW_SHOW_FOG_OF_WAR
, 0 },
164 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
165 { { N_("Center View"), 0 }, "c", MENU_VIEW_CENTER_VIEW
, 0 },
166 { { 0, }, 0, MENU_END_OF_LIST
, 0 }
169 static struct MenuEntry order_menu_entries
[]={
170 { { N_("Build City"),
171 N_("Add to City"), 0 }, "b", MENU_ORDER_BUILD_CITY
, 0 },
172 { { N_("Build Road"), 0 }, "r", MENU_ORDER_ROAD
, 0 },
174 N_("Build Irrigation"),
175 N_("Change to %s"), 0 }, "i", MENU_ORDER_IRRIGATE
, 0 },
178 N_("Change to %s"), 0 }, "m", MENU_ORDER_MINE
, 0 },
179 { { N_("Transform Terrain"),
180 N_("Transform to %s"), 0 }, "o", MENU_ORDER_TRANSFORM
, 0 },
181 { { N_("Build Fortress"), 0 }, "F", MENU_ORDER_FORTRESS
, 0 },
182 { { N_("Build Airbase"), 0 }, "E", MENU_ORDER_AIRBASE
, 0 },
183 { { N_("Clean Pollution"),
184 N_("Drop Paratrooper"), 0 }, "p", MENU_ORDER_POLLUTION
, 0 },
185 { { N_("Clean Nuclear Fallout"), 0}, "n", MENU_ORDER_FALLOUT
, 0 },
186 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
187 { { N_("Fortify Unit"), 0 }, "f", MENU_ORDER_FORTIFY
, 0 },
188 { { N_("Sentry Unit"), 0 }, "s", MENU_ORDER_SENTRY
, 0 },
189 { { N_("Pillage"), 0 }, "P", MENU_ORDER_PILLAGE
, 0 },
190 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
191 { { N_("Set Home City"), 0 }, "h", MENU_ORDER_HOMECITY
, 0 },
192 { { N_("Unload All From Transporter"), 0 }, "T",
193 MENU_ORDER_UNLOAD_TRANSPORTER
, 0 },
194 { { N_("Load Unit"), 0 }, "l", MENU_ORDER_LOAD
, 0 },
195 { { N_("Unload Unit"), 0 }, "u", MENU_ORDER_UNLOAD
, 0 },
196 { { N_("Unsentry All On Tile"), 0 }, "S", MENU_ORDER_WAKEUP_OTHERS
, 0 },
197 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
198 { { N_("Auto Settler"), 0 }, "a", MENU_ORDER_AUTO_SETTLER
, 0 },
199 { { N_("Auto Attack"), 0 }, "a", MENU_ORDER_AUTO_ATTACK
, 0 },
200 { { N_("Auto Explore"), 0 }, "x", MENU_ORDER_AUTO_EXPLORE
, 0 },
201 { { N_("Connect With Road"), 0 }, "R", MENU_ORDER_CONNECT_ROAD
, 0 },
202 { { N_("Connect With Rail"), 0 }, "L", MENU_ORDER_CONNECT_RAIL
, 0 },
203 { { N_("Connect With Irrigation"), 0 }, "I", MENU_ORDER_CONNECT_IRRIGATE
, 0 },
204 { { N_("Patrol"), 0 }, "q", MENU_ORDER_PATROL
, 0 },
205 { { N_("Go to Tile"), 0 }, "g", MENU_ORDER_GOTO
, 0 },
206 { { N_("Go to/Airlift to City..."), 0 }, "t", MENU_ORDER_GOTO_CITY
, 0 },
207 { { N_("Return to Nearest City"), 0 }, "G", MENU_ORDER_RETURN
, 0 },
208 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
209 { { N_("Convert Unit"), 0 }, "O", MENU_ORDER_CONVERT
, 0 },
210 { { N_("Disband Unit"), 0 }, "D", MENU_ORDER_DISBAND
, 0 },
211 { { N_("Help Build Wonder"), 0 }, "b", MENU_ORDER_BUILD_WONDER
, 0 },
212 { { N_("Establish Trade Route"), 0 }, "r", MENU_ORDER_TRADE_ROUTE
, 0 },
213 { { N_("Diplomat/Spy Actions"), 0 }, "d", MENU_ORDER_DIPLOMAT_DLG
, 0},
214 { { N_("Explode Nuclear"), 0 }, "N", MENU_ORDER_NUKE
, 0 },
215 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
216 { { N_("Select Same Type Everywhere"), 0 }, "X", MENU_ORDER_SELECT_SAME_TYPE
, 0 },
217 { { N_("Wait"), 0 }, "w", MENU_ORDER_WAIT
, 0 },
218 { { N_("Done"), 0 }, "spc", MENU_ORDER_DONE
, 0 },
219 { { 0, }, 0, MENU_END_OF_LIST
, 0 }
222 static struct MenuEntry reports_menu_entries
[]={
223 { { N_("Units"), 0 }, "F2", MENU_REPORT_UNITS
, 0 },
224 /* TRANS: Nations report action */
225 { { N_("Nations"), 0 }, "F3", MENU_REPORT_PLAYERS
, 0 },
226 { { N_("Cities"), 0 }, "F4", MENU_REPORT_CITIES
, 0 },
227 { { N_("Economy"), 0 }, "F5", MENU_REPORT_ECONOMY
, 0 },
228 /* TRANS: Research report action */
229 { { N_("Research"), 0 }, "F6", MENU_REPORT_SCIENCE
, 0 },
230 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
231 { { N_("Wonders of the World"), 0 }, "F7", MENU_REPORT_WOW
, 0 },
232 { { N_("Top Five Cities"), 0 }, "F8", MENU_REPORT_TOP_CITIES
, 0 },
233 { { N_("Messages"), 0 }, "F9", MENU_REPORT_MESSAGES
, 0 },
234 { { N_("Demographics"), 0 }, "F11", MENU_REPORT_DEMOGRAPHIC
, 0 },
235 { { N_("Spaceship"), 0 }, "F12", MENU_REPORT_SPACESHIP
, 0 },
236 { { N_("Achievements"), 0 }, "", MENU_REPORT_ACHIEVEMENTS
, 0},
237 { { 0, }, 0, MENU_END_OF_LIST
, 0 }
240 static struct MenuEntry editor_menu_entries
[] = {
241 { { N_("Editing Mode"), 0 }, "", MENU_EDITOR_TOGGLE
, 0 },
242 { { N_("Tools"), 0 }, "", MENU_EDITOR_TOOLS
, 0 },
243 { { 0, }, 0, MENU_END_OF_LIST
, 0 }
246 static struct MenuEntry help_menu_entries
[]={
247 /* TRANS: "Overview" topic in built-in help */
248 { { N_("?help:Overview"), 0 }, "", MENU_HELP_OVERVIEW
, 0 },
249 { { N_("Strategy and Tactics"), 0 }, "", MENU_HELP_PLAYING
, 0 },
250 { { N_("Terrain"), 0 }, "", MENU_HELP_TERRAIN
, 0 },
251 { { N_("Economy"), 0 }, "", MENU_HELP_ECONOMY
, 0 },
252 { { N_("Cities"), 0 }, "", MENU_HELP_CITIES
, 0 },
253 { { N_("City Improvements"), 0 }, "", MENU_HELP_IMPROVEMENTS
, 0 },
254 { { N_("Wonders of the World"), 0 }, "", MENU_HELP_WONDERS
, 0 },
255 { { N_("Units"), 0 }, "", MENU_HELP_UNITS
, 0 },
256 { { N_("Combat"), 0 }, "", MENU_HELP_COMBAT
, 0 },
257 { { N_("ZOC"), 0 }, "", MENU_HELP_ZOC
, 0 },
258 { { N_("Government"), 0 }, "", MENU_HELP_GOVERNMENT
, 0 },
259 { { N_("Diplomacy"), 0 }, "", MENU_HELP_DIPLOMACY
, 0 },
260 { { N_("Technology"), 0 }, "", MENU_HELP_TECH
, 0 },
261 { { N_("Space Race"), 0 }, "", MENU_HELP_SPACE_RACE
, 0 },
262 { { N_("About Ruleset"), 0 }, "", MENU_HELP_RULESET
, 0 },
263 { { N_("About Nations"), 0 }, "", MENU_HELP_NATIONS
, 0 },
264 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
265 { { N_("Connecting"), 0 }, "", MENU_HELP_CONNECTING
, 0 },
266 { { N_("Controls"), 0 }, "", MENU_HELP_CONTROLS
, 0 },
267 { { N_("Citizen Governor"), 0 }, "", MENU_HELP_CMA
, 0 },
268 { { N_("Chatline"), 0 }, "", MENU_HELP_CHATLINE
, 0 },
269 { { N_("Worklist Editor"), 0 }, "", MENU_HELP_WORKLIST_EDITOR
, 0 },
270 { { 0 }, "", MENU_SEPARATOR_LINE
, 0 },
271 { { N_("Languages"), 0 }, "", MENU_HELP_LANGUAGES
, 0 },
272 { { N_("Copying"), 0 }, "", MENU_HELP_COPYING
, 0 },
273 { { N_("About Freeciv"), 0 }, "", MENU_HELP_ABOUT
, 0 },
274 { { 0, }, 0, MENU_END_OF_LIST
, 0 }
278 static void create_menu(enum MenuIndex menu
, char *name
, struct MenuEntry entries
[],
279 void (*menucallback
)(Widget
, XtPointer
, XtPointer
),
281 static void menu_entry_sensitive(enum MenuIndex menu
, enum MenuID id
, Bool s
);
282 static void menu_entry_rename(enum MenuIndex menu
, enum MenuID id
, int var
,
284 static char *menu_entry_text(enum MenuIndex menu
, int ent
, int var
,
287 static void revolution_menu_callback(Widget w
, XtPointer client_data
,
290 /**************************************************************************
291 Initialize menus (sensitivity, name, etc.) based on the
292 current state and current ruleset, etc. Call menus_update().
293 **************************************************************************/
294 void real_menus_init(void)
299 /****************************************************************
301 *****************************************************************/
302 void real_menus_update(void)
304 if (!can_client_change_view()) {
305 XtSetSensitive(menus
[MENU_REPORT
]->button
, False
);
306 XtSetSensitive(menus
[MENU_ORDER
]->button
, False
);
307 XtSetSensitive(menus
[MENU_VIEW
]->button
, False
);
308 XtSetSensitive(menus
[MENU_GOVERNMENT
]->button
, False
);
310 menu_entry_sensitive(MENU_GAME
, MENU_GAME_OPTIONS
, 0);
311 menu_entry_sensitive(MENU_GAME
, MENU_GAME_MSG_OPTIONS
, 0);
312 menu_entry_sensitive(MENU_GAME
, MENU_GAME_SAVE_SETTINGS
, 0);
313 menu_entry_sensitive(MENU_GAME
, MENU_GAME_SERVER_OPTIONS
, 1);
314 menu_entry_sensitive(MENU_GAME
, MENU_GAME_OUTPUT_LOG
, 1);
315 menu_entry_sensitive(MENU_GAME
, MENU_GAME_CLEAR_OUTPUT
, 1);
318 int any_cities
= FALSE
;
320 players_iterate(pplayer
) {
321 if (city_list_size(pplayer
->cities
)) {
325 } players_iterate_end
;
327 XtSetSensitive(menus
[MENU_REPORT
]->button
, True
);
328 XtSetSensitive(menus
[MENU_VIEW
]->button
, True
);
329 XtSetSensitive(menus
[MENU_GOVERNMENT
]->button
, True
);
331 menu_entry_sensitive(MENU_GOVERNMENT
, MENU_GOVERNMENT_RATES
,
332 can_client_issue_orders());
333 menu_entry_sensitive(MENU_GOVERNMENT
, MENU_GOVERNMENT_WORKLISTS
,
334 can_client_issue_orders());
335 menu_entry_sensitive(MENU_GOVERNMENT
, MENU_GOVERNMENT_REVOLUTION
,
336 can_client_issue_orders());
338 /* Destroy all government-change entries and build them from scratch.
339 * This could probably be done more efficiently if it were only done
340 * when the client receives the rulesets or disconnects. */
341 for (i
= 0; i
< num_government_entries
; i
++) {
342 XtDestroyWidget(government_widgets
[i
]);
345 governments_iterate(pgovernment
) {
348 if (pgovernment
== game
.government_during_revolution
) {
352 w
= XtCreateManagedWidget(government_name_translation(pgovernment
),
354 menus
[MENU_GOVERNMENT
]->shell
, NULL
, 0);
355 XtAddCallback(w
, XtNcallback
, revolution_menu_callback
, pgovernment
);
356 XtSetSensitive(w
, can_change_to_government(client
.conn
.playing
,
359 government_widgets
[i
] = w
;
361 } governments_iterate_end
;
362 num_government_entries
= i
;
364 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_CITY_GROWTH
,
365 gui_options
.draw_city_names
);
366 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_TERRAIN
, 1);
367 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_COASTLINE
,
368 !gui_options
.draw_terrain
);
369 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_PATHS
, 1);
370 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_IRRIGATION
, 1);
371 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_MINES
, 1);
372 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_BASES
, 1);
373 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_RESOURCES
, 1);
374 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_HUTS
, 1);
375 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_POLLUTION
, 1);
376 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_CITIES
, 1);
377 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_UNITS
, 1);
378 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_FOCUS_UNIT
,
379 !gui_options
.draw_units
);
380 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_FOG_OF_WAR
, 1);
382 menu_entry_sensitive(MENU_GAME
, MENU_GAME_OPTIONS
, 1);
383 menu_entry_sensitive(MENU_GAME
, MENU_GAME_MSG_OPTIONS
, 1);
384 menu_entry_sensitive(MENU_GAME
, MENU_GAME_SAVE_SETTINGS
, 1);
385 menu_entry_sensitive(MENU_GAME
, MENU_GAME_SERVER_OPTIONS
, 1);
386 menu_entry_sensitive(MENU_GAME
, MENU_GAME_OUTPUT_LOG
, 1);
387 menu_entry_sensitive(MENU_GAME
, MENU_GAME_CLEAR_OUTPUT
, 1);
388 menu_entry_sensitive(MENU_GAME
, MENU_GAME_DISCONNECT
, 1);
390 if (NULL
!= client
.conn
.playing
) {
391 menu_entry_sensitive(MENU_REPORT
, MENU_REPORT_SPACESHIP
,
392 (SSHIP_NONE
!= client
.conn
.playing
->spaceship
.state
));
394 menu_entry_sensitive(MENU_REPORT
, MENU_REPORT_SPACESHIP
, 0);
397 if ((get_num_units_in_focus() > 0) && can_client_issue_orders()) {
398 struct terrain
*tinfo
;
399 struct tile
*ptile
= NULL
;
401 struct unit_list
*punits
= get_units_in_focus();
403 struct road_type
*proad
;
404 struct extra_type_list
*extras
;
406 XtSetSensitive(menus
[MENU_ORDER
]->button
, True
);
408 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_SELECT_SAME_TYPE
, True
);
410 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_BUILD_CITY
,
411 can_units_do(punits
, unit_can_add_or_build_city
));
412 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_ROAD
,
413 can_units_do_any_road(punits
));
414 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_IRRIGATE
,
415 can_units_do_activity(punits
, ACTIVITY_IRRIGATE
));
416 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_MINE
,
417 can_units_do_activity(punits
, ACTIVITY_MINE
));
418 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_TRANSFORM
,
419 can_units_do_activity(punits
, ACTIVITY_TRANSFORM
));
420 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_FORTRESS
,
421 can_units_do_base_gui(punits
, BASE_GUI_FORTRESS
));
422 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_AIRBASE
,
423 can_units_do_base_gui(punits
, BASE_GUI_AIRBASE
));
424 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_POLLUTION
,
425 can_units_do_activity(punits
, ACTIVITY_POLLUTION
)
426 || can_units_do(punits
, can_unit_paradrop
));
427 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_FALLOUT
,
428 can_units_do_activity(punits
, ACTIVITY_FALLOUT
));
429 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_FORTIFY
,
430 can_units_do_activity(punits
, ACTIVITY_FORTIFYING
));
431 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_SENTRY
,
432 can_units_do_activity(punits
, ACTIVITY_SENTRY
));
433 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_PILLAGE
,
434 can_units_do_activity(punits
, ACTIVITY_PILLAGE
));
435 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_HOMECITY
,
436 can_units_do(punits
, can_unit_change_homecity
));
437 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_UNLOAD_TRANSPORTER
,
438 units_are_occupied(punits
));
439 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_LOAD
,
440 units_can_load(punits
));
441 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_UNLOAD
,
442 units_can_unload(punits
));
443 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_WAKEUP_OTHERS
,
444 units_have_activity_on_tile(punits
,
446 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_AUTO_SETTLER
,
447 can_units_do(punits
, can_unit_do_autosettlers
));
448 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_AUTO_ATTACK
, false);
449 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_CONVERT
,
450 units_can_convert(punits
));
451 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_DISBAND
,
452 units_have_type_flag(punits
, UTYF_UNDISBANDABLE
,
454 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_AUTO_EXPLORE
,
455 can_units_do_activity(punits
, ACTIVITY_EXPLORE
));
457 proad
= road_by_compat_special(ROCO_ROAD
);
459 struct extra_type
*tgt
;
461 tgt
= road_extra_get(proad
);
463 conn_possible
= can_units_do_connect(punits
, ACTIVITY_GEN_ROAD
, tgt
);
465 conn_possible
= FALSE
;
467 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_CONNECT_ROAD
, conn_possible
);
469 proad
= road_by_compat_special(ROCO_RAILROAD
);
471 struct extra_type
*tgt
;
473 tgt
= road_extra_get(proad
);
475 conn_possible
= can_units_do_connect(punits
, ACTIVITY_GEN_ROAD
, tgt
);
477 conn_possible
= FALSE
;
479 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_CONNECT_RAIL
,
482 extras
= extra_type_list_by_cause(EC_IRRIGATION
);
484 if (extra_type_list_size(extras
) > 0) {
485 struct extra_type
*tgt
;
487 tgt
= extra_type_list_get(extras
, 0);
488 conn_possible
= can_units_do_connect(punits
, ACTIVITY_IRRIGATE
, tgt
);
490 conn_possible
= FALSE
;
493 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_CONNECT_IRRIGATE
, conn_possible
);
494 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_GOTO_CITY
,
496 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_BUILD_WONDER
,
498 unit_can_help_build_wonder_here
));
499 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_TRADE_ROUTE
,
501 unit_can_est_trade_route_here
));
502 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_DIPLOMAT_DLG
,
503 can_units_act_against_own_tile(punits
));
504 menu_entry_sensitive(MENU_ORDER
, MENU_ORDER_NUKE
,
505 units_have_type_flag(punits
, UTYF_NUCLEAR
, TRUE
));
507 /* FiXME: very odd, iterating for the first entry! */
508 unit_list_iterate(punits
, punit
) {
509 ptile
= unit_tile(punit
);
511 } unit_list_iterate_end
;
513 tinfo
= tile_terrain(ptile
);
514 can_build
= !(tile_city(ptile
));
516 if (units_contain_cityfounder(punits
)) {
518 menu_entry_rename(MENU_ORDER
, MENU_ORDER_BUILD_CITY
,
519 TEXT_ORDER_CITY_ADD_TO
, NULL
);
521 menu_entry_rename(MENU_ORDER
, MENU_ORDER_BUILD_CITY
,
522 TEXT_ORDER_CITY_BUILD
, NULL
);
526 if ((tinfo
->irrigation_result
!= T_NONE
)
527 && (tinfo
->irrigation_result
!= tinfo
)) {
528 menu_entry_rename(MENU_ORDER
, MENU_ORDER_IRRIGATE
,
529 TEXT_ORDER_IRRIGATE_CHANGE_TO
,
530 terrain_name_translation(tinfo
->irrigation_result
));
531 } else if (units_have_type_flag(punits
, UTYF_SETTLERS
, TRUE
)) {
532 struct extra_type
*pextra
= NULL
;
534 /* FIXME: this overloading doesn't work well with multiple focus
536 unit_list_iterate(punits
, punit
) {
537 pextra
= next_extra_for_tile(unit_tile(punit
), EC_IRRIGATION
,
538 unit_owner(punit
), punit
);
539 if (pextra
!= NULL
) {
542 } unit_list_iterate_end
;
544 if (pextra
!= NULL
) {
545 /* TRANS: Build irrigation of specific type */
546 menu_entry_rename(MENU_ORDER
, MENU_ORDER_IRRIGATE
,
547 TEXT_ORDER_IRRIGATE
, extra_name_translation(pextra
));
549 menu_entry_rename(MENU_ORDER
, MENU_ORDER_IRRIGATE
,
550 TEXT_ORDER_IRRIGATE_GENERIC
, NULL
);
554 if ((tinfo
->mining_result
!= T_NONE
)
555 && (tinfo
->mining_result
!= tinfo
)) {
556 menu_entry_rename(MENU_ORDER
, MENU_ORDER_MINE
,
557 TEXT_ORDER_MINE_CHANGE_TO
,
558 terrain_name_translation(tinfo
->mining_result
));
559 } else if (units_have_type_flag(punits
, UTYF_SETTLERS
, TRUE
)) {
560 struct extra_type
*pextra
= NULL
;
562 /* FIXME: this overloading doesn't work well with multiple focus
564 unit_list_iterate(punits
, punit
) {
565 pextra
= next_extra_for_tile(unit_tile(punit
), EC_MINE
,
566 unit_owner(punit
), punit
);
567 if (pextra
!= NULL
) {
570 } unit_list_iterate_end
;
572 if (pextra
!= NULL
) {
573 /* TRANS: Build mine of specific type */
574 menu_entry_rename(MENU_ORDER
, MENU_ORDER_MINE
,
575 TEXT_ORDER_MINE
, extra_name_translation(pextra
));
577 menu_entry_rename(MENU_ORDER
, MENU_ORDER_MINE
,
578 TEXT_ORDER_MINE_GENERIC
, NULL
);
582 if ((tinfo
->transform_result
!= T_NONE
)
583 && (tinfo
->transform_result
!= tinfo
)) {
584 menu_entry_rename(MENU_ORDER
, MENU_ORDER_TRANSFORM
,
585 TEXT_ORDER_TRANSFORM_TRANSFORM_TO
,
586 terrain_name_translation(tinfo
->transform_result
));
588 menu_entry_rename(MENU_ORDER
, MENU_ORDER_TRANSFORM
,
589 TEXT_ORDER_TRANSFORM_TERRAIN
, NULL
);
592 if (units_have_type_flag(punits
, UTYF_PARATROOPERS
, TRUE
)) {
593 menu_entry_rename(MENU_ORDER
, MENU_ORDER_POLLUTION
,
594 TEXT_ORDER_POLLUTION_PARADROP
, NULL
);
596 menu_entry_rename(MENU_ORDER
, MENU_ORDER_POLLUTION
,
597 TEXT_ORDER_POLLUTION_POLLUTION
, NULL
);
603 /****************************************************************
605 *****************************************************************/
606 static void game_menu_callback(Widget w
, XtPointer client_data
,
609 size_t pane_num
= (size_t)client_data
;
612 case MENU_GAME_OPTIONS
:
613 option_dialog_popup(_("Local Options"), client_optset
);
615 case MENU_GAME_MSG_OPTIONS
:
616 popup_messageopt_dialog();
618 case MENU_GAME_SAVE_SETTINGS
:
621 case MENU_GAME_SERVER_OPTIONS
:
622 option_dialog_popup(_("Game Settings"), server_optset
);
624 case MENU_GAME_OUTPUT_LOG
:
627 case MENU_GAME_CLEAR_OUTPUT
:
628 clear_output_window();
630 case MENU_GAME_DISCONNECT
:
631 disconnect_from_server();
639 /****************************************************************
641 *****************************************************************/
642 static void government_menu_callback(Widget w
, XtPointer client_data
,
645 size_t pane_num
= (size_t)client_data
;
648 case MENU_GOVERNMENT_FIND_CITY
:
651 case MENU_GOVERNMENT_RATES
:
652 popup_rates_dialog();
654 case MENU_GOVERNMENT_WORKLISTS
:
655 popup_worklists_dialog(client
.conn
.playing
);
657 case MENU_GOVERNMENT_REVOLUTION
:
658 popup_revolution_dialog(NULL
);
663 /****************************************************************************
664 Callback for the government change entries in the government menu.
665 ****************************************************************************/
666 static void revolution_menu_callback(Widget w
, XtPointer client_data
,
669 struct government
*pgovernment
= client_data
;
671 if (!can_client_issue_orders()) {
674 if (-1 == client
.conn
.playing
->revolution_finishes
) {
675 popup_revolution_dialog(pgovernment
);
677 /* Player already has a revolution and should just choose a government */
678 set_government_choice(pgovernment
);
682 /****************************************************************
684 *****************************************************************/
685 static void view_menu_callback(Widget w
, XtPointer client_data
,
688 size_t pane_num
= (size_t)client_data
;
691 case MENU_VIEW_SHOW_MAP_GRID
:
692 key_map_grid_toggle();
694 case MENU_VIEW_SHOW_NATIONAL_BORDERS
:
695 key_map_borders_toggle();
697 case MENU_VIEW_SHOW_CITY_NAMES
:
698 key_city_names_toggle();
699 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_CITY_GROWTH
,
700 gui_options
.draw_city_names
);
702 case MENU_VIEW_SHOW_CITY_GROWTH
:
703 key_city_growth_toggle();
705 case MENU_VIEW_SHOW_CITY_PRODUCTIONS
:
706 key_city_productions_toggle();
708 case MENU_VIEW_SHOW_TERRAIN
:
709 key_terrain_toggle();
710 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_COASTLINE
,
711 !gui_options
.draw_terrain
);
713 case MENU_VIEW_SHOW_COASTLINE
:
714 key_coastline_toggle();
716 case MENU_VIEW_SHOW_PATHS
:
717 key_roads_rails_toggle();
719 case MENU_VIEW_SHOW_IRRIGATION
:
720 key_irrigation_toggle();
722 case MENU_VIEW_SHOW_MINES
:
725 case MENU_VIEW_SHOW_BASES
:
728 case MENU_VIEW_SHOW_RESOURCES
:
729 key_resources_toggle();
731 case MENU_VIEW_SHOW_HUTS
:
734 case MENU_VIEW_SHOW_POLLUTION
:
735 key_pollution_toggle();
737 case MENU_VIEW_SHOW_CITIES
:
740 case MENU_VIEW_SHOW_UNITS
:
742 menu_entry_sensitive(MENU_VIEW
, MENU_VIEW_SHOW_FOCUS_UNIT
,
743 !gui_options
.draw_units
);
745 case MENU_VIEW_SHOW_FOCUS_UNIT
:
746 key_focus_unit_toggle();
748 case MENU_VIEW_SHOW_FOG_OF_WAR
:
749 key_fog_of_war_toggle();
751 case MENU_VIEW_CENTER_VIEW
:
752 request_center_focus_unit();
757 /****************************************************************
758 Order selected from the orders menu.
759 *****************************************************************/
760 static void orders_menu_callback(Widget w
, XtPointer client_data
,
763 size_t pane_num
= (size_t)client_data
;
766 case MENU_ORDER_BUILD_CITY
:
767 key_unit_build_city();
769 case MENU_ORDER_ROAD
:
772 case MENU_ORDER_IRRIGATE
:
775 case MENU_ORDER_MINE
:
778 case MENU_ORDER_TRANSFORM
:
779 key_unit_transform();
781 case MENU_ORDER_FORTRESS
:
784 case MENU_ORDER_AIRBASE
:
787 case MENU_ORDER_POLLUTION
: /* or MENU_ORDER_PARADROP */
788 /* FIXME: This calls key_unit_paradrop() / key_unit_pollution()
789 * as many times as there's focus units while those functions
790 * themselves handle all focus units at once. */
791 unit_list_iterate(get_units_in_focus(), punit
) {
792 if (can_unit_paradrop(punit
)) {
795 key_unit_pollution();
797 } unit_list_iterate_end
;
799 case MENU_ORDER_FALLOUT
:
802 case MENU_ORDER_FORTIFY
:
805 case MENU_ORDER_SENTRY
:
808 case MENU_ORDER_PILLAGE
:
811 case MENU_ORDER_HOMECITY
:
814 case MENU_ORDER_UNLOAD_TRANSPORTER
:
815 key_unit_unload_all();
817 case MENU_ORDER_LOAD
:
818 unit_list_iterate(get_units_in_focus(), punit
) {
819 request_unit_load(punit
, NULL
, unit_tile(punit
));
820 } unit_list_iterate_end
;
822 case MENU_ORDER_UNLOAD
:
823 unit_list_iterate(get_units_in_focus(), punit
) {
824 request_unit_unload(punit
);
825 } unit_list_iterate_end
;
827 case MENU_ORDER_WAKEUP_OTHERS
:
828 key_unit_wakeup_others();
830 case MENU_ORDER_AUTO_SETTLER
:
831 key_unit_auto_settle();
833 case MENU_ORDER_AUTO_EXPLORE
:
834 key_unit_auto_explore();
836 case MENU_ORDER_CONNECT_ROAD
:
838 struct road_type
*proad
= road_by_compat_special(ROCO_ROAD
);
841 struct extra_type
*tgt
;
843 tgt
= road_extra_get(proad
);
845 key_unit_connect(ACTIVITY_GEN_ROAD
, tgt
);
849 case MENU_ORDER_CONNECT_RAIL
:
851 struct road_type
*proad
= road_by_compat_special(ROCO_RAILROAD
);
854 struct extra_type
*tgt
;
856 tgt
= road_extra_get(proad
);
858 key_unit_connect(ACTIVITY_GEN_ROAD
, tgt
);
862 case MENU_ORDER_CONNECT_IRRIGATE
:
864 struct extra_type_list
*extras
= extra_type_list_by_cause(EC_IRRIGATION
);
866 if (extra_type_list_size(extras
) > 0) {
867 struct extra_type
*pextra
;
869 pextra
= extra_type_list_get(extra_type_list_by_cause(EC_IRRIGATION
), 0);
871 key_unit_connect(ACTIVITY_IRRIGATE
, pextra
);
875 case MENU_ORDER_PATROL
:
878 case MENU_ORDER_GOTO
:
881 case MENU_ORDER_GOTO_CITY
:
882 if (get_num_units_in_focus() > 0)
885 case MENU_ORDER_RETURN
:
886 unit_list_iterate(get_units_in_focus(), punit
) {
887 request_unit_return(punit
);
888 } unit_list_iterate_end
;
890 case MENU_ORDER_CONVERT
:
893 case MENU_ORDER_DISBAND
:
894 popup_disband_dialog(get_units_in_focus());
896 case MENU_ORDER_BUILD_WONDER
:
897 key_unit_build_wonder();
899 case MENU_ORDER_TRADE_ROUTE
:
900 key_unit_trade_route();
902 case MENU_ORDER_DIPLOMAT_DLG
:
903 key_unit_action_select();
905 case MENU_ORDER_NUKE
:
908 case MENU_ORDER_SELECT_SAME_TYPE
:
909 request_unit_select(get_units_in_focus(), SELTYPE_SAME
, SELLOC_WORLD
);
911 case MENU_ORDER_WAIT
:
914 case MENU_ORDER_DONE
:
920 /****************************************************************
921 User has selected item from reports menu
922 *****************************************************************/
923 static void reports_menu_callback(Widget w
, XtPointer client_data
,
926 size_t pane_num
= (size_t)client_data
;
929 case MENU_REPORT_CITIES
:
930 city_report_dialog_popup(FALSE
);
932 case MENU_REPORT_UNITS
:
933 units_report_dialog_popup(FALSE
);
935 case MENU_REPORT_PLAYERS
:
936 popup_players_dialog(FALSE
);
938 case MENU_REPORT_ECONOMY
:
939 economy_report_dialog_popup(FALSE
);
941 case MENU_REPORT_SCIENCE
:
942 science_report_dialog_popup(FALSE
);
944 case MENU_REPORT_WOW
:
945 send_report_request(REPORT_WONDERS_OF_THE_WORLD
);
947 case MENU_REPORT_TOP_CITIES
:
948 send_report_request(REPORT_TOP_5_CITIES
);
950 case MENU_REPORT_MESSAGES
:
951 meswin_dialog_popup(FALSE
);
953 case MENU_REPORT_DEMOGRAPHIC
:
954 send_report_request(REPORT_DEMOGRAPHIC
);
956 case MENU_REPORT_ACHIEVEMENTS
:
957 send_report_request(REPORT_ACHIEVEMENTS
);
959 case MENU_REPORT_SPACESHIP
:
960 if (NULL
!= client
.conn
.playing
) {
961 popup_spaceship_dialog(client
.conn
.playing
);
967 /****************************************************************
968 Callback for Editor menu entries.
969 *****************************************************************/
970 static void editor_menu_callback(Widget w
, XtPointer client_data
,
973 size_t pane_num
= (size_t)client_data
;
976 case MENU_EDITOR_TOGGLE
:
979 case MENU_EDITOR_TOOLS
:
984 /****************************************************************
986 *****************************************************************/
987 static void help_menu_callback(Widget w
, XtPointer client_data
,
990 size_t pane_num
= (size_t)client_data
;
993 case MENU_HELP_LANGUAGES
:
994 popup_help_dialog_string(HELP_LANGUAGES_ITEM
);
996 case MENU_HELP_CONNECTING
:
997 popup_help_dialog_string(HELP_CONNECTING_ITEM
);
999 case MENU_HELP_CONTROLS
:
1000 popup_help_dialog_string(HELP_CONTROLS_ITEM
);
1003 popup_help_dialog_string(HELP_CMA_ITEM
);
1005 case MENU_HELP_CHATLINE
:
1006 popup_help_dialog_string(HELP_CHATLINE_ITEM
);
1008 case MENU_HELP_WORKLIST_EDITOR
:
1009 popup_help_dialog_string(HELP_WORKLIST_EDITOR_ITEM
);
1011 case MENU_HELP_OVERVIEW
:
1012 popup_help_dialog_string(HELP_OVERVIEW_ITEM
);
1014 case MENU_HELP_PLAYING
:
1015 popup_help_dialog_string(HELP_PLAYING_ITEM
);
1017 case MENU_HELP_ECONOMY
:
1018 popup_help_dialog_string(HELP_ECONOMY_ITEM
);
1020 case MENU_HELP_CITIES
:
1021 popup_help_dialog_string(HELP_CITIES_ITEM
);
1023 case MENU_HELP_IMPROVEMENTS
:
1024 popup_help_dialog_string(HELP_IMPROVEMENTS_ITEM
);
1026 case MENU_HELP_UNITS
:
1027 popup_help_dialog_string(HELP_UNITS_ITEM
);
1029 case MENU_HELP_COMBAT
:
1030 popup_help_dialog_string(HELP_COMBAT_ITEM
);
1033 popup_help_dialog_string(HELP_ZOC_ITEM
);
1035 case MENU_HELP_TECH
:
1036 popup_help_dialog_string(HELP_TECHS_ITEM
);
1038 case MENU_HELP_TERRAIN
:
1039 popup_help_dialog_string(HELP_TERRAIN_ITEM
);
1041 case MENU_HELP_WONDERS
:
1042 popup_help_dialog_string(HELP_WONDERS_ITEM
);
1044 case MENU_HELP_GOVERNMENT
:
1045 popup_help_dialog_string(HELP_GOVERNMENT_ITEM
);
1047 case MENU_HELP_DIPLOMACY
:
1048 popup_help_dialog_string(HELP_DIPLOMACY_ITEM
);
1050 case MENU_HELP_SPACE_RACE
:
1051 popup_help_dialog_string(HELP_SPACE_RACE_ITEM
);
1053 case MENU_HELP_RULESET
:
1054 popup_help_dialog_string(HELP_RULESET_ITEM
);
1056 case MENU_HELP_NATIONS
:
1057 popup_help_dialog_string(HELP_NATIONS_ITEM
);
1059 case MENU_HELP_COPYING
:
1060 popup_help_dialog_string(HELP_COPYING_ITEM
);
1062 case MENU_HELP_ABOUT
:
1063 popup_help_dialog_string(HELP_ABOUT_ITEM
);
1068 /****************************************************************
1070 *****************************************************************/
1071 void setup_menus(Widget parent_form
)
1073 create_menu(MENU_GAME
, "gamemenu",
1074 game_menu_entries
, game_menu_callback
,
1076 create_menu(MENU_GOVERNMENT
, "governmentmenu",
1077 government_menu_entries
, government_menu_callback
,
1079 create_menu(MENU_VIEW
, "viewmenu",
1080 view_menu_entries
, view_menu_callback
,
1082 create_menu(MENU_ORDER
, "ordersmenu",
1083 order_menu_entries
, orders_menu_callback
,
1085 create_menu(MENU_REPORT
, "reportsmenu",
1086 reports_menu_entries
, reports_menu_callback
,
1088 create_menu(MENU_EDITOR
, "editormenu",
1089 editor_menu_entries
, editor_menu_callback
,
1091 create_menu(MENU_HELP
, "helpmenu",
1092 help_menu_entries
, help_menu_callback
,
1096 /****************************************************************
1097 Determine whether menu item is active or not.
1098 *****************************************************************/
1099 int is_menu_item_active(enum MenuIndex menu
, enum MenuID id
)
1101 struct Menu
*pmenu
= menus
[menu
];
1104 for (i
= 0; pmenu
->entries
[i
].id
!= MENU_END_OF_LIST
; i
++) {
1105 if(pmenu
->entries
[i
].id
==id
) {
1106 return XtIsSensitive(pmenu
->entries
[i
].w
);
1113 /****************************************************************
1114 Create one of the main menus
1115 *****************************************************************/
1116 void create_menu(enum MenuIndex menu
, char *name
, struct MenuEntry entries
[],
1117 void (*menucallback
)(Widget
, XtPointer
, XtPointer
),
1121 struct Menu
*mymenu
;
1127 mymenu
=fc_malloc(sizeof(struct Menu
));
1129 mymenu
->entries
=entries
;
1131 /* Calculate the longest string in this menu so if the font
1132 * is fixed then we will know where to put the accelerator key.- Serrada */
1134 for (i
= 0; entries
[i
].id
!= MENU_END_OF_LIST
; i
++) {
1135 if (entries
[i
].id
!= MENU_SEPARATOR_LINE
) {
1136 lstr
=strlen(entries
[i
].acel
);
1140 for (j
= 0; entries
[i
].text
[j
]; j
++) {
1141 xlt
=Q_(entries
[i
].text
[j
]);
1143 if (strstr(xlt
, "%s")) {
1144 lstr
+=MAX_LEN_TERR_NAME_DISP
;
1152 if ((litem
>0) && (lacel
>0)) {
1153 litem
+=(ACEL_SPACE
/2);
1154 lacel
+=(ACEL_SPACE
-(ACEL_SPACE
/2));
1156 mymenu
->maxitemlen
=litem
;
1157 mymenu
->maxacellen
=lacel
;
1159 I_L(mymenu
->button
=XtVaCreateManagedWidget(name
,
1160 menuButtonWidgetClass
,
1164 mymenu
->shell
=XtCreatePopupShell("menu", simpleMenuWidgetClass
,
1165 mymenu
->button
, NULL
, 0);
1167 for (i
= 0; entries
[i
].id
!= MENU_END_OF_LIST
; i
++) {
1168 if (entries
[i
].id
== MENU_SEPARATOR_LINE
) {
1169 entries
[i
].w
= XtCreateManagedWidget(NULL
, smeLineObjectClass
,
1170 mymenu
->shell
, NULL
, 0);
1172 xlt
=menu_entry_text(menu
, i
, 0, "");
1173 entries
[i
].w
= XtCreateManagedWidget(xlt
, smeBSBObjectClass
,
1174 mymenu
->shell
, NULL
, 0);
1175 XtAddCallback(entries
[i
].w
, XtNcallback
, menucallback
,
1176 (XtPointer
)entries
[i
].id
);
1183 /****************************************************************
1185 *****************************************************************/
1186 void menu_entry_rename(enum MenuIndex menu
, enum MenuID id
, int var
,
1189 struct Menu
*pmenu
= menus
[menu
];
1193 for (i
= 0; pmenu
->entries
[i
].id
!= MENU_END_OF_LIST
; i
++) {
1194 if (pmenu
->entries
[i
].id
== id
) {
1195 item
= menu_entry_text(menu
, i
, var
, terr
);
1196 XtVaSetValues(pmenu
->entries
[i
].w
, XtNlabel
, item
, NULL
);
1202 /****************************************************************
1204 *****************************************************************/
1205 void menu_entry_sensitive(enum MenuIndex menu
, enum MenuID id
, Bool s
)
1207 struct Menu
*pmenu
= menus
[menu
];
1210 for (i
= 0; pmenu
->entries
[i
].id
!= MENU_END_OF_LIST
; i
++) {
1211 if(pmenu
->entries
[i
].id
==id
) {
1212 XtSetSensitive(pmenu
->entries
[i
].w
, (s
? True
: False
));
1218 /****************************************************************
1220 *****************************************************************/
1221 static char *menu_entry_text(enum MenuIndex menu
, int ent
, int var
,
1224 struct Menu
*pmenu
= menus
[menu
];
1225 static char retbuf
[256];
1229 xlt
=Q_(pmenu
->entries
[ent
].text
[var
]);
1231 if (strstr(xlt
, "%s")) {
1232 fc_snprintf(tmp
, sizeof(tmp
), xlt
, terr
);
1236 fc_snprintf(retbuf
, sizeof(retbuf
), "%*.*s%*.*s",
1237 -pmenu
->maxitemlen
, pmenu
->maxitemlen
, xlt
,
1238 pmenu
->maxacellen
, pmenu
->maxacellen
, pmenu
->entries
[ent
].acel
);