Mercurial > dwindows
comparison mac/dw.m @ 806:16964b141964
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 24 Mar 2011 06:35:41 +0000 |
parents | 1a0bbb2aa9dd |
children | f7016a38bedd |
comparison
equal
deleted
inserted
replaced
805:1a0bbb2aa9dd | 806:16964b141964 |
---|---|
1619 return 0L; | 1619 return 0L; |
1620 } | 1620 } |
1621 | 1621 |
1622 unsigned long _foreground = 0xAAAAAA, _background = 0; | 1622 unsigned long _foreground = 0xAAAAAA, _background = 0; |
1623 | 1623 |
1624 /* TODO: Figure out how to calculate these on the fly */ | 1624 /* Default border is 5.0 according to the documentation */ |
1625 #define _DW_GROUPBOX_BORDER_Y 12 | 1625 #define _DW_GROUPBOX_BORDER 5 |
1626 #define _DW_GROUPBOX_BORDER_X 8 | |
1627 #define _DW_GROUPBOX_BORDER 4 | |
1628 | 1626 |
1629 /* This function calculates how much space the widgets and boxes require | 1627 /* This function calculates how much space the widgets and boxes require |
1630 * and does expansion as necessary. | 1628 * and does expansion as necessary. |
1631 */ | 1629 */ |
1632 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, | 1630 static int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy, |
1642 int thispady = thisbox->pad * 2; | 1640 int thispady = thisbox->pad * 2; |
1643 | 1641 |
1644 /* Handle special groupbox case */ | 1642 /* Handle special groupbox case */ |
1645 if(thisbox->grouphwnd) | 1643 if(thisbox->grouphwnd) |
1646 { | 1644 { |
1647 thisbox->grouppadx = _DW_GROUPBOX_BORDER_X; | 1645 DWGroupBox *groupbox = thisbox->grouphwnd; |
1648 thisbox->grouppady = _DW_GROUPBOX_BORDER_Y; | 1646 NSRect titleRect; |
1647 | |
1648 /* Get the title size for a more accurate groupbox padding size */ | |
1649 titleRect = [groupbox titleRect]; | |
1650 thisbox->grouppadx = _DW_GROUPBOX_BORDER * 2; | |
1651 thisbox->grouppady = (_DW_GROUPBOX_BORDER * 2) + titleRect.size.height; | |
1649 | 1652 |
1650 (*usedx) += thisbox->grouppadx; | 1653 (*usedx) += thisbox->grouppadx; |
1651 (*usedpadx) += thisbox->grouppadx; | 1654 (*usedpadx) += thisbox->grouppadx; |
1652 (*usedy) += thisbox->grouppady; | 1655 (*usedy) += thisbox->grouppady; |
1653 (*usedpady) += thisbox->grouppady; | 1656 (*usedpady) += thisbox->grouppady; |
2479 HWND API dw_groupbox_new(int type, int pad, char *title) | 2482 HWND API dw_groupbox_new(int type, int pad, char *title) |
2480 { | 2483 { |
2481 NSBox *groupbox = [[DWGroupBox alloc] init]; | 2484 NSBox *groupbox = [[DWGroupBox alloc] init]; |
2482 DWBox *thisbox = dw_box_new(type, pad); | 2485 DWBox *thisbox = dw_box_new(type, pad); |
2483 Box *box = [thisbox box]; | 2486 Box *box = [thisbox box]; |
2484 box->grouphwnd = groupbox; | 2487 |
2485 [groupbox setBorderType:NSBezelBorder]; | 2488 [groupbox setBorderType:NSBezelBorder]; |
2486 [groupbox setTitle:[NSString stringWithUTF8String:title]]; | 2489 [groupbox setTitle:[NSString stringWithUTF8String:title]]; |
2490 box->grouphwnd = groupbox; | |
2487 [groupbox setContentView:thisbox]; | 2491 [groupbox setContentView:thisbox]; |
2488 return groupbox; | 2492 return groupbox; |
2489 } | 2493 } |
2490 | 2494 |
2491 #ifndef INCOMPLETE | 2495 #ifndef INCOMPLETE |