XEmacs 21.4.7 "Economic Science".
[chise/xemacs-chise.git.1] / lwlib / lwlib-Xm.c
index 76d893d..64ea878 100644 (file)
@@ -219,6 +219,10 @@ xm_update_label (widget_instance* instance, Widget widget, widget_value* val)
 
   if (val->value)
     {
+      /* #### Temporary fix. I though Motif was supposed to grok %_
+         type things. */
+      lw_remove_accelerator_spec (val->value);
+  
 #ifdef LWLIB_DIALOGS_MOTIF
       /*
        * Sigh.  The main text of a label is the name field for menubar
@@ -255,18 +259,18 @@ xm_update_label (widget_instance* instance, Widget widget, widget_value* val)
            {
              name_string =
                XmStringCreateLtoR (res_name, XmSTRING_DEFAULT_CHARSET);
-             
+
              value_name = XtMalloc (strlen (val->value) + 2);
              *value_name = 0;
              strcat (value_name, " ");
              strcat (value_name, val->value);
-             
+
              val_string =
                XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET);
-             
+
              built_string =
                XmStringConcat (name_string, val_string);
-             
+
              XtFree (value_name);
            }
        }
@@ -332,6 +336,36 @@ xm_update_pushbutton (widget_instance* instance, Widget widget,
   XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance);
 }
 
+static void
+xm_update_progress (widget_instance* instance, Widget scale,
+                     widget_value* val)
+{
+  Arg al[20];
+  int ac = 0;
+  Dimension height = 0;
+  Dimension width = 0;
+  if (!val->call_data)
+    {
+      XtSetArg (al [ac], XmNeditable, False);          ac++;
+    }
+  else
+    {
+      XtSetArg (al [ac], XmNeditable, val->enabled);           ac++;
+    }
+  height = (Dimension)lw_get_value_arg (val, XtNheight);
+  width = (Dimension)lw_get_value_arg (val, XtNwidth);
+  if (height > 0)
+    {
+      XtSetArg (al [ac], XmNscaleHeight, height); ac++;
+    }
+  if (width > 0)
+    {
+      XtSetArg (al [ac], XmNscaleWidth, width); ac++;
+    }
+
+  XtSetValues (scale, al, 1);
+}
+
 #ifdef LWLIB_MENUBARS_MOTIF
 
 static void
@@ -854,6 +888,10 @@ xm_update_one_widget (widget_instance* instance, Widget widget,
       xm_update_scrollbar (instance, widget, val);
     }
 #endif
+  else if (class == xmScaleWidgetClass)
+    {
+      xm_update_progress (instance, widget, val);
+    }
   /* Lastly update our global arg values. */
   if (val->args && val->args->nargs)
     XtSetValues (widget, val->args->args, val->args->nargs);
@@ -885,14 +923,14 @@ xm_update_one_value (widget_instance* instance, Widget widget,
   else if (class == xmTextWidgetClass)
     {
       if (val->value)
-       free (val->value);
+       XtFree (val->value);
       val->value = XmTextGetString (widget);
       val->edited = True;
     }
   else if (class == xmTextFieldWidgetClass)
     {
       if (val->value)
-       free (val->value);
+       XtFree (val->value);
       val->value = XmTextFieldGetString (widget);
       val->edited = True;
     }
@@ -908,7 +946,7 @@ xm_update_one_value (widget_instance* instance, Widget widget,
       if (radiobox)
        {
          CompositeWidget radio = (CompositeWidget)widget;
-         int i;
+         unsigned int i;
          for (i = 0; i < radio->composite.num_children; i++)
            {
              int set = False;
@@ -927,7 +965,7 @@ xm_update_one_value (widget_instance* instance, Widget widget,
          val->edited = True;
        }
     }
-  else if (class == xmListWidgetClass 
+  else if (class == xmListWidgetClass
 #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1
           || class == xmComboBoxWidgetClass
 #endif
@@ -1140,7 +1178,7 @@ make_dialog (char* name, Widget parent, Boolean pop_up_p,
       n_children++;
     }
 
-  /* invisible seperator button */
+  /* invisible separator button */
   ac = 0;
   XtSetArg (al[ac], XmNmappedWhenManaged, FALSE); ac++;
   children [n_children] = XmCreateLabel (row, "separator_button",
@@ -1256,10 +1294,11 @@ make_dialog (char* name, Widget parent, Boolean pop_up_p,
       XtSetArg(al[ac], XmNrightOffset, 13);                    ac++;
       value = XmCreateScrolledList (form, "list", al, ac);
 
-      /* this is the easiest way I found to have the dble click in the
+      /* this is the easiest way I found to have the double click in the
         list activate the default button */
       XtAddCallback (value, XmNdefaultActionCallback, activate_button, button);
     }
+  /* else add nothing; it's a separator */
 
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING);       ac++;
@@ -1297,11 +1336,12 @@ make_dialog (char* name, Widget parent, Boolean pop_up_p,
       XtInstallAccelerators (value, button);
       XmProcessTraversal(value, XmTRAVERSE_CURRENT);
     }
-  else
+  else if (radio_box)
     {
       XtInstallAccelerators (form, button);
       XmProcessTraversal(value, XmTRAVERSE_CURRENT);
     }
+  /* else we don' need no STEENKIN' assellerators. */
 
 #ifdef DND_KLUDGE
   XtFree ((char *) dnd_override);
@@ -1645,20 +1685,18 @@ xm_create_progress (widget_instance *instance)
 {
   Arg al[20];
   int ac = 0;
+  Dimension height = 0;
+  Dimension width = 0;
   Widget scale = 0;
   widget_value* val = instance->info->val;
-#if 0          /* This looks too awful, although more correct. */
   if (!val->call_data)
     {
-      XtSetArg (al [ac], XmNsensitive, False);         ac++;
+      XtSetArg (al [ac], XmNeditable, False);          ac++;
     }
   else
     {
-      XtSetArg (al [ac], XmNsensitive, val->enabled);          ac++;
+      XtSetArg (al [ac], XmNeditable, val->enabled);           ac++;
     }
-#else
-  XtSetArg (al [ac], XmNsensitive, True);              ac++;
-#endif
   XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING);     ac++;
   XtSetArg (al [ac], XmNuserData, val->call_data);             ac++;
   XtSetArg (al [ac], XmNmappedWhenManaged, FALSE);     ac++;
@@ -1667,6 +1705,18 @@ xm_create_progress (widget_instance *instance)
      look ugly.  I think this may be a LessTif bug but for now we just
      get rid of it. */
   XtSetArg (al [ac], XmNhighlightThickness, (Dimension)0);ac++;
+  
+  height = (Dimension)lw_get_value_arg (val, XtNheight);
+  width = (Dimension)lw_get_value_arg (val, XtNwidth);
+  if (height > 0)
+    {
+      XtSetArg (al [ac], XmNscaleHeight, height); ac++;
+    }
+  if (width > 0)
+    {
+      XtSetArg (al [ac], XmNscaleWidth, width); ac++;
+    }
+
   /* add any args the user supplied for creation time */
   lw_add_value_args_to_args (val, al, &ac);
 
@@ -1688,7 +1738,7 @@ xm_create_text_field (widget_instance *instance)
   Widget text = 0;
   widget_value* val = instance->info->val;
 
-  XtSetArg (al [ac], XmNsensitive, val->enabled && val->call_data);            ac++;
+  XtSetArg (al [ac], XmNsensitive, val->enabled);              ac++;
   XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING);     ac++;
   XtSetArg (al [ac], XmNuserData, val->call_data);             ac++;
   XtSetArg (al [ac], XmNmappedWhenManaged, FALSE);     ac++;
@@ -1782,7 +1832,7 @@ xm_create_combo_box (widget_instance *instance)
 \f
 /* Table of functions to create widgets */
 
-widget_creation_entry
+const widget_creation_entry
 xm_creation_table [] =
 {
 #ifdef LWLIB_MENUBARS_MOTIF