gr = *ip++;
bl = *ip++;
conv.val = pixarray[QUANT_GET_COLOR(qtable,rd,gr,bl)];
-#if WORDS_BIGENDIAN
+#ifdef WORDS_BIGENDIAN
if (outimg->byte_order == MSBFirst)
for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
else
bl = *ip++ >> (8 - bbits);
conv.val = (rd << rshift) | (gr << gshift) | (bl << bshift);
-#if WORDS_BIGENDIAN
+#ifdef WORDS_BIGENDIAN
if (outimg->byte_order == MSBFirst)
for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
else
static void
x_update_widget (Lisp_Image_Instance *p)
{
+ /* This function can GC if IN_REDISPLAY is false. */
#ifdef HAVE_WIDGETS
widget_value* wv = 0;
- Boolean deep_p = False;
- /* Possibly update the size. */
- if (IMAGE_INSTANCE_SIZE_CHANGED (p))
- {
- Arg al[2];
-
- assert (IMAGE_INSTANCE_X_WIDGET_ID (p) &&
- IMAGE_INSTANCE_X_CLIPWIDGET (p)) ;
-
- if ( !XtIsManaged(IMAGE_INSTANCE_X_WIDGET_ID (p))
- ||
- IMAGE_INSTANCE_X_WIDGET_ID (p)->core.being_destroyed )
- {
- Lisp_Object sw;
- XSETIMAGE_INSTANCE (sw, p);
- signal_simple_error ("XEmacs bug: subwindow is deleted", sw);
- }
-
- XtSetArg (al [0], XtNwidth, (Dimension)IMAGE_INSTANCE_WIDTH (p));
- XtSetArg (al [1], XtNheight, (Dimension)IMAGE_INSTANCE_HEIGHT (p));
- XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (p), al, 2);
- }
- /* First get the items if they have changed since this is a structural change. */
+ /* First get the items if they have changed since this is a
+ structural change. As such it will nuke all added values so we
+ need to update most other things after the items have changed.*/
if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
{
+ Lisp_Object image_instance;
+
+ XSETIMAGE_INSTANCE (image_instance, p);
wv = gui_items_to_widget_values
- (IMAGE_INSTANCE_WIDGET_ITEMS (p));
- deep_p = True;
+ (image_instance, IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p));
+ wv->change = STRUCTURAL_CHANGE;
+ /* now modify the widget */
+ lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p),
+ wv, True);
+ free_widget_value_tree (wv);
}
+ /* Now do non structural updates. */
+ wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (p));
+
+ if (!wv)
+ return;
+
/* Possibly update the colors and font */
- if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p))
+ if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p)
+ ||
+ XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (p))->faces_changed
+ ||
+ IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
{
update_widget_face (wv, p, IMAGE_INSTANCE_SUBWINDOW_FRAME (p));
}
wv->value = str;
}
+ /* Possibly update the size. */
+ if (IMAGE_INSTANCE_SIZE_CHANGED (p)
+ ||
+ IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)
+ ||
+ IMAGE_INSTANCE_TEXT_CHANGED (p))
+ {
+ assert (IMAGE_INSTANCE_X_WIDGET_ID (p) &&
+ IMAGE_INSTANCE_X_CLIPWIDGET (p)) ;
+
+ if (IMAGE_INSTANCE_X_WIDGET_ID (p)->core.being_destroyed
+ || !XtIsManaged(IMAGE_INSTANCE_X_WIDGET_ID (p)))
+ {
+ Lisp_Object sw;
+ XSETIMAGE_INSTANCE (sw, p);
+ signal_simple_error ("XEmacs bug: subwindow is deleted", sw);
+ }
+
+ lw_add_widget_value_arg (wv, XtNwidth,
+ (Dimension)IMAGE_INSTANCE_WIDTH (p));
+ lw_add_widget_value_arg (wv, XtNheight,
+ (Dimension)IMAGE_INSTANCE_HEIGHT (p));
+ }
+
/* now modify the widget */
lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p),
- wv, deep_p);
- free_widget_value_tree (wv);
+ wv, False);
#endif
}
lw_add_widget_value_arg (clip_wv, XtNresize, False);
lw_add_widget_value_arg (clip_wv, XtNwidth,
- (Dimension)IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii));
+ (Dimension)IMAGE_INSTANCE_WIDTH (ii));
lw_add_widget_value_arg (clip_wv, XtNheight,
- (Dimension)IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii));
+ (Dimension)IMAGE_INSTANCE_HEIGHT (ii));
clip_wv->enabled = True;
clip_wv->name = xstrdup ("clip-window");
/* we cannot allow widgets to resize themselves */
lw_add_widget_value_arg (wv, XtNresize, False);
lw_add_widget_value_arg (wv, XtNwidth,
- (Dimension)IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii));
+ (Dimension)IMAGE_INSTANCE_WIDTH (ii));
lw_add_widget_value_arg (wv, XtNheight,
- (Dimension)IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii));
+ (Dimension)IMAGE_INSTANCE_HEIGHT (ii));
/* update the font. */
update_widget_face (wv, ii, domain);
IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void*)wid;
IMAGE_INSTANCE_X_WIDGET_LWID (ii) = id;
-
- /* Resize the widget here so that the values do not get copied by
- lwlib. */
- ac = 0;
- XtSetArg (al [ac], XtNwidth,
- (Dimension)IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii)); ac++;
- XtSetArg (al [ac], XtNheight,
- (Dimension)IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii)); ac++;
- XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, ac);
/* because the EmacsManager is the widgets parent we have to
offset the redisplay of the widget by the amount the text
widget is inside the manager. */
Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
- widget_value* wv = xmalloc_widget_value ();
-
- button_item_to_widget_value (gui, wv, 1, 1);
+ widget_value* wv = gui_items_to_widget_values (image_instance, gui);
if (!NILP (glyph))
{
}
}
+/* Update a button's clicked state.
+
+ #### This is overkill, but it works. Right now this causes all
+ button instances to flash for some reason buried deep in lwlib. In
+ theory this should be the Right Thing to do since lwlib should only
+ merge in changed values - and if nothing has changed then nothing
+ should get done. This may be because of the args stuff,
+ i.e. although the arg contents may be the same the args look
+ different and so are re-applied to the widget. */
+static void
+x_button_update (Lisp_Object image_instance)
+{
+ /* This function can GC if IN_REDISPLAY is false. */
+ Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
+ widget_value* wv =
+ gui_items_to_widget_values (image_instance,
+ IMAGE_INSTANCE_WIDGET_ITEMS (p));
+
+ /* now modify the widget */
+ lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p),
+ wv, True);
+ free_widget_value_tree (wv);
+}
+
/* get properties of a button */
static Lisp_Object
x_button_property (Lisp_Object image_instance, Lisp_Object prop)
{
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);
+ widget_value* wv = gui_items_to_widget_values (image_instance, gui);
x_widget_instantiate (image_instance, instantiator, pointer_fg,
pointer_bg, dest_mask, domain, "progress", wv);
{
Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
- if (IMAGE_INSTANCE_WIDGET_PERCENT_CHANGED (ii))
+ if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
{
Arg al [1];
- /* #### I'm not convinced we should store this in the plist. */
- Lisp_Object val = Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii),
- Q_percent, Qnil);
+ Lisp_Object val;
+#ifdef ERROR_CHECK_GLYPHS
+ assert (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)));
+#endif
+ val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value;
XtSetArg (al[0], XtNvalue, XINT (val));
XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 1);
}
{
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);
+ widget_value* wv = gui_items_to_widget_values (image_instance, gui);
x_widget_instantiate (image_instance, instantiator, pointer_fg,
pointer_bg, dest_mask, domain, "text-field", wv);
widget_instantiate (image_instance, instantiator, pointer_fg,
pointer_bg, dest_mask, domain);
- wv = gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
+ wv = gui_items_to_widget_values (image_instance,
+ IMAGE_INSTANCE_WIDGET_ITEMS (ii));
x_widget_instantiate (image_instance, instantiator, pointer_fg,
pointer_bg, dest_mask, domain, "combo-box", wv);
{
Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
widget_value * wv =
- gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
+ gui_items_to_widget_values (image_instance,
+ IMAGE_INSTANCE_WIDGET_ITEMS (ii));
update_tab_widget_face (wv, ii,
IMAGE_INSTANCE_SUBWINDOW_FRAME (ii));
/* set the properties of a tab control */
static void
-x_tab_control_update (Lisp_Object image_instance)
+x_tab_control_update (Lisp_Object image_instance)
{
Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
/* Possibly update the face. */
- if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (ii))
+ if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (ii)
+ ||
+ XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (ii))->faces_changed
+ ||
+ IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
{
widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
+
+ /* #### I don't know why this can occur. */
+ if (!wv)
+ return;
+
update_tab_widget_face (wv, ii,
IMAGE_INSTANCE_SUBWINDOW_FRAME (ii));
lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (ii), wv, True);
- free_widget_value_tree (wv);
}
}
{
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);
+ widget_value* wv = gui_items_to_widget_values (image_instance, gui);
x_widget_instantiate (image_instance, instantiator, pointer_fg,
pointer_bg, dest_mask, domain, "button", wv);
INITIALIZE_DEVICE_IIFORMAT (x, button);
IIFORMAT_HAS_DEVMETHOD (x, button, property);
IIFORMAT_HAS_DEVMETHOD (x, button, instantiate);
+ IIFORMAT_HAS_DEVMETHOD (x, button, update);
INITIALIZE_DEVICE_IIFORMAT (x, widget);
IIFORMAT_HAS_DEVMETHOD (x, widget, property);