1441 mustAdjust = NO;
1442 NSArray* subviews = [self RB___subviews];
1443 NSUInteger subcount = [subviews count];
1444 if (subcount<1) {
1445 return;
1446 }
1447 NSRect bounds = [self bounds];
1448
1449 if ((bounds.size.width<1.0)||(bounds.size.height<1.0)) {
1450 return;
1451 }
1452
1453 if (isAdjusting) {
1454 return;
1455 }
1456 isAdjusting = YES;
1457
1458 if ([delegate respondsToSelector:@selector(willAdjustSubviews:)]) {
1459 [delegate willAdjustSubviews:self];
1460 bounds = [self bounds];
1461 }
1462 NSUInteger divcount = subcount-1;
1463 if (divcount<1) {
1464
1465 if (dividers) {
1466 free(dividers);
1467 dividers = NULL;
1468 }
1469 } else {
1470
1471 NSUInteger divsiz = sizeof(NSRect)*divcount;
1472 dividers = (NSRect*)(dividers?reallocf(dividers,divsiz):malloc(divsiz));
1473 if (!dividers) {
1474 return;
1475 }
1476 }
1477
1479 double realsize = 0.0;
1480 double expsize = 0.0;
1481 CGFloat newsize = 0.0;
1482 CGFloat effsize = 0.0;
1483 CGFloat limit;
1485 NSUInteger i;
1486 BOOL ishor = [self isHorizontal];
1487 CGFloat divt = [self dividerThickness];
1488
1489 for (i=0;i<subcount;i++) {
1490 curr = &caches[i];
1491 [[subviews objectAtIndex:i] RB___copyIntoCache:curr];
1492 }
1493
1494 NSInteger sanity = excepting?-3:0;
1495 while (sanity++<3) {
1496
1497 if (sanity==1) {
1499 }
1500
1501
1502 NSUInteger smallest = 0;
1503 CGFloat smalldim = -1.0;
1504 BOOL haveexp = NO;
1505
1506
1507 for (i=0;i<subcount;i++) {
1508 curr = &caches[i];
1510 if (curr->
size>0.0) {
1511 expsize += curr->size;
1512 if (!isInScrollView) {
1513
1514 expsize += curr->fraction;
1515 }
1516 haveexp = YES;
1517 } else {
1518 limit = [curr->sub minDimension];
1519 if (smalldim>limit) {
1520 smalldim = limit;
1521 smallest = i;
1522 }
1523 }
1524 }
1525
1526
1527 curr = &caches[smallest];
1528 if (!haveexp) {
1529 curr->
size = [curr->sub minDimension];
1531 expsize += curr->
size;
1532 }
1533 if (isInScrollView) {
1534
1535
1536 DIM(bounds.size) = expsize;
1537 break;
1538 } else {
1539
1540
1541 newsize =
DIM(bounds.size)-divcount*divt;
1542 if (expsize<1.0) {
1543 curr->
size = newsize;
1545 expsize = newsize;
1546 }
1547
1548
1549 BOOL constrained;
1550 effsize = newsize;
1551 do {
1552
1553
1554 double scale = newsize/expsize;
1555 constrained = NO;
1556 realsize = 0.0;
1557 expsize = 0.0;
1558 for (i=0;i<subcount;i++) {
1559
1560 curr = &caches[i];
1561 if (curr->
size>0.0) {
1562
1563 if (!curr->constrain) {
1564
1565 CGFloat cursize = (curr->size+curr->fraction)*scale;
1566
1567 if (([curr->sub RB___animationData:NO resize:NO]&&((limit = curr->size)>=0.0))||
1568 ((curr->sub==excepting)&&((limit = [curr->sub dimension])>0.0))||
1569 (cursize<(limit = [curr->sub minDimension]))||
1570 (cursize>(limit = [curr->sub maxDimension]))) {
1571
1572
1573 curr->constrain = constrained = YES;
1574
1575 cursize = limit;
1576 curr->fraction = 0.0;
1577 newsize -= cursize;
1578 } else {
1579
1580 double rem = fmod(cursize,1.0);
1581 cursize -= rem;
1582 if (rem>0.5) {
1583 ++cursize;
1584 --rem;
1585 }
1586 expsize += cursize;
1587 curr->fraction = rem;
1588 }
1589
1590 curr->size = cursize;
1591 }
1592
1594 }
1595 }
1596
1597
1598
1599
1600 } while (constrained&&(expsize>0.0));
1601
1602
1603
1604 limit = realsize-effsize;
1605 if (limit>=1.0) {
1606
1607
1608
1609 for (i=0;i<subcount;i++) {
1610 curr = &caches[i];
1611 if (curr->
constrain&&(curr->
sub!=excepting)&&([curr->
sub RB___animationData:NO resize:NO]==
nil)&&[curr->
sub canCollapse]) {
1612 realsize -= curr->size;
1613 if (realsize<1.0) {
1614 break;
1615 }
1617 if ((realsize-effsize)<1.0) {
1618 break;
1619 }
1620 }
1621 }
1622 } else if (limit<=-1.0) {
1623
1624
1625
1626 for (i=0;i<subcount;i++) {
1627 curr = &caches[i];
1628 if (curr->
size<=0.0) {
1629 curr->size = [curr->sub minDimension];
1630 curr->fraction = 0.0;
1631 realsize += curr->size;
1632 if ((realsize-effsize)>-1.0) {
1633 break;
1634 }
1635 }
1636 }
1637 } else {
1638
1639
1640 break;
1641 }
1642 }
1643
1644
1645
1646 }
1647
1648
1649 NSRect newframe = NSMakeRect(0.0,0.0,bounds.size.width,bounds.size.height);
1650
1651
1653
1654 NSInteger nested = NSNotFound;
1655
1656 for (i=0;i<subcount;i++) {
1657 curr = &caches[i];
1658
1659 if ((nested==NSNotFound)&&([curr->
sub asSplitView]!=
nil)) {
1660 nested = i;
1661 }
1662
1663 curr->
rect.origin = newframe.origin;
1666
1667 if ((curr->
size>0.0)&&mustClearFractions) {
1668 curr->fraction = 0.0;
1669 }
1670
1671 [curr->
sub RB___updateFromCache:curr withTotalDimension:effsize];
1672
1673 DIM(newframe.origin) += curr->
size;
1674 if (curr->
size>0.0) {
1675 last = curr->sub;
1676 }
1677 if (i==divcount) {
1678
1679
1680 CGFloat remain =
DIM(bounds.size)-
DIM(newframe.
origin);
1681 if (last&&(fabs(remain)>0.0)) {
1682
1683
1684
1685
1686 newframe = [last frame];
1687 DIM(newframe.size) += remain;
1689
1690 while ((i>0)&&(last!=[subviews objectAtIndex:i])) {
1692 }
1693 break;
1694 }
1695 } else {
1696
1697 DIM(newframe.size) = divt;
1698 if (dividers) {
1699 dividers[i] = newframe;
1700 }
1701 DIM(newframe.origin) += divt;
1702 }
1703 }
1704
1705 if (isInScrollView) {
1706 [super setFrameSize:bounds.size];
1707 }
1708
1709 for (i=nested;i<subcount;i++) {
1710 curr = &caches[i];
1712 if ([sv mustAdjust]) {
1714 }
1715 }
1716
1717 free(caches);
1718
1719 mustAdjust = NO;
1720 mustClearFractions = NO;
1721 [[self window] invalidateCursorRectsForView:self];
1722
1723 if (!isDragging) {
1724 [self saveState:NO];
1725 }
1726
1728 if (sv) {
1729 [[self window] invalidateCursorRectsForView:sv];
1730 }
1731 isAdjusting = NO;
1732
1733 if ([delegate respondsToSelector:@selector(didAdjustSubviews:)]) {
1734 [delegate didAdjustSubviews:self];
1735 }
1736}
void RB___setFrameSize:withFraction:(NSSize size,[withFraction] double value)