Index: lwlib/lwlib-Xlw.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/lwlib/lwlib-Xlw.c,v retrieving revision 1.7.2.3 diff -u -r1.7.2.3 lwlib-Xlw.c --- lwlib/lwlib-Xlw.c 1999/09/01 12:56:32 1.7.2.3 +++ lwlib/lwlib-Xlw.c 1999/09/20 09:48:44 @@ -30,6 +30,9 @@ #include #include #include +#ifdef HAVE_WIDGETS +#include "../src/EmacsManager.h" +#endif #ifdef LWLIB_MENUBARS_LUCID #include "xlwmenu.h" #endif @@ -453,6 +456,32 @@ } #endif /* LWLIB_TABS_LUCID */ +#ifdef HAVE_WIDGETS +static Widget +xlw_create_clip_window (widget_instance *instance) +{ + Arg al[20]; + int ac = 0; + Widget clip = 0; + widget_value* val = instance->info->val; + + XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++; + XtSetArg (al [ac], XtNsensitive, TRUE); ac++; + /* add any args the user supplied for creation time */ + lw_add_value_args_to_args (val, al, &ac); + + /* Create a clip window to contain the subwidget. Incredibly the + XEmacs manager seems to be the most appropriate widget for + this. Nothing else is simple enough and yet does what is + required. */ + clip = XtCreateManagedWidget (val->name, + emacsManagerWidgetClass, + instance->parent, al, ac); + + return clip; +} +#endif + widget_creation_entry xlw_creation_table [] = { @@ -466,6 +495,9 @@ #endif #ifdef LWLIB_TABS_LUCID {"tab-control", xlw_create_tab_control}, +#endif +#ifdef HAVE_WIDGETS + {"clip-window", xlw_create_clip_window}, #endif {NULL, NULL} }; Index: src/glyphs-msw.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-msw.c,v retrieving revision 1.21.2.23 diff -u -r1.21.2.23 glyphs-msw.c --- src/glyphs-msw.c 1999/09/16 16:56:49 1.21.2.23 +++ src/glyphs-msw.c 1999/09/20 09:49:13 @@ -2101,6 +2101,16 @@ SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); } + + /* set the widget font from the widget face */ + SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), + WM_SETFONT, + (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT + (XFONT_INSTANCE (widget_face_font_info + (IMAGE_INSTANCE_SUBWINDOW_FRAME (p), + IMAGE_INSTANCE_WIDGET_FACE (p), + 0, 0))), + MAKELPARAM (TRUE, 0)); } } Index: src/glyphs-x.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs-x.c,v retrieving revision 1.49.2.25 diff -u -r1.49.2.25 glyphs-x.c --- src/glyphs-x.c 1999/09/16 16:56:49 1.49.2.25 +++ src/glyphs-x.c 1999/09/20 09:49:27 @@ -78,9 +78,6 @@ #include #endif #include -#ifdef HAVE_WIDGETS -#include "EmacsManager.h" -#endif #if INTBITS == 32 # define FOUR_BYTE_TYPE unsigned int @@ -146,6 +143,11 @@ int dest_mask, Lisp_Object domain); +#ifdef HAVE_WIDGETS +static void +update_widget_face (struct Lisp_Image_Instance* ii, Lisp_Object domain); +#endif + #include "bitmaps.h" @@ -391,7 +393,7 @@ stderr_out ("widget destroyed, %d left\n", debug_widget_instances); #endif lw_destroy_widget (IMAGE_INSTANCE_X_WIDGET_ID (p)); - XtDestroyWidget (IMAGE_INSTANCE_X_CLIPWIDGET (p)); + lw_destroy_widget (IMAGE_INSTANCE_X_CLIPWIDGET (p)); IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0; } } @@ -2076,20 +2078,47 @@ static void x_update_subwindow (struct Lisp_Image_Instance *p) { +#ifdef HAVE_WIDGETS if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) { - Arg al[2]; + Arg al[5]; widget_value* wv = gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (p)); + + /* This seems ugly, but I'm not sure what else to do. */ + if (EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qtab_control)) + { + widget_value* cur = 0; + /* Give each child label the correct foreground color. */ + Lisp_Object pixel = FACE_FOREGROUND + (IMAGE_INSTANCE_WIDGET_FACE (p), + IMAGE_INSTANCE_SUBWINDOW_FRAME (p)); + XColor fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel)); + XtSetArg (al [0], XtNtabForeground, fcolor.pixel); + + for (cur = wv->contents; cur; cur = cur->next) + { + if (cur->value) + { + cur->nargs = 1; + cur->args = al; + } + } + } + + /* now modify the widget */ lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p), wv, True); free_widget_value_tree (wv); + /* update the colors and font */ + update_widget_face (p, IMAGE_INSTANCE_SUBWINDOW_FRAME (p)); /* We have to do this otherwise Motif will unceremoniously resize us when the label gets set. */ XtSetArg (al [0], XtNwidth, IMAGE_INSTANCE_WIDGET_WIDTH (p)); XtSetArg (al [1], XtNheight, IMAGE_INSTANCE_WIDGET_HEIGHT (p)); XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (p), al, 2); } +#endif } /* instantiate and x type subwindow */ @@ -2202,6 +2231,46 @@ /************************************************************************/ static void +update_widget_face (struct Lisp_Image_Instance* ii, Lisp_Object domain) +{ + Arg al[3]; + XmFontList fontList; + + Lisp_Object pixel = FACE_FOREGROUND + (IMAGE_INSTANCE_WIDGET_FACE (ii), + IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); + XColor fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel)); + XColor bcolor; + + pixel = FACE_BACKGROUND + (IMAGE_INSTANCE_WIDGET_FACE (ii), + IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); + bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel)); + + XtSetArg (al [0], XtNbackground, bcolor.pixel); + XtSetArg (al [1], XtNforeground, fcolor.pixel); + +#ifdef LWLIB_WIDGETS_MOTIF + fontList = XmFontListCreate + ((void*)FONT_INSTANCE_X_FONT + (XFONT_INSTANCE (widget_face_font_info + (domain, IMAGE_INSTANCE_WIDGET_FACE (ii), + 0, 0))), XmSTRING_DEFAULT_CHARSET); + XtSetArg (al [2], XmNfontList, fontList ); +#else + XtSetArg (al [2], XtNfont, (void*)FONT_INSTANCE_X_FONT + (XFONT_INSTANCE (widget_face_font_info + (domain, + IMAGE_INSTANCE_WIDGET_FACE (ii), + 0, 0)))); +#endif + XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 3); +#ifdef LWLIB_WIDGETS_MOTIF + XmFontListFree (fontList); +#endif +} + +static void x_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, Lisp_Object pointer_fg, Lisp_Object pointer_bg, int dest_mask, Lisp_Object domain, @@ -2212,15 +2281,13 @@ struct device* d = XDEVICE (device); Lisp_Object frame = FW_FRAME (domain); struct frame* f = XFRAME (frame); - XColor fcolor, bcolor; Extbyte* nm=0; Widget wid; Arg al [32]; int ac = 0; int id = new_lwlib_id (); -#ifdef LWLIB_WIDGETS_MOTIF - XmFontList fontList; -#endif + widget_value* clip_wv; + XColor fcolor, bcolor; if (!DEVICE_X_P (d)) signal_simple_error ("Not an X device", device); @@ -2239,28 +2306,42 @@ XEmacs manager seems to be the most appropriate widget for this. Nothing else is simple enough and yet does what is required. */ + clip_wv = xmalloc_widget_value (); + XtSetArg (al [ac], XtNresize, False); ac++; - XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++; XtSetArg (al [ac], XtNwidth, (Dimension)IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii)); ac++; XtSetArg (al [ac], XtNheight, (Dimension)IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii)); ac++; + + clip_wv->enabled = True; + clip_wv->nargs = ac; + clip_wv->args = al; + clip_wv->name = xstrdup ("clip-window"); + clip_wv->value = xstrdup ("clip-window"); + IMAGE_INSTANCE_X_CLIPWIDGET (ii) - = XtCreateManagedWidget ("clipwindow", - emacsManagerWidgetClass, - FRAME_X_CONTAINER_WIDGET (f), al, ac); + = lw_create_widget ("clip-window", "clip-window", new_lwlib_id (), + clip_wv, FRAME_X_CONTAINER_WIDGET (f), + False, 0, 0, 0); + free_widget_value_tree (clip_wv); + /* copy any args we were given */ ac = 0; if (wv->nargs) lw_add_value_args_to_args (wv, al, &ac); - /* add our own arguments */ + /* Fixup the colors. We have to do this *before* the widget gets + created so that Motif will fix up the shadow colors + correctly. Once the widget is created Motif won't do this + anymore...*/ pixel = FACE_FOREGROUND (IMAGE_INSTANCE_WIDGET_FACE (ii), IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel)); + pixel = FACE_BACKGROUND (IMAGE_INSTANCE_WIDGET_FACE (ii), IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); @@ -2270,6 +2351,10 @@ XtSetArg (al [ac], XtNforeground, fcolor.pixel); ac++; /* we cannot allow widgets to resize themselves */ XtSetArg (al [ac], XtNresize, False); ac++; + XtSetArg (al [ac], XtNwidth, + (Dimension)IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii)); ac++; + XtSetArg (al [ac], XtNheight, + (Dimension)IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii)); ac++; wv->nargs = ac; wv->args = al; @@ -2277,40 +2362,28 @@ wid = lw_create_widget (type, wv->name, id, wv, IMAGE_INSTANCE_X_CLIPWIDGET (ii), False, 0, popup_selection_callback, 0); + IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void*)wid; IMAGE_INSTANCE_X_WIDGET_LWID (ii) = id; - /* 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. */ + + /* update the font. */ + update_widget_face (ii, domain); + + /* 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++; -#ifdef LWLIB_WIDGETS_MOTIF - fontList = XmFontListCreate - ((void*)FONT_INSTANCE_X_FONT - (XFONT_INSTANCE (widget_face_font_info - (domain, IMAGE_INSTANCE_WIDGET_FACE (ii), - 0, 0))), XmSTRING_DEFAULT_CHARSET); - XtSetArg (al [ac], XmNfontList, fontList ); ac++; -#else - XtSetArg (al [ac], XtNfont, (void*)FONT_INSTANCE_X_FONT - (XFONT_INSTANCE (widget_face_font_info - (domain, - IMAGE_INSTANCE_WIDGET_FACE (ii), - 0, 0)))); ac++; -#endif - XtSetValues (wid, al, ac); -#ifdef LWLIB_WIDGETS_MOTIF - XmFontListFree (fontList); -#endif - /* finally get offsets in the frame */ + 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. */ ac = 0; XtSetArg (al [ac], XtNx, &IMAGE_INSTANCE_X_WIDGET_XOFFSET (ii)); ac++; XtSetArg (al [ac], XtNy, &IMAGE_INSTANCE_X_WIDGET_YOFFSET (ii)); ac++; XtGetValues (FRAME_X_TEXT_WIDGET (f), al, ac); - IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void*)wid; XtMapWidget (wid); free_widget_value_tree (wv); @@ -2332,23 +2405,10 @@ lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (ii), wv, False); return Qt; } - /* Modify the colors of the widget */ + /* Modify the face properties of the widget */ if (EQ (prop, Q_face)) { - Arg al [2]; - XColor fcolor, bcolor; - Lisp_Object pixel = FACE_FOREGROUND - (IMAGE_INSTANCE_WIDGET_FACE (ii), - IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); - fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel)); - pixel = FACE_BACKGROUND - (IMAGE_INSTANCE_WIDGET_FACE (ii), - IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); - bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel)); - - XtSetArg (al [0], XtNforeground, fcolor.pixel); - XtSetArg (al [1], XtNbackground, bcolor.pixel); - XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 2); + update_widget_face (ii, IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); return Qt; } return Qunbound; Index: src/glyphs.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/glyphs.c,v retrieving revision 1.23.2.25 diff -u -r1.23.2.25 glyphs.c --- src/glyphs.c 1999/09/16 16:56:50 1.23.2.25 +++ src/glyphs.c 1999/09/20 09:49:51 @@ -3926,7 +3926,7 @@ { int elt; - if (f->subwindows_changed || f->glyphs_changed) + if (f->subwindows_changed || f->glyphs_changed || f->faces_changed) for (elt = 0; elt < Dynarr_length (f->subwindow_cachels); elt++) { struct subwindow_cachel *cachel =