? old
? sync.patch
? synced
? tabdisp.patch
? tabs.patch
Index: ChangeLog
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lwlib/ChangeLog,v
retrieving revision 1.1.2.104
diff -u -r1.1.2.104 ChangeLog
--- ChangeLog	2000/12/05 06:37:29	1.1.2.104
+++ ChangeLog	2000/12/30 09:55:05
@@ -1,3 +1,19 @@
+2000-12-30  Andy Piper  <andy@xemacs.org>
+
+	* xlwtabs.c: remove assertion definitions and put them in
+	lwlib-internal.h. This has the effect of enabling assertions which
+	should have been done from the very start.
+	(TabsShuffleRows): fix duff assertion.
+	(PreferredSize3): use dimensions throughout.
+	(PreferredSize2): ditto.
+	(TabLayout): ditto.
+	(DrawFrame): be clever about the enclosing frame if the child
+	height is 0.
+	(TabsResize): don't configure children that are no visible
+	anyway. Make sure geometry calculations don't end up negative.
+
+	* lwlib-internal.h: put in assertion definitions.
+
 2000-12-05  Martin Buchholz <martin@xemacs.org>
 
 	* XEmacs 21.2.38 is released.
Index: lwlib-internal.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lwlib/lwlib-internal.h,v
retrieving revision 1.1.1.1.4.5
diff -u -r1.1.1.1.4.5 lwlib-internal.h
--- lwlib-internal.h	2000/09/20 02:39:45	1.1.1.1.4.5
+++ lwlib-internal.h	2000/12/30 09:55:05
@@ -3,6 +3,20 @@
 
 #include "lwlib.h"
 
+#ifdef USE_ASSERTIONS
+/* Highly dubious kludge */
+/*   (thanks, Jamie, I feel better now -- ben) */
+void assert_failed (const char *, int, const char *);
+# define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
+# define assert(x) ((x) ? (void) 0 : assert_failed (__FILE__, __LINE__, #x))
+#else
+# ifdef DEBUG_XEMACS
+#  define assert(x) ((x) ? (void) 0 : (void) abort ())
+# else
+#  define assert(x)
+# endif
+#endif
+
 /* This represents a single widget within a widget tree.  All the
    widgets in a widget tree are chained through the `next' field.
    `info' is a back pointer to the widget tree. */
Index: xlwtabs.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lwlib/Attic/xlwtabs.c,v
retrieving revision 1.1.2.29
diff -u -r1.1.2.29 xlwtabs.c
--- xlwtabs.c	2000/11/24 21:53:38	1.1.2.29
+++ xlwtabs.c	2000/12/30 09:55:09
@@ -66,6 +66,8 @@
 #include	<X11/Xlib.h>
 #include	<X11/IntrinsicP.h>
 #include	<X11/StringDefs.h>
+
+#include	"lwlib-internal.h"
 #include	"../src/xmu.h"
 #include	"xlwtabsP.h"
 #include	"xlwgcs.h"
@@ -267,7 +269,7 @@
 static	void	UndrawTab( TabsWidget tw, Widget child) ;
 
 static	void	TabWidth( Widget w) ;
-static	int	TabLayout( TabsWidget, int wid, int hgt, Dimension *r_hgt,
+static	int	TabLayout( TabsWidget, Dimension wid, Dimension hgt, Dimension *r_hgt,
 			Bool query_only) ;
 static	void	GetPreferredSizes(TabsWidget) ;
 static	void	MaxChild(TabsWidget, Widget except, Dimension, Dimension) ;
@@ -275,9 +277,9 @@
 static	int	PreferredSize( TabsWidget,
 			Dimension *reply_width, Dimension *reply_height,
 			Dimension *reply_cw, Dimension *reply_ch) ;
-static	int	PreferredSize2( TabsWidget, int cw, int ch,
+static	int	PreferredSize2( TabsWidget, Dimension cw, Dimension ch,
 			Dimension *rw, Dimension *rh) ;
-static	int	PreferredSize3( TabsWidget, int wid, int hgt,
+static	int	PreferredSize3( TabsWidget, Dimension wid, Dimension hgt,
 			Dimension *rw, Dimension *rh) ;
 static	void	MakeSizeRequest(TabsWidget) ;
 
@@ -392,20 +394,6 @@
 
 WidgetClass tabsWidgetClass = (WidgetClass)&tabsClassRec;
 
-
-
-#ifdef	DEBUG
-#ifdef	__STDC__
-#define	assert(e) \
-	  if(!(e)) fprintf(stderr,"yak! %s at %s:%d\n",#e,__FILE__,__LINE__)
-#else
-#define	assert(e) \
-	  if(!(e)) fprintf(stderr,"yak! e at %s:%d\n",__FILE__,__LINE__)
-#endif
-#else
-#define	assert(e)
-#endif
-
 #define TabsNumChildren(tw) (((TabsWidget)tw)->composite.num_children)
 #define TabVisible(tab) \
 	(XtIsManaged(tab) && \
@@ -570,18 +558,20 @@
 
 	  tw->tabs.child_width = cw = tw->core.width - 2 * SHADWID ;
 	  tw->tabs.child_height = ch =
-			tw->core.height - tw->tabs.tab_total - 2 * SHADWID ;
+	    tw->core.height < (tw->tabs.tab_total + 2 * SHADWID) ? 0 :
+	    tw->core.height - tw->tabs.tab_total - 2 * SHADWID ;
 
-
 	  for(i=0, childP=tw->composite.children;
 		i < num_children;
 		++i, ++childP)
-	    if( TabVisible(*childP) )
+	    if( XtIsManaged(*childP) )
 	    {
 	      tab = (TabsConstraints) (*childP)->core.constraints ;
 	      bw = (*childP)->core.border_width ;
-	      XtConfigureWidget(*childP, SHADWID,tw->tabs.tab_total+SHADWID,
-			  cw-bw*2,ch-bw*2, bw) ;
+	      /* Don't do anything if we can't see any of the child. */
+	      if (ch >= bw*2 && ch > 0 && cw >= bw*2 && cw > 0)
+		XtConfigureWidget(*childP, SHADWID,tw->tabs.tab_total+SHADWID,
+				  cw-bw*2,ch-bw*2, bw) ;
 	    }
 	  if( XtIsRealized(w) ) {
 	    XClearWindow(XtDisplay((Widget)tw), XtWindow((Widget)tw)) ;
@@ -873,7 +863,8 @@
 	    myrequest.width = wid ;
 	    myrequest.height = hgt ;
 	    myrequest.request_mode = CWWidth | CWHeight ;
-
+	    
+	    assert (wid > 0 && hgt > 0);
 	    /* If child is only querying, or if we're going to have to
 	     * offer the child a compromise, then make this a query only.
 	     */
@@ -1505,8 +1496,26 @@
 	GC		botgc = tw->tabs.botGC ;
 	Dimension	s = SHADWID ;
 	Dimension	ch = tw->tabs.child_height ;
-	Draw3dBox((Widget)tw, 0,tw->tabs.tab_total,
-		tw->core.width, ch+2*s, s, topgc, botgc) ;
+	if (ch > 0)
+	  Draw3dBox((Widget)tw, 0,tw->tabs.tab_total,
+		    tw->core.width, ch+2*s, s, topgc, botgc) ;
+	else
+	  {
+	    Widget		w = tw->tabs.topWidget ;
+	    if (w != NULL)
+	      {
+		TabsConstraints	tab = (TabsConstraints) w->core.constraints ;
+		Draw3dBox((Widget)tw, 0,tw->core.height - 2*s,
+			  tab->tabs.x, 2*s, s, topgc, botgc);
+		Draw3dBox((Widget)tw, tab->tabs.x + tab->tabs.width, 
+			  tw->core.height - 2*s,
+			  tw->core.width - tab->tabs.x - tab->tabs.width, 2*s, s, 
+			  topgc, botgc);
+	      }
+	    else
+	      Draw3dBox((Widget)tw, 0,tw->core.height - 2*s,
+			tw->core.width, 2*s, s, topgc, botgc) ;
+	  }
 }
 
 
@@ -1712,7 +1721,10 @@
 	 */
 
 static	int
-TabLayout(TabsWidget tw, int wid, int hgt, Dimension *reply_height, Bool query_only)
+TabLayout(TabsWidget tw, 
+	  Dimension wid, 
+	  Dimension hgt, 
+	  Dimension *reply_height, Bool query_only)
 {
 	int		i, row, done = 0, display_rows = 0 ;
 	int		num_children = tw->composite.num_children ;
@@ -1817,7 +1829,7 @@
 	XtWidgetGeometry	preferred ;
 
 	for(i=tw->composite.num_children; --i >=0; ++childP)
-	  if( XtIsManaged(*childP)  &&  *childP != except )
+	  if( TabVisible (*childP) /*XtIsManaged(*childP)*/  &&  *childP != except )
 	  {
 	    (void) XtQueryGeometry(*childP, NULL, &preferred) ;
 	    cw = Max(cw, preferred.width + preferred.border_width * 2 ) ;
@@ -1859,7 +1871,7 @@
 	{
 	  display_rows = tw->tabs.numRows ;
 	  real_rows = tw->tabs.realRows ;
-	  assert( display_rows >= real_rows ) ;
+	  assert( display_rows <= real_rows ) ;
 
 	  if( real_rows > 1 )
 	  {
@@ -1959,18 +1971,22 @@
 static	int
 PreferredSize2(
 	TabsWidget	tw,
-	int		cw,		/* child width, height */
-	int		ch,
+	Dimension	cw,		/* child width, height */
+	Dimension	ch,
 	Dimension	*reply_width,	/* total widget size */
 	Dimension	*reply_height)
 {
 	Dimension	s = SHADWID ;
+	int ret;
 
 	/* make room for shadow frame */
 	cw += s*2 ;
 	ch += s*2 ;
+
+	ret = PreferredSize3(tw, cw, ch, reply_width, reply_height) ;
 
-	return PreferredSize3(tw, cw, ch, reply_width, reply_height) ;
+	assert (*reply_width > 0 && *reply_height > 0);
+	return ret;
 }
 
 
@@ -1979,8 +1995,8 @@
 static	int
 PreferredSize3(
 	TabsWidget	tw,
-	int		wid,		/* child width, height */
-	int		hgt,
+	Dimension	wid,		/* child width, height */
+	Dimension	hgt,
 	Dimension	*reply_width,	/* total widget size */
 	Dimension	*reply_height)
 {
