Mercurial > dwindows
changeset 1552:f00f91d15cbf
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 14 Jan 2012 17:30:37 +0000 |
parents | cf897886ceeb |
children | 46a2123ff570 |
files | mac/dw.m |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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;