Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
[Freeciv-Dev] patch: "View" menu in Xaw
Home

[Freeciv-Dev] patch: "View" menu in Xaw

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] patch: "View" menu in Xaw
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sun, 9 May 1999 21:29:25 +1000 (EST)

This patch adds a "View" menu to the Xaw client, with (essentially) the
same items as the Gtk client: Grid On/Off (Ctl-g), and Center View (c).

Hmm, I wonder if draw_map_grid should be a normal client option 
(as well as toggled via ctl-g).  Then it would also show up in 
the options menu, but, more importantly, could be saved.  
I guess it depends if anyone would want to have draw_map_grid=1 
all the time...

(Oops, just noticed a minor nit: the "Center View" option should
be turned off if there is no current focus unit...  This nit
applies to the gtk client too.)

-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/mapctrl.c 
freeciv-mod/client/gui-xaw/mapctrl.c
--- freeciv-cvs/client/gui-xaw/mapctrl.c        Mon Apr 26 17:07:18 1999
+++ freeciv-mod/client/gui-xaw/mapctrl.c        Wed May  5 18:27:22 1999
@@ -423,13 +423,17 @@
 /**************************************************************************
   Toggle display of grid lines on the map
 **************************************************************************/
-void key_map_grid(Widget w, XEvent *event, String *argv, Cardinal *argc)
+void request_toggle_map_grid(void) 
 {
   if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) return;
 
   draw_map_grid^=1;
   update_map_canvas(0,0, map_canvas_store_twidth,map_canvas_store_theight, 1);
 }
+void key_map_grid(Widget w, XEvent *event, String *argv, Cardinal *argc)
+{
+  request_toggle_map_grid();
+}
 
 /**************************************************************************
 ...
@@ -913,12 +917,16 @@
 /**************************************************************************
 ...
 **************************************************************************/
-void center_on_unit(Widget w, XEvent *event, String *argv, Cardinal *argc)
+void request_center_focus_unit(void)
 {
   struct unit *punit;
   
   if((punit=get_unit_in_focus()))
     center_tile_mapcanvas(punit->x, punit->y);
+}
+void center_on_unit(Widget w, XEvent *event, String *argv, Cardinal *argc)
+{
+  request_center_focus_unit();
 }
 
 
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/mapctrl.h 
freeciv-mod/client/gui-xaw/mapctrl.h
--- freeciv-cvs/client/gui-xaw/mapctrl.h        Tue Apr 13 20:53:13 1999
+++ freeciv-mod/client/gui-xaw/mapctrl.h        Wed May  5 18:28:01 1999
@@ -30,6 +30,8 @@
 void request_unit_auto(struct unit *punit);
 void request_unit_unload(struct unit *punit);
 void request_unit_wakeup(struct unit *punit);
+void request_center_focus_unit(void);
+void request_toggle_map_grid(void);
 
 void request_new_unit_activity(struct unit *punit, enum unit_activity act);
 
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/menu.c 
freeciv-mod/client/gui-xaw/menu.c
--- freeciv-cvs/client/gui-xaw/menu.c   Wed Apr 28 14:01:58 1999
+++ freeciv-mod/client/gui-xaw/menu.c   Wed May  5 18:31:18 1999
@@ -59,6 +59,9 @@
   MENU_GAME_CLEAR_OUTPUT,
   MENU_GAME_DISCONNECT,
   MENU_GAME_QUIT,
+
+  MENU_VIEW_SHOW_MAP_GRID,
+  MENU_VIEW_CENTER_VIEW,
   
   MENU_ORDER_AUTO_SETTLER,
   MENU_ORDER_AUTO_ATTACK,
@@ -120,7 +123,7 @@
   struct MenuEntry *entries;
 };
 
-struct Menu *game_menu, *orders_menu, *reports_menu, *help_menu;
+struct Menu *game_menu, *view_menu, *orders_menu, *reports_menu, *help_menu;
 
 
 struct MenuEntry game_menu_entries[]={
@@ -138,7 +141,13 @@
     { "Clear log",      MENU_GAME_CLEAR_OUTPUT, 0 },
     { "Disconnect",     MENU_GAME_DISCONNECT, 0 }, /* added by Syela */
     { "Quit",           MENU_GAME_QUIT, 0 },
-    { 0, MENU_END_OF_LIST, 0 },
+    { 0, MENU_END_OF_LIST, 0 }
+};
+
+struct MenuEntry view_menu_entries[]={
+    { "Grid On/Off  ctl-G",   MENU_VIEW_SHOW_MAP_GRID, 0 },
+    { "Center View      c",   MENU_VIEW_CENTER_VIEW, 0 },
+    { 0, MENU_END_OF_LIST, 0 }
 };
 
 struct MenuEntry order_menu_entries[]={
@@ -214,6 +223,7 @@
   if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
     XtVaSetValues(reports_menu->button, XtNsensitive, False, NULL);
     XtVaSetValues(orders_menu->button, XtNsensitive, False, NULL);
+    XtVaSetValues(view_menu->button, XtNsensitive, False, NULL);
 
     menu_entry_sensitive(game_menu, MENU_GAME_FIND_CITY, 0);
     menu_entry_sensitive(game_menu, MENU_GAME_OPTIONS, 0);
@@ -234,6 +244,7 @@
     struct unit *punit;
     XtVaSetValues(reports_menu->button, XtNsensitive, True, NULL);
     XtVaSetValues(orders_menu->button, XtNsensitive, True, NULL);
+    XtVaSetValues(view_menu->button, XtNsensitive, True, NULL);
   
     menu_entry_sensitive(game_menu, MENU_GAME_FIND_CITY, 1);
     menu_entry_sensitive(game_menu, MENU_GAME_OPTIONS, 1);
@@ -428,6 +439,24 @@
 /****************************************************************
 ...
 *****************************************************************/
+void view_menu_callback(Widget w, XtPointer client_data, XtPointer garbage)
+{
+  size_t pane_num = (size_t)client_data;
+
+  switch(pane_num) {
+  case MENU_VIEW_SHOW_MAP_GRID:
+    request_toggle_map_grid();
+    break;
+  case MENU_VIEW_CENTER_VIEW:
+    request_center_focus_unit();
+    break;
+  }
+}
+
+
+/****************************************************************
+...
+*****************************************************************/
 void orders_menu_callback(Widget w, XtPointer client_data, XtPointer garbage)
 {
   size_t pane_num = (size_t)client_data;
@@ -625,6 +654,9 @@
 {
   game_menu=create_menu("gamemenu", 
                        game_menu_entries, game_menu_callback, 
+                       parent_form);
+  view_menu=create_menu("viewmenu", 
+                       view_menu_entries, view_menu_callback, 
                        parent_form);
   orders_menu=create_menu("ordersmenu", 
                          order_menu_entries, orders_menu_callback, 
diff -u -r --exclude-from exclude freeciv-cvs/data/Freeciv 
freeciv-mod/data/Freeciv
--- freeciv-cvs/data/Freeciv    Sat May  1 14:07:25 1999
+++ freeciv-mod/data/Freeciv    Wed May  5 18:35:06 1999
@@ -1646,11 +1646,14 @@
 ! menues
 !
 Freeciv*gamemenu.label:                 Game
+Freeciv*viewmenu.label:                 View
 Freeciv*ordersmenu.label:               Orders
 Freeciv*reportsmenu.label:              Reports
 Freeciv*helpmenu.label:                 Help
 Freeciv*gamemenu.background:            Blue
 Freeciv*gamemenu.foreground:            White
+Freeciv*viewmenu.background:            Blue
+Freeciv*viewmenu.foreground:            White
 Freeciv*ordersmenu.background:          Blue
 Freeciv*ordersmenu.foreground:          White
 Freeciv*reportsmenu.background:         Blue
@@ -1658,12 +1661,16 @@
 Freeciv*helpmenu.background:            Blue
 Freeciv*helpmenu.foreground:            White
 Freeciv*gamemenu.borderWidth:           0
+Freeciv*viewmenu.borderWidth:           0
 Freeciv*ordersmenu.borderWidth:         0
 Freeciv*reportsmenu.borderWidth:        0
 Freeciv*helpmenu.borderWidth:           0
 Freeciv*gamemenu.left:                  chainLeft
 Freeciv*gamemenu.right:                 chainLeft
-Freeciv*ordersmenu.fromHoriz:           gamemenu
+Freeciv*viewmenu.fromHoriz:             gamemenu
+Freeciv*viewmenu.left:                  chainLeft
+Freeciv*viewmenu.right:                 chainLeft
+Freeciv*ordersmenu.fromHoriz:           viewmenu
 Freeciv*ordersmenu.left:                chainLeft
 Freeciv*ordersmenu.right:               chainLeft
 Freeciv*reportsmenu.fromHoriz:          ordersmenu
--- freeciv-cvs/client/gui-xaw/Freeciv.h        Sat May  1 14:07:25 1999
+++ mod-xaw/client/gui-xaw/Freeciv.h    Wed May  5 18:35:25 1999
@@ -1269,11 +1269,14 @@
 "Freeciv*reportactiveunitsupgradecommand.left:        chainLeft",
 "Freeciv*reportactiveunitsupgradecommand.right:       chainLeft",
 "Freeciv*gamemenu.label:                 Game",
+"Freeciv*viewmenu.label:                 View",
 "Freeciv*ordersmenu.label:               Orders",
 "Freeciv*reportsmenu.label:              Reports",
 "Freeciv*helpmenu.label:                 Help",
 "Freeciv*gamemenu.background:            Blue",
 "Freeciv*gamemenu.foreground:            White",
+"Freeciv*viewmenu.background:            Blue",
+"Freeciv*viewmenu.foreground:            White",
 "Freeciv*ordersmenu.background:          Blue",
 "Freeciv*ordersmenu.foreground:          White",
 "Freeciv*reportsmenu.background:         Blue",
@@ -1281,12 +1284,16 @@
 "Freeciv*helpmenu.background:            Blue",
 "Freeciv*helpmenu.foreground:            White",
 "Freeciv*gamemenu.borderWidth:           0",
+"Freeciv*viewmenu.borderWidth:           0",
 "Freeciv*ordersmenu.borderWidth:         0",
 "Freeciv*reportsmenu.borderWidth:        0",
 "Freeciv*helpmenu.borderWidth:           0",
 "Freeciv*gamemenu.left:                  chainLeft",
 "Freeciv*gamemenu.right:                 chainLeft",
-"Freeciv*ordersmenu.fromHoriz:           gamemenu",
+"Freeciv*viewmenu.fromHoriz:             gamemenu",
+"Freeciv*viewmenu.left:                  chainLeft",
+"Freeciv*viewmenu.right:                 chainLeft",
+"Freeciv*ordersmenu.fromHoriz:           viewmenu",
 "Freeciv*ordersmenu.left:                chainLeft",
 "Freeciv*ordersmenu.right:               chainLeft",
 "Freeciv*reportsmenu.fromHoriz:          ordersmenu",

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patch: "View" menu in Xaw, David Pfitzner <=