X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lwlib%2Fxlwtabs.c;h=ec1502a96658e378936e09efe68a4aa966494c1f;hb=b4c3e15c108cc55ef990c86049cc1e74eed3b918;hp=65af1eee796049b7683574b094c9c481860d8ef7;hpb=82f6d62ee211b1d36e8f45fed3ee3edde82b6916;p=chise%2Fxemacs-chise.git.1 diff --git a/lwlib/xlwtabs.c b/lwlib/xlwtabs.c index 65af1ee..ec1502a 100644 --- a/lwlib/xlwtabs.c +++ b/lwlib/xlwtabs.c @@ -66,6 +66,8 @@ #include #include #include + +#include "lwlib-internal.h" #include "../src/xmu.h" #include "xlwtabsP.h" #include "xlwgcs.h" @@ -144,6 +146,8 @@ static XtResource resources[] = { XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate, (XtPointer)0}, {XtNtopWidget, XtCTopWidget, XtRWidget, sizeof(Widget), offset(topWidget), XtRImmediate, NULL}, + {XtNhighlightWidget, XtCHighlightWidget, XtRWidget, sizeof(Widget), + offset(hilight), XtRImmediate, NULL}, {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer), offset(callbacks), XtRCallback, NULL}, {XtNpopdownCallback, XtCCallback, XtRCallback, sizeof(XtPointer), @@ -267,7 +271,7 @@ static void DrawHighlight( TabsWidget tw, Widget child, Bool undraw) ; 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 +279,9 @@ static void TabsShuffleRows( TabsWidget tw) ; 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 +396,6 @@ TabsClassRec tabsClassRec = { 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 +560,20 @@ TabsResize(Widget w) 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)) ; @@ -660,6 +652,12 @@ TabsSetValues(Widget current, Widget request, Widget new, if( tw->core.sensitive != curtw->core.sensitive ) needRedraw = True ; + /* Highlit widget changed */ + if ( tw->tabs.hilight != curtw->tabs.hilight ) + { + needRedraw = True ; + } + /* If top widget changes, need to change stacking order, redraw tabs. * Window system will handle the redraws. */ @@ -680,6 +678,7 @@ TabsSetValues(Widget current, Widget request, Widget new, if( tab->tabs.row != tw->tabs.numRows-1 ) TabsShuffleRows(tw) ; + needRedraw = True ; } else @@ -873,7 +872,8 @@ TabsGeometryManager(Widget w, XtWidgetGeometry *req, XtWidgetGeometry *reply) 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 +1505,26 @@ DrawFrame(TabsWidget tw) 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 +1730,10 @@ TabWidth(Widget w) */ 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 +1838,7 @@ MaxChild(TabsWidget tw, Widget except, Dimension cw, Dimension ch) 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 +1880,7 @@ TabsShuffleRows(TabsWidget tw) { 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 +1980,22 @@ PreferredSize( 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; } @@ -1979,8 +2004,8 @@ PreferredSize2( 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) {