Index: src/glyphs-widget.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/Attic/glyphs-widget.c,v retrieving revision 1.1.2.34 diff -u -r1.1.2.34 glyphs-widget.c --- src/glyphs-widget.c 2000/03/31 09:54:32 1.1.2.34 +++ src/glyphs-widget.c 2000/03/31 18:28:45 @@ -519,7 +519,7 @@ IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii) = Qnil; IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii) = 1; IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) = 1; - IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = 0; + IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_HORIZONTAL; IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) = 0; } @@ -605,10 +605,10 @@ /* make sure we are designated as the parent. */ XIMAGE_INSTANCE_PARENT (gii) = image_instance; children = Fcons (gii, children); - /* Make sure elements in the layout are in the order the - user expected. */ - children = Fnreverse (children); } + /* Make sure elements in the layout are in the order the + user expected. */ + children = Fnreverse (children); IMAGE_INSTANCE_LAYOUT_CHILDREN (ii) = children; } /* retrieve the gui item information. This is easy if we have been @@ -627,7 +627,7 @@ /* Pick up the orientation before we do our first layout. */ if (EQ (orient, Qleft) || EQ (orient, Qright) || EQ (orient, Qvertical)) - IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = 1; + IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL; /* parse more gui items out of the properties */ if (!NILP (props) @@ -938,56 +938,76 @@ Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); Lisp_Object items = IMAGE_INSTANCE_LAYOUT_CHILDREN (ii), rest; int maxph = 0, maxpw = 0, nitems = 0, ph_adjust = 0; + unsigned int gheight, gwidth; + /* First just set up what we already have. */ + if (width) *width = IMAGE_INSTANCE_WIDTH (ii); + if (height) *height = IMAGE_INSTANCE_HEIGHT (ii); + + /* If we are not allowed to dynamically size then return. */ + if (!IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii) + && + !IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii)) + return; + + /* Pick up the border text if we have one. */ + if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii))) + { + image_instance_query_geometry (XCAR (items), &gwidth, &gheight, disp, domain); + ph_adjust = gheight / 2; + items = XCDR (items); + } + /* Flip through the items to work out how much stuff we have to display */ LIST_LOOP (rest, items) { Lisp_Object glyph = XCAR (rest); - unsigned int gheight, gwidth; - image_instance_query_geometry (glyph, &gwidth, &gheight, disp, domain); - /* Pick up the border text if we have one. */ - if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) - && NILP (XCDR (rest))) + nitems ++; + if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) + == LAYOUT_HORIZONTAL) { - ph_adjust = gheight / 2; + maxph = max (maxph, gheight); + maxpw += gwidth; } else { - - nitems ++; - if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) - == LAYOUT_HORIZONTAL) - { - maxph = max (maxph, gheight); - maxpw += gwidth; - } - else - { - maxpw = max (maxpw, gwidth); - maxph += gheight; - } + maxpw = max (maxpw, gwidth); + maxph += gheight; } } - /* work out spacing between items and bounds of the layout. No user - provided width so we just do default spacing. */ - if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) - == LAYOUT_HORIZONTAL) + /* Work out minimum space we need to fit all the items. This could + have been fixed by the user. */ + if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii))) + { + Lisp_Object dynamic_width = + Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)); + if (INTP (dynamic_width)) + *width = XINT (dynamic_width); + } + else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) + == LAYOUT_HORIZONTAL) *width = maxpw + (nitems + 1) * WIDGET_BORDER_WIDTH * 2; else *width = maxpw + 2 * WIDGET_BORDER_WIDTH * 2; /* Work out vertical spacings. */ - if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) - == LAYOUT_VERTICAL) + if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii))) + { + Lisp_Object dynamic_height = + Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)); + if (INTP (dynamic_height)) + *height = XINT (dynamic_height); + } + else if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) + == LAYOUT_VERTICAL) *height = maxph + (nitems + 1) * WIDGET_BORDER_HEIGHT * 2 + ph_adjust; - else + else *height = maxph + 2 * WIDGET_BORDER_HEIGHT * 2 + ph_adjust; } - static void layout_layout (Lisp_Object image_instance, unsigned int width, unsigned int height, Lisp_Object domain) @@ -998,38 +1018,41 @@ int x, y, maxph = 0, maxpw = 0, nitems = 0, horiz_spacing, vert_spacing, ph_adjust = 0; unsigned int gheight, gwidth; + + /* Pick up the border text if we have one. */ + if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii))) + { + Lisp_Object border = XCAR (items); + items = XCDR (items); + image_instance_query_geometry (border, &gwidth, &gheight, + IMAGE_DESIRED_GEOMETRY, domain); + /* #### Really, what should this be? */ + XIMAGE_INSTANCE_XOFFSET (border) = 10; + XIMAGE_INSTANCE_YOFFSET (border) = 0; + ph_adjust = gheight / 2; + IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (ph_adjust); - /* flip through the items to work out how much stuff we have to display */ + image_instance_layout (border, gwidth, gheight, domain); + } + + /* Flip through the items to work out how much stuff we have to display. */ LIST_LOOP (rest, items) { Lisp_Object glyph = XCAR (rest); image_instance_query_geometry (glyph, &gwidth, &gheight, IMAGE_DESIRED_GEOMETRY, domain); - - /* Pick up the border text if we have one. */ - if (INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) - && NILP (XCDR (rest))) - { - XIMAGE_INSTANCE_XOFFSET (glyph) = 10; /* Really, what should this be? */ - XIMAGE_INSTANCE_YOFFSET (glyph) = 0; - ph_adjust = gheight / 2; - IMAGE_INSTANCE_LAYOUT_BORDER (ii) = make_int (ph_adjust); + nitems ++; + if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) + == LAYOUT_HORIZONTAL) + { + maxph = max (maxph, gheight); + maxpw += gwidth; } else { - nitems ++; - if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) - == LAYOUT_HORIZONTAL) - { - maxph = max (maxph, gheight); - maxpw += gwidth; - } - else - { - maxpw = max (maxpw, gwidth); - maxph += gheight; - } + maxpw = max (maxpw, gwidth); + maxph += gheight; } } @@ -1068,42 +1091,38 @@ image_instance_query_geometry (glyph, &gwidth, &gheight, IMAGE_DESIRED_GEOMETRY, domain); - if (!INTP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) - || !NILP (XCDR (rest))) - { - if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) - == LAYOUT_HORIZONTAL) - { - if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) - == LAYOUT_JUSTIFY_RIGHT) - y = height - (gheight + vert_spacing); - if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) - == LAYOUT_JUSTIFY_CENTER) - y = (height - gheight) / 2; - } - else - { - if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) - == LAYOUT_JUSTIFY_RIGHT) - x = width - (gwidth + horiz_spacing); - if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) - == LAYOUT_JUSTIFY_CENTER) - x = (width - gwidth) / 2; - } + if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) + == LAYOUT_HORIZONTAL) + { + if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) + == LAYOUT_JUSTIFY_RIGHT) + y = height - (gheight + vert_spacing); + if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) + == LAYOUT_JUSTIFY_CENTER) + y = (height - gheight) / 2; + } + else + { + if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) + == LAYOUT_JUSTIFY_RIGHT) + x = width - (gwidth + horiz_spacing); + if (IMAGE_INSTANCE_SUBWINDOW_JUSTIFY (ii) + == LAYOUT_JUSTIFY_CENTER) + x = (width - gwidth) / 2; + } - XIMAGE_INSTANCE_XOFFSET (glyph) = x; - XIMAGE_INSTANCE_YOFFSET (glyph) = y; + XIMAGE_INSTANCE_XOFFSET (glyph) = x; + XIMAGE_INSTANCE_YOFFSET (glyph) = y; - if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) - == LAYOUT_HORIZONTAL) - { - x += (gwidth + horiz_spacing); - } - else - { - y += (gheight + vert_spacing); - } - } + if (IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) + == LAYOUT_HORIZONTAL) + { + x += (gwidth + horiz_spacing); + } + else + { + y += (gheight + vert_spacing); + } /* Now layout subwidgets if they require it. */ image_instance_layout (glyph, gwidth, gheight, domain);