(xmenu_show):
[bpt/emacs.git] / lwlib / lwlib-Xaw.c
index efc287e..5a1c9d2 100644 (file)
@@ -15,7 +15,12 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdio.h>
 
@@ -35,7 +40,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include <X11/Xatom.h>
 
-static void xaw_generic_callback (Widget, XtPointer, XtPointer);
+static void xaw_generic_callback (/*Widget, XtPointer, XtPointer*/);
 
 
 Boolean
@@ -68,7 +73,7 @@ xaw_update_scrollbar (instance, widget, val)
                     XtNy, &pos_y,
                     XtNtopOfThumb, &widget_topOfThumb,
                     XtNshown, &widget_shown,
-                    0);
+                    NULL);
 
       /*
        * First size and position the scrollbar widget.
@@ -83,7 +88,7 @@ xaw_update_scrollbar (instance, widget, val)
          XtVaSetValues (widget,
                         XtNlength, data->scrollbar_height,
                         XtNthickness, width,
-                        0);
+                        NULL);
        }
 
       /*
@@ -118,18 +123,25 @@ xaw_update_one_widget (instance, widget, val, deep_p)
      widget_value *val;
      Boolean deep_p;
 {
+#if 0
   if (XtIsSubclass (widget, scrollbarWidgetClass))
     {
       xaw_update_scrollbar (instance, widget, val);
     }
-  else if (XtIsSubclass (widget, dialogWidgetClass))
+#endif
+  if (XtIsSubclass (widget, dialogWidgetClass))
     {
-      XtVaSetValues (widget, XtNlabel, val->contents->value, 0);
+      Arg al[1];
+      int ac = 0;
+      XtSetArg (al[ac], XtNlabel, val->contents->value); ac++;
+      XtSetValues (widget,  al, ac);
     }
   else if (XtIsSubclass (widget, commandWidgetClass))
     {
       Dimension bw = 0;
-      XtVaGetValues (widget, XtNborderWidth, &bw, 0);
+      Arg al[3];
+
+      XtVaGetValues (widget, XtNborderWidth, &bw, NULL);
       if (bw == 0)
        /* Don't let buttons end up with 0 borderwidth, that's ugly...
           Yeah, all this should really be done through app-defaults files
@@ -137,15 +149,16 @@ xaw_update_one_widget (instance, widget, val, deep_p)
           that I don't feel like opening right now.  Making Athena widgets
           not look like shit is just entirely too much work.
         */
-       XtVaSetValues (widget, XtNborderWidth, 1, 0);
-
-      XtVaSetValues (widget,
-                    XtNlabel, val->value,
-                    XtNsensitive, val->enabled,
-                    /* Force centered button text.  Se above. */
-                    XtNjustify, XtJustifyCenter,
-                    0);
+       {
+         XtSetArg (al[0], XtNborderWidth, 1);
+         XtSetValues (widget, al, 1);
+       }
 
+      XtSetArg (al[0], XtNlabel, val->value);
+      XtSetArg (al[1], XtNsensitive, val->enabled);
+      /* Force centered button text.  Se above. */
+      XtSetArg (al[2], XtNjustify, XtJustifyCenter);
+      XtSetValues (widget, al, 3);
       XtRemoveAllCallbacks (widget, XtNcallback);
       XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance);
     }
@@ -174,8 +187,9 @@ xaw_destroy_instance (instance)
 }
 
 void
-xaw_popup_menu (widget)
+xaw_popup_menu (widget, event)
      Widget widget;
+     XEvent *event;
 {
   /* An Athena menubar has not been implemented. */
   return;
@@ -212,8 +226,10 @@ xaw_pop_instance (instance, up)
             life easier?
           */
          {
-           int x, y, w, h;
+           unsigned int x, y, w, h;
            Widget topmost = instance->parent;
+           Arg args[2];
+
            w = shell->core.width;
            h = shell->core.height;
            while (topmost->core.parent && XtIsRealized (topmost->core.parent))
@@ -222,7 +238,12 @@ xaw_pop_instance (instance, up)
            else x = topmost->core.x + ((topmost->core.width - w) / 2);
            if (topmost->core.height < h) y = topmost->core.y;
            else y = topmost->core.y + ((topmost->core.height - h) / 2);
-           XtMoveWidget (shell, x, y);
+           /* Using XtMoveWidget caused the widget to come
+              out in the wrong place with vtwm.
+              Question of virtual vs real coords, perhaps.  */
+           XtSetArg (args[0], XtNx, x);
+           XtSetArg (args[1], XtNy, y);
+           XtSetValues (shell, args, 2);
          }
 
          /* Finally, pop it up. */
@@ -291,6 +312,10 @@ make_dialog (name, parent, pop_up_p, shell_title, icon_name, text_input_slot, ra
   ac = 0;
   XtSetArg (av[ac], XtNtitle, shell_title); ac++;
   XtSetArg (av[ac], XtNallowShellResize, True); ac++;
+
+  /* Don't allow any geometry request from the user.  */
+  XtSetArg (av[ac], XtNgeometry, 0); ac++;
+
   shell = XtCreatePopupShell ("dialog", transientShellWidgetClass,
                              parent, av, ac);
   XtOverrideTranslations (shell, override);
@@ -451,7 +476,7 @@ xaw_generic_callback (widget, closure, call_data)
 
 #if 0
   user_data = NULL;
-  XtVaGetValues (widget, XtNuserData, &user_data, 0);
+  XtVaGetValues (widget, XtNuserData, &user_data, NULL);
 #else
   /* Damn!  Athena doesn't give us a way to hang our own data on the
      buttons, so we have to go find it...  I guess this assumes that
@@ -481,16 +506,22 @@ wm_delete_window (shell, closure, call_data)
      XtPointer call_data;
 {
   LWLIB_ID id;
+  Cardinal nkids;
+  int i;
   Widget *kids = 0;
   Widget widget;
   if (! XtIsSubclass (shell, shellWidgetClass))
     abort ();
-  XtVaGetValues (shell, XtNchildren, &kids, 0);
+  XtVaGetValues (shell, XtNnumChildren, &nkids, NULL);
+  XtVaGetValues (shell, XtNchildren, &kids, NULL);
   if (!kids || !*kids)
     abort ();
-  widget = kids [0];
-  if (! XtIsSubclass (widget, dialogWidgetClass))
-    abort ();
+  for (i = 0; i < nkids; i++)
+    {
+      widget = kids[i];
+      if (XtIsSubclass (widget, dialogWidgetClass))
+       break;
+    }
   id = lw_get_widget_id (widget);
   if (! id) abort ();
 
@@ -576,7 +607,7 @@ xaw_create_scrollbar (instance)
   Dimension width;
   Widget scrollbar;
 
-  XtVaGetValues (instance->parent, XtNwidth, &width, 0);
+  XtVaGetValues (instance->parent, XtNwidth, &width, NULL);
   
   XtSetArg (av[ac], XtNshowGrip, 0); ac++;
   XtSetArg (av[ac], XtNresizeToPreferred, 1); ac++;
@@ -591,7 +622,7 @@ xaw_create_scrollbar (instance)
 
   /* We have to force the border width to be 0 otherwise the
      geometry manager likes to start looping for awhile... */
-  XtVaSetValues (scrollbar, XtNborderWidth, 0, 0);
+  XtVaSetValues (scrollbar, XtNborderWidth, 0, NULL);
 
   XtRemoveAllCallbacks (scrollbar, "jumpProc");
   XtRemoveAllCallbacks (scrollbar, "scrollProc");
@@ -605,9 +636,24 @@ xaw_create_scrollbar (instance)
 #endif
 }
 
+static Widget
+xaw_create_main (instance)
+     widget_instance *instance;
+{
+  Arg al[1];
+  int ac;
+
+  /* Create a vertical Paned to hold menubar */
+  ac = 0;
+  XtSetArg (al[ac], XtNborderWidth, 0); ac++;
+  return XtCreateWidget (instance->info->name, panedWidgetClass,
+                        instance->parent, al, ac);
+}
+
 widget_creation_entry
 xaw_creation_table [] =
 {
   {"scrollbar",                        xaw_create_scrollbar},
+  {"main",                     xaw_create_main},
   {NULL, NULL}
 };