(U-0002195D): Add `ideographic-structure'; add `sound@ja/on'; add
[chise/xemacs-chise.git.1] / lwlib / lwlib-Xaw.c
index 3ff9460..2fe4dc9 100644 (file)
@@ -33,22 +33,20 @@ Boston, MA 02111-1307, USA.  */
 #include <X11/Shell.h>
 
 #ifdef LWLIB_SCROLLBARS_ATHENA
-#include ATHENA_INCLUDE(Scrollbar.h)
+#include ATHENA_Scrollbar_h_
 #endif
 #ifdef LWLIB_DIALOGS_ATHENA
-#include ATHENA_INCLUDE(Dialog.h)
-#include ATHENA_INCLUDE(Form.h)
-#include ATHENA_INCLUDE(Command.h)
-#include ATHENA_INCLUDE(Label.h)
+#include ATHENA_Dialog_h_
+#include ATHENA_Form_h_
+#include ATHENA_Command_h_
+#include ATHENA_Label_h_
 #endif
 #ifdef LWLIB_WIDGETS_ATHENA
-#include ATHENA_INCLUDE(Toggle.h)
+#include ATHENA_Toggle_h_
 #include "xlwradio.h"
 #include "xlwcheckbox.h"
 #include "xlwgauge.h"
-#ifndef NEED_MOTIF
-#include ATHENA_INCLUDE(AsciiText.h)
-#endif
+#include ATHENA_AsciiText_h_
 #endif
 #include <X11/Xatom.h>
 
@@ -69,8 +67,8 @@ lw_xaw_widget_p (Widget widget)
          || XtIsSubclass (widget, labelWidgetClass)
          || XtIsSubclass (widget, toggleWidgetClass)
          || XtIsSubclass (widget, gaugeWidgetClass)
-#if 0
-         || XtIsSubclass (widget, textWidgetClass)
+#ifndef NEED_MOTIF
+         || XtIsSubclass (widget, asciiTextWidgetClass)
 #endif
 #endif
          );
@@ -126,9 +124,6 @@ void
 xaw_update_one_widget (widget_instance *instance, Widget widget,
                       widget_value *val, Boolean deep_p)
 {
-  if (val->args && val->args->nargs)
-    XtSetValues (widget, val->args->args, val->args->nargs);
-
   if (0)
     ;
 #ifdef LWLIB_SCROLLBARS_ATHENA
@@ -137,6 +132,13 @@ xaw_update_one_widget (widget_instance *instance, Widget widget,
       xaw_update_scrollbar (instance, widget, val);
     }
 #endif
+#ifdef LWLIB_WIDGETS_ATHENA
+#ifndef NEED_MOTIF
+  else if (XtIsSubclass (widget, asciiTextWidgetClass))
+      {
+      }
+#endif
+#endif
 #ifdef LWLIB_DIALOGS_ATHENA
   else if (XtIsSubclass (widget, dialogWidgetClass))
       {
@@ -175,6 +177,7 @@ xaw_update_one_widget (widget_instance *instance, Widget widget,
        }
 #endif /* ! LWLIB_DIALOGS_ATHENA3D */
 
+      lw_remove_accelerator_spec (val->value);
       XtSetArg (al [0], XtNlabel,     val->value);
       XtSetArg (al [1], XtNsensitive, val->enabled);
       /* Force centered button text.  See above. */
@@ -193,6 +196,9 @@ xaw_update_one_widget (widget_instance *instance, Widget widget,
 #endif /* LWLIB_WIDGETS_ATHENA */
     }
 #endif /* LWLIB_DIALOGS_ATHENA */
+  /* Lastly update our global arg values. */
+  if (val->args && val->args->nargs)
+    XtSetValues (widget, val->args->args, val->args->nargs);
 }
 
 void
@@ -220,11 +226,19 @@ xaw_update_one_value (widget_instance *instance, Widget widget,
 #ifndef NEED_MOTIF
   else if (XtIsSubclass (widget, asciiTextWidgetClass))
     {
-      Arg al [1];
-      if (val->value)
-       free (val->value);
-      XtSetArg (al [0], XtNstring, &val->value);
+      Arg al [2];
+      String buf = 0;
+      XtSetArg (al [0], XtNstring, &buf);
       XtGetValues (widget, al, 1);
+
+      if (val->value)
+       {
+         free (val->value);
+         val->value = 0;
+       }
+      /* I don't think this causes a leak. */
+      if (buf)
+       val->value = strdup (buf);
       val->edited = True;
     }
 #endif
@@ -583,11 +597,14 @@ wm_delete_window (Widget shell, XtPointer closure, XtPointer call_data)
     abort ();
   XtSetArg (al [0], XtNchildren, &kids);
   XtGetValues (shell, al, 1);
-  if (!kids || !*kids)
-    abort ();
-  widget = kids [0];
-  if (! XtIsSubclass (widget, dialogWidgetClass))
-    abort ();
+  if (!kids || !*kids) abort ();
+
+  for (widget = *kids;
+       widget && ! XtIsSubclass (widget, dialogWidgetClass);
+       widget = *++kids)
+    ;
+  if (!widget) abort ();
+
   id = lw_get_widget_id (widget);
   if (! id) abort ();
 
@@ -776,6 +793,8 @@ xaw_create_label (Widget parent, widget_value* val)
   /* Do it again for arguments that have no effect until the widget is realized. */
   ac = 0;
   lw_add_value_args_to_args (val, al, &ac);
+  if (ac > 20)
+    abort (); /* #### need assert macro in lwlib */
   XtSetValues (label, al, ac);
 
   return label;
@@ -788,7 +807,7 @@ xaw_create_progress (widget_instance *instance)
   int ac = 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], XtNsensitive, False);         ac++;
@@ -797,6 +816,10 @@ xaw_create_progress (widget_instance *instance)
     {
       XtSetArg (al [ac], XtNsensitive, val->enabled);          ac++;
     }
+#else
+  XtSetArg (al [ac], XtNsensitive, True);              ac++;
+#endif
+
   XtSetArg (al [ac], XtNmappedWhenManaged, FALSE);     ac++;
   XtSetArg (al [ac], XtNorientation, XtorientHorizontal);      ac++;
   XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++;
@@ -816,7 +839,8 @@ xaw_create_progress (widget_instance *instance)
   return scale;
 }
 
-#ifndef NEED_MOTIF
+#if defined(LWLIB_WIDGETS_ATHENA)
+#define TEXT_BUFFER_SIZE 128
 static Widget
 xaw_create_text_field (widget_instance *instance)
 {
@@ -825,25 +849,39 @@ xaw_create_text_field (widget_instance *instance)
   Widget text = 0;
   widget_value* val = instance->info->val;
 
-  XtSetArg (al [ac], XtNsensitive, val->enabled && val->call_data);            ac++;
+  XtSetArg (al [ac], XtNsensitive, val->enabled);              ac++;
   XtSetArg (al [ac], XtNmappedWhenManaged, FALSE);     ac++;
   XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);     ac++;
   XtSetArg (al [ac], XtNtype, XawAsciiString);         ac++;
   XtSetArg (al [ac], XtNeditType, XawtextEdit);                ac++;
+  XtSetArg (al [ac], XtNuseStringInPlace, False);              ac++;
+#if 0
+  XtSetArg (al [ac], XtNlength, TEXT_BUFFER_SIZE);     ac++;
+#endif
+  if (val->value)
+    {
+      XtSetArg (al [ac], XtNstring, val->value);               ac++;
+    }
 
   /* add any args the user supplied for creation time */
   lw_add_value_args_to_args (val, al, &ac);
 
   text = XtCreateManagedWidget (val->name, asciiTextWidgetClass,
                                      instance->parent, al, ac);
+
+  /* add the callback */
+  if (val->call_data)
+    XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance);
+
   XtManageChild (text);
 
   return text;
 }
 #endif
+
 #endif /* LWLIB_WIDGETS_ATHENA */
 
-widget_creation_entry
+const widget_creation_entry
 xaw_creation_table [] =
 {
 #ifdef LWLIB_SCROLLBARS_ATHENA
@@ -853,9 +891,7 @@ xaw_creation_table [] =
 #ifdef LWLIB_WIDGETS_ATHENA
   {"button",           xaw_create_button               },
   { "label",           xaw_create_label_field          },
-#ifndef NEED_MOTIF
   {"text-field",               xaw_create_text_field           },
-#endif
   {"progress",         xaw_create_progress             },
 #endif
   {NULL, NULL}