# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1056512384 0 # Node ID 935436731b411e2b61b33376bf4ac23636bb30c5 # Parent dd04a4d781f8c158784dd0b1834d4161723d73a3 Hybrid fix, seems the last change illiminated some important code that dealt with varying padding sizes in the opposite direction of the box. This readds that code but optimizes it and includes the groupbox calculations that were already present in the previous code path. This fix will be added to the OS/2 tree as well pending testing of this new code path. diff -r dd04a4d781f8 -r 935436731b41 dw.h --- a/dw.h Mon Jun 23 22:50:18 2003 +0000 +++ b/dw.h Wed Jun 25 03:39:44 2003 +0000 @@ -497,7 +497,7 @@ /* Box type - horizontal or vertical */ int type; /* Padding */ - int pad, parentpad; + int pad, parentpad, grouppadx, grouppady; /* Groupbox */ HWND grouphwnd; /* Default item */ diff -r dd04a4d781f8 -r 935436731b41 win/dw.c --- a/win/dw.c Mon Jun 23 22:50:18 2003 +0000 +++ b/win/dw.c Wed Jun 25 03:39:44 2003 +0000 @@ -844,7 +844,6 @@ /* Used for the SIZEEXPAND */ int nux = *usedx, nuy = *usedy; int nupx = *usedpadx, nupy = *usedpady; - int textheight = 0; (*usedx) += (thisbox->pad * 2); (*usedy) += (thisbox->pad * 2); @@ -853,16 +852,25 @@ { char *text = dw_window_get_text(thisbox->grouphwnd); + thisbox->grouppady = 0; + if(text) { - dw_font_text_extents(thisbox->grouphwnd, 0, text, NULL, &textheight); + dw_font_text_extents(thisbox->grouphwnd, 0, text, NULL, &thisbox->grouppady); dw_free(text); } - (*usedx) += 6; - (*usedpadx) += 6; - (*usedy) += textheight ? (3 + textheight) : 6; - (*usedpady) += textheight ? (3 + textheight) : 6; + if(thisbox->grouppady) + thisbox->grouppady += 3; + else + thisbox->grouppady = 6; + + thisbox->grouppadx = 6; + + (*usedx) += thisbox->grouppadx; + (*usedpadx) += thisbox->grouppadx; + (*usedy) += thisbox->grouppady; + (*usedpady) += thisbox->grouppady; } for(z=0;zcount;z++) @@ -908,10 +916,30 @@ tmp->xratio = thisbox->xratio; tmp->yratio = thisbox->yratio; - if((thisbox->items[z].width-tmp->upx)!=0) - tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); - if((thisbox->items[z].height-tmp->upy)!=0) - tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); + if(thisbox->type == DW_VERT) + { + int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady; + + if((thisbox->items[z].width - tmppad)!=0) + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad)); + } + else + { + if((thisbox->items[z].width-tmp->upx)!=0) + tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); + } + if(thisbox->type == DW_HORZ) + { + int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx; + + if((thisbox->items[z].height-tmppad)!=0) + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad)); + } + else + { + if((thisbox->items[z].height-tmp->upy)!=0) + tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); + } nux = *usedx; nuy = *usedy; upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2); @@ -933,14 +961,39 @@ if(pass > 1 && *depth > 0) { - if(thisbox->minwidth-thisbox->upx == 0) - thisbox->items[z].xratio = 1.0; + if(thisbox->type == DW_VERT) + { + int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx; + + if((thisbox->minwidth-tmppad) == 0) + thisbox->items[z].xratio = 1.0; + else + thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad)); + } else - thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); - if(thisbox->minheight-thisbox->upy == 0) - thisbox->items[z].yratio = 1.0; + { + if(thisbox->minwidth-thisbox->upx == 0) + thisbox->items[z].xratio = 1.0; + else + thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); + } + + if(thisbox->type == DW_HORZ) + { + int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady; + + if((thisbox->minheight-tmppad) == 0) + thisbox->items[z].yratio = 1.0; + else + thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad)); + } else - thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); + { + if(thisbox->minheight-thisbox->upy == 0) + thisbox->items[z].yratio = 1.0; + else + thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); + } if(thisbox->items[z].type == TYPEBOX) { @@ -1038,7 +1091,7 @@ if(thisbox->grouphwnd) { currentx += 3; - currenty += textheight ? textheight : 3; + currenty += thisbox->grouppady - 3; } /* The second pass is for expansion and actual placement. */