This should fix the openwound problems + cygwin b19 problems + I have
implemented images in buttons, edit fields and progress gauges. Examples in
glyph-tests.el
I will apply this to cvs.
andy
1999-06-28 Andy Piper <andy(a)xemacs.org>
* lwlib-Xm.c: unconditionally enable text field & list code.
(make_progress): new function. creates a slider.
(make_text_field): new function. creates an edit field.
(make_combo_box): new function. creates a combo box.
(xm_creation_table): add new widget functions.
1999-06-28 Andy Piper <andy(a)xemacs.org>
* event-Xt.c (handle_focus_event_1): conditionally compile for
X11R5.
* s/cygwin32.h: fix me website address.
* event-msw.c: add NMHDR for pre b20 cygwin builds.
* gui-x.c (button_item_to_widget_value): only add callback if it
is non-nil.
* glyphs-x.c: add progress, edit and combo instantiators.
(x_widget_set_property): new function. uses lwlib to set widget
values.
(x_widget_property): new function. uses lwlib to get widget
values.
(x_button_instantiate): support images in buttons.
(x_button_property): new function. use lwlib to get the selected
state.
(x_progress_instantiate): new function for instantiating progress
gauges.
(x_progress_set_property): new function. sets the progress gauge
position.
(x_edit_instantiate): new function. for instantiating edit fields.
(x_combo_instantiate): new function. for instantiating combo
boxes.
(image_instantiator_format_create_glyphs_x): add new device ii
formats.
* glyphs-msw.c (mswindows_tab_instantiate): remove redundant var.
* console.h (CONSOLE_FEATURES): new features accesor.
* conslots.h (MARKED_SLOT): add features entry.
? munge.awk
? Root
? tmp
? tst
? wid.patch
? wid2.patch
? etc/ChangeLog
? lib-src/run.res
? lisp/.emacs_andyp
? lisp/msw-faces.el.fm
? lisp/mule
? lisp/prim
? lisp/x-font-menu.el.dist
? lisp/x-font-menu.el.fm
? man/internals/patch.exe.core
? modules/ChangeLog
? nt/Addtargetscheckandcheck-temacstoxemacsmakremovemule-c.txt
? nt/Installation
? nt/obj
? nt/puresize-adjust.h
? nt/xemacs.mak+
? nt/xemacs95.mak
? src/depend.tmp
? src/l
? src/mkdc
? src/t.c
? src/TDOC
? src/temacs.exe.core
? src/tstdoc
? src/weblogic.log
? src/winsup
? src/xstrace.gz
Index: lwlib/lwlib-Xm.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lwlib/lwlib-Xm.c,v
retrieving revision 1.11.2.1
diff -u -r1.11.2.1 lwlib-Xm.c
--- lwlib/lwlib-Xm.c 1999/06/25 14:16:43 1.11.2.1
+++ lwlib/lwlib-Xm.c 1999/06/28 15:54:29
@@ -60,6 +60,10 @@
#include <Xm/Separator.h>
#include <Xm/DialogS.h>
#include <Xm/Form.h>
+#include <Xm/Scale.h>
+#if XmVERSION > 1
+#include <Xm/ComboBox.h>
+#endif
#ifdef LWLIB_MENUBARS_MOTIF
static void xm_pull_down_callback (Widget, XtPointer, XtPointer);
@@ -656,8 +660,6 @@
#endif /* LWLIB_MENUBARS_MOTIF */
-#ifdef LWLIB_DIALOGS_MOTIF
-
/* update text widgets */
static void
@@ -683,7 +685,6 @@
xm_internal_update_other_instances, instance);
}
-#endif /* LWLIB_DIALOGS_MOTIF */
#ifdef LWLIB_SCROLLBARS_MOTIF
@@ -776,11 +777,9 @@
XtSetArg (al [1], XmNuserData, val->call_data);
XtSetValues (widget, al, 2);
-#if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF)
/* Common to all label like widgets */
if (XtIsSubclass (widget, xmLabelWidgetClass))
xm_update_label (instance, widget, val);
-#endif
class = XtClass (widget);
/* Class specific things */
@@ -814,7 +813,6 @@
xm_update_menu (instance, widget, val, deep_p);
#endif
}
-#ifdef LWLIB_DIALOGS_MOTIF
else if (class == xmTextWidgetClass)
{
xm_update_text (instance, widget, val);
@@ -823,7 +821,6 @@
{
xm_update_text_field (instance, widget, val);
}
-#endif
else if (class == xmListWidgetClass)
{
xm_update_list (instance, widget, val);
@@ -859,7 +856,6 @@
XtGetValues (widget, al, 1);
val->edited = True;
}
-#ifdef LWLIB_DIALOGS_MOTIF
else if (class == xmTextWidgetClass)
{
if (val->value)
@@ -874,7 +870,6 @@
val->value = XmTextFieldGetString (widget);
val->edited = True;
}
-#endif
else if (class == xmRowColumnWidgetClass)
{
Boolean radiobox = 0;
@@ -1616,9 +1611,105 @@
return button;
}
+
+static Widget
+make_progress (widget_instance *instance)
+{
+ Arg al[20];
+ int ac = 0;
+ Widget scale = 0;
+ widget_value* val = instance->info->val;
+
+ 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++;
+ XtSetArg (al [ac], XmNorientation, XmHORIZONTAL); ac++;
+ /* The highlight doesn't appear to be dynamically set which makes it
+ 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++;
+ if (!val->call_data)
+ XtSetArg (al [ac], XmNsensitive, False); ac++;
+
+ /* add any args the user supplied for creation time */
+ lw_add_value_args_to_args (val, al, &ac);
+
+ scale = XmCreateScale (instance->parent, val->name, al, ac);
+ if (val->call_data)
+ XtAddCallback (scale, XmNvalueChangedCallback, xm_generic_callback,
+ (XtPointer)instance);
+
+ XtManageChild (scale);
+
+ return scale;
+}
-/* Table of functions to create widgets */
+static Widget
+make_text_field (widget_instance *instance)
+{
+ Arg al[20];
+ int ac = 0;
+ Widget text = 0;
+ widget_value* val = instance->info->val;
+ XtSetArg (al [ac], XmNsensitive, val->enabled && val->call_data); ac++;
+ XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
+ XtSetArg (al [ac], XmNuserData, val->call_data); ac++;
+ XtSetArg (al [ac], XmNmappedWhenManaged, FALSE); ac++;
+ /* The highlight doesn't appear to be dynamically set which makes it
+ 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++;
+
+ /* add any args the user supplied for creation time */
+ lw_add_value_args_to_args (val, al, &ac);
+
+ text = XmCreateTextField (instance->parent, val->name, al, ac);
+ if (val->call_data)
+ XtAddCallback (text, XmNvalueChangedCallback, xm_generic_callback,
+ (XtPointer)instance);
+
+ XtManageChild (text);
+
+ return text;
+}
+
+#if XmVERSION > 1
+static Widget
+make_combo_box (widget_instance *instance)
+{
+ Arg al[20];
+ int ac = 0;
+ Widget combo = 0;
+ widget_value* val = instance->info->val;
+
+ 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++;
+ /* The highlight doesn't appear to be dynamically set which makes it
+ 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++;
+
+ /* add any args the user supplied for creation time */
+ lw_add_value_args_to_args (val, al, &ac);
+
+ combo = XmCreateComboBox (instance->parent, val->name, al, ac);
+ if (val->call_data)
+ XtAddCallback (combo, XmNselectionCallback, xm_generic_callback,
+ (XtPointer)instance);
+
+ XtManageChild (combo);
+
+ return combo;
+}
+#endif
+
+
+/* Table of functions to create widgets */
+
widget_creation_entry
xm_creation_table [] =
{
@@ -1631,6 +1722,11 @@
{"horizontal-scrollbar", make_horizontal_scrollbar},
#endif
{"button", make_button},
+ {"progress", make_progress},
+ {"text-field", make_text_field},
+#if XmVERSION > 1
+ {"combo-box", make_combo_box},
+#endif
{NULL, NULL}
};
Index: src/conslots.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/conslots.h,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 conslots.h
--- src/conslots.h 1998/12/05 16:55:24 1.3.2.1
+++ src/conslots.h 1999/06/28 15:54:29
@@ -93,4 +93,7 @@
Initialized by the terminal-specific lisp files. */
MARKED_SLOT (function_key_map);
+ /* Console-specific features */
+ MARKED_SLOT (features);
+
Index: src/console.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/console.h,v
retrieving revision 1.22.2.4
diff -u -r1.22.2.4 console.h
--- src/console.h 1999/05/22 23:03:06 1.22.2.4
+++ src/console.h 1999/06/28 15:54:32
@@ -528,6 +528,7 @@
DEVICE_SELECTED_FRAME (XDEVICE ((con)->selected_device))
#define CONSOLE_LAST_NONMINIBUF_FRAME(con) NON_LVALUE ((con)->last_nonminibuf_frame)
#define CONSOLE_QUIT_CHAR(con) ((con)->quit_char)
+#define CONSOLE_FEATURES(con) ((con)->features)
#define CDFW_CONSOLE(obj) \
(WINDOWP (obj) ? WINDOW_CONSOLE (XWINDOW (obj)) \
Index: src/glyphs-msw.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-msw.c,v
retrieving revision 1.21.2.15
diff -u -r1.21.2.15 glyphs-msw.c
--- src/glyphs-msw.c 1999/06/13 21:45:13 1.21.2.15
+++ src/glyphs-msw.c 1999/06/28 15:54:36
@@ -2515,7 +2515,6 @@
{
Lisp_Object rest;
HWND wnd;
- HTREEITEM parent;
int index = 0;
struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
Index: src/glyphs-x.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-x.c,v
retrieving revision 1.49.2.9
diff -u -r1.49.2.9 glyphs-x.c
--- src/glyphs-x.c 1999/06/25 14:16:46 1.49.2.9
+++ src/glyphs-x.c 1999/06/28 15:54:43
@@ -72,6 +72,11 @@
#include "file-coding.h"
#endif
+#ifdef LWLIB_USES_MOTIF
+#include <Xm/Xm.h>
+#endif
+#include <X11/IntrinsicP.h>
+
#if INTBITS == 32
# define FOUR_BYTE_TYPE unsigned int
#elif LONGBITS == 32
@@ -102,6 +107,9 @@
DEFINE_DEVICE_IIFORMAT (x, widget);
DEFINE_DEVICE_IIFORMAT (x, button);
+DEFINE_DEVICE_IIFORMAT (x, progress);
+DEFINE_DEVICE_IIFORMAT (x, edit);
+DEFINE_DEVICE_IIFORMAT (x, combo);
static void cursor_font_instantiate (Lisp_Object image_instance,
Lisp_Object instantiator,
@@ -2197,6 +2205,39 @@
free_widget_value (wv);
}
+static Lisp_Object
+x_widget_set_property (Lisp_Object image_instance, Lisp_Object prop,
+ Lisp_Object val)
+{
+ struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+
+ if (EQ (prop, Q_text))
+ {
+ Extbyte* str=0;
+ widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
+ CHECK_STRING (val);
+ GET_C_STRING_OS_DATA_ALLOCA (val, str);
+ wv->value = str;
+ lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (ii), wv, False);
+ return Qt;
+ }
+ return Qunbound;
+}
+
+/* get properties of a control */
+static Lisp_Object
+x_widget_property (Lisp_Object image_instance, Lisp_Object prop)
+{
+ struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+ /* get the text from a control */
+ if (EQ (prop, Q_text))
+ {
+ widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
+ return build_ext_string (wv->value, FORMAT_OS);
+ }
+ return Qunbound;
+}
+
/* Instantiate a button widget. Unfortunately instantiated widgets are
particular to a frame since they need to have a parent. It's not
like images where you just select the image into the context you
@@ -2223,6 +2264,117 @@
x_widget_instantiate (image_instance, instantiator, pointer_fg,
pointer_bg, dest_mask, domain, "button", wv);
+
+ /* add the image if one was given */
+ if (!NILP (glyph) && IMAGE_INSTANCEP (glyph))
+ {
+ Arg al [2];
+ int ac =0;
+#ifdef LWLIB_USES_MOTIF
+ XtSetArg (al [ac], XmNlabelType, XmPIXMAP); ac++;
+ XtSetArg (al [ac], XmNlabelPixmap, XIMAGE_INSTANCE_X_PIXMAP (glyph));ac++;
+#else
+ XtSetArg (al [ac], XtNpixmap, XIMAGE_INSTANCE_X_PIXMAP (glyph)); ac++;
+#endif
+ XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, ac);
+ }
+}
+
+/* get properties of a button */
+static Lisp_Object
+x_button_property (Lisp_Object image_instance, Lisp_Object prop)
+{
+ struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+ /* check the state of a button */
+ if (EQ (prop, Q_selected))
+ {
+ widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
+
+ if (wv->selected)
+ return Qt;
+ else
+ return Qnil;
+ }
+ return Qunbound;
+}
+
+/* instantiate a progress gauge */
+static void
+x_progress_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+ Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+ int dest_mask, Lisp_Object domain)
+{
+ struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+ Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
+ widget_value* wv = xmalloc_widget_value ();
+
+ button_item_to_widget_value (gui, wv, 1, 1);
+
+ x_widget_instantiate (image_instance, instantiator, pointer_fg,
+ pointer_bg, dest_mask, domain, "progress", wv);
+}
+
+/* set the properties of a progres guage */
+static Lisp_Object
+x_progress_set_property (Lisp_Object image_instance, Lisp_Object prop,
+ Lisp_Object val)
+{
+ struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+
+ if (EQ (prop, Q_percent))
+ {
+ Arg al [1];
+ CHECK_INT (val);
+ XtSetArg (al[0], XtNvalue, XINT (val));
+ XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 1);
+ return Qt;
+ }
+ return Qunbound;
+}
+
+/* instantiate an edit control */
+static void
+x_edit_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+ Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+ int dest_mask, Lisp_Object domain)
+{
+ struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+ Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
+ widget_value* wv = xmalloc_widget_value ();
+
+ button_item_to_widget_value (gui, wv, 1, 1);
+
+ x_widget_instantiate (image_instance, instantiator, pointer_fg,
+ pointer_bg, dest_mask, domain, "text-field", wv);
+}
+
+/* instantiate a combo control */
+static void
+x_combo_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+ Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+ int dest_mask, Lisp_Object domain)
+{
+ struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+ Lisp_Object rest;
+ Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
+ widget_value* wv = xmalloc_widget_value ();
+
+ button_item_to_widget_value (gui, wv, 1, 1);
+
+ x_widget_instantiate (image_instance, instantiator, pointer_fg,
+ pointer_bg, dest_mask, domain, "combo-box", wv);
+ /* add items to the combo box */
+ LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil))
+ {
+#if 0
+ Extbyte* str;
+ XmString xmstr;
+ GET_C_STRING_OS_DATA_ALLOCA (XCAR (rest), str);
+ xmstr = XmStringCreate (str, XmSTRING_DEFAULT_CHARSET);
+ XmListAddItem (IMAGE_INSTANCE_X_WIDGET_ID (ii), xmstr, 0);
+ XmStringFree (xmstr);
+#endif
+ }
}
@@ -2271,12 +2423,22 @@
/* button widget */
INITIALIZE_DEVICE_IIFORMAT (x, button);
- /* IIFORMAT_HAS_DEVMETHOD (x, button, property);*/
+ IIFORMAT_HAS_DEVMETHOD (x, button, property);
IIFORMAT_HAS_DEVMETHOD (x, button, instantiate);
INITIALIZE_DEVICE_IIFORMAT (x, widget);
- /*IIFORMAT_HAS_DEVMETHOD (x, widget, property);*/
- /*IIFORMAT_HAS_DEVMETHOD (x, widget, set_property);*/
+ IIFORMAT_HAS_DEVMETHOD (x, widget, property);
+ IIFORMAT_HAS_DEVMETHOD (x, widget, set_property);
+ /* progress gauge */
+ INITIALIZE_DEVICE_IIFORMAT (x, progress);
+ IIFORMAT_HAS_DEVMETHOD (x, progress, set_property);
+ IIFORMAT_HAS_DEVMETHOD (x, progress, instantiate);
+ /* text field */
+ INITIALIZE_DEVICE_IIFORMAT (x, edit);
+ IIFORMAT_HAS_DEVMETHOD (x, edit, instantiate);
+ /* combo box */
+ INITIALIZE_DEVICE_IIFORMAT (x, combo);
+ IIFORMAT_HAS_DEVMETHOD (x, combo, instantiate);
INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (cursor_font, "cursor-font");
@@ -2326,6 +2488,9 @@
Vx_bitmap_file_path = Qnil;
Fprovide (Qbutton);
+ Fprovide (Qedit);
+ Fprovide (Qprogress);
+ /* Fprovide (Qcombo);*/
}
void
Index: src/gui-x.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/gui-x.c,v
retrieving revision 1.14.2.5
diff -u -r1.14.2.5 gui-x.c
--- src/gui-x.c 1999/06/25 14:16:47 1.14.2.5
+++ src/gui-x.c 1999/06/28 15:54:44
@@ -364,7 +364,8 @@
wv_set_evalable_slot (wv->enabled, pgui->active);
wv_set_evalable_slot (wv->selected, pgui->selected);
- wv->call_data = LISP_TO_VOID (pgui->callback);
+ if (!NILP (pgui->callback))
+ wv->call_data = LISP_TO_VOID (pgui->callback);
if (no_keys_p
#ifdef HAVE_MENUBARS
Index: tests/glyph-test.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/tests/Attic/glyph-test.el,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 glyph-test.el
--- tests/glyph-test.el 1999/06/25 14:16:48 1.1.2.6
+++ tests/glyph-test.el 1999/06/28 15:54:44
@@ -20,8 +20,10 @@
;; toggle button
(set-extent-begin-glyph
(make-extent (point) (point))
- (make-glyph [button :descriptor ["ok" (setq ok-select nil) :style toggle
- :selected (not ok-select)]]))
+ (setq tbutton
+ (make-glyph [button :descriptor ["ok" (setq ok-select nil)
+ :style toggle
+ :selected (not ok-select)]])))
(set-extent-begin-glyph
(make-extent (point) (point))
(make-glyph [button :descriptor ["ok" :style toggle
--------------------------------------------------------------
Dr Andy Piper
Senior Consultant Architect, BEA Systems Ltd