# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1300948541 0 # Node ID 16964b141964703207ba54eca9aa501a14481a86 # Parent 1a0bbb2aa9dd8dee1c3f7742cf24b991eb682341 More accurate groupbox paddig calculations. Title rectangle is now calculated on the fly. Additionally the default border size of 5 is pulled from the Apple documentation to replace my guess of 4. diff -r 1a0bbb2aa9dd -r 16964b141964 mac/dw.m --- a/mac/dw.m Thu Mar 24 02:07:12 2011 +0000 +++ b/mac/dw.m Thu Mar 24 06:35:41 2011 +0000 @@ -1621,10 +1621,8 @@ unsigned long _foreground = 0xAAAAAA, _background = 0; -/* TODO: Figure out how to calculate these on the fly */ -#define _DW_GROUPBOX_BORDER_Y 12 -#define _DW_GROUPBOX_BORDER_X 8 -#define _DW_GROUPBOX_BORDER 4 +/* Default border is 5.0 according to the documentation */ +#define _DW_GROUPBOX_BORDER 5 /* This function calculates how much space the widgets and boxes require * and does expansion as necessary. @@ -1644,8 +1642,13 @@ /* Handle special groupbox case */ if(thisbox->grouphwnd) { - thisbox->grouppadx = _DW_GROUPBOX_BORDER_X; - thisbox->grouppady = _DW_GROUPBOX_BORDER_Y; + DWGroupBox *groupbox = thisbox->grouphwnd; + NSRect titleRect; + + /* Get the title size for a more accurate groupbox padding size */ + titleRect = [groupbox titleRect]; + thisbox->grouppadx = _DW_GROUPBOX_BORDER * 2; + thisbox->grouppady = (_DW_GROUPBOX_BORDER * 2) + titleRect.size.height; (*usedx) += thisbox->grouppadx; (*usedpadx) += thisbox->grouppadx; @@ -2481,9 +2484,10 @@ NSBox *groupbox = [[DWGroupBox alloc] init]; DWBox *thisbox = dw_box_new(type, pad); Box *box = [thisbox box]; - box->grouphwnd = groupbox; + [groupbox setBorderType:NSBezelBorder]; [groupbox setTitle:[NSString stringWithUTF8String:title]]; + box->grouphwnd = groupbox; [groupbox setContentView:thisbox]; return groupbox; }