# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1326562237 0 # Node ID f00f91d15cbf204ca718dfaa67dec4921188de61 # Parent cf897886ceebb45713b6e617dff5e7c644a17d3e Added additional code to MLE calculations on Mac to take into account the scrollview border and scrollbars. Also comments so I can figure it out later. diff -r cf897886ceeb -r f00f91d15cbf mac/dw.m --- a/mac/dw.m Sat Jan 14 01:50:39 2012 +0000 +++ b/mac/dw.m Sat Jan 14 17:30:37 2012 +0000 @@ -3543,7 +3543,9 @@ NSScrollView *sv = [object scrollview]; NSSize frame = [sv frame].size; BOOL hscroll = [sv hasHorizontalScroller]; + BOOL scrolled = FALSE; + /* Make sure word wrap is off for the first part */ if(!hscroll) { [[object textContainer] setWidthTracksTextView:NO]; @@ -3551,23 +3553,37 @@ [object setHorizontallyResizable:YES]; [sv setHasHorizontalScroller:YES]; } + /* Size the text view to fit */ [object sizeToFit]; size = [object bounds].size; + size.width += 2.0; + size.height += 2.0; + /* Re-enable word wrapping if it was on */ if(!hscroll) { [[object textContainer] setWidthTracksTextView:YES]; [sv setHasHorizontalScroller:NO]; } + /* If the un wrapped it is beyond the bounds... */ if(size.width > _DW_SCROLLED_MAX_WIDTH) { NSSize max = [object maxSize]; + /* Set the flag for later */ + scrolled = TRUE; + /* Set the max size to the limit */ [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)]; + /* Recalculate the size */ [object sizeToFit]; size = [object bounds].size; + size.width += 2.0; + size.height += 2.0; [object setMaxSize:max]; } [sv setFrameSize:frame]; + /* Take into account the horizontal scrollbar */ + if(hscroll && scrolled) + size.height += 16.0; } else size = [object frame].size;