#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"
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) ;
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) ;
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) && \
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)) ;
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.
*/
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) ;
+ }
}
*/
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 ;
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 ) ;
{
display_rows = tw->tabs.numRows ;
real_rows = tw->tabs.realRows ;
- assert( display_rows >= real_rows ) ;
+ assert( display_rows <= real_rows ) ;
if( real_rows > 1 )
{
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 ;
- return PreferredSize3(tw, cw, ch, reply_width, reply_height) ;
+ ret = PreferredSize3(tw, cw, ch, reply_width, reply_height) ;
+
+ assert (*reply_width > 0 && *reply_height > 0);
+ return ret;
}
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)
{