Mercurial > dwindows
comparison mac/dw.m @ 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 |
comparison
equal
deleted
inserted
replaced
1551:cf897886ceeb | 1552:f00f91d15cbf |
---|---|
3541 if([ object isMemberOfClass:[DWMLE class] ]) | 3541 if([ object isMemberOfClass:[DWMLE class] ]) |
3542 { | 3542 { |
3543 NSScrollView *sv = [object scrollview]; | 3543 NSScrollView *sv = [object scrollview]; |
3544 NSSize frame = [sv frame].size; | 3544 NSSize frame = [sv frame].size; |
3545 BOOL hscroll = [sv hasHorizontalScroller]; | 3545 BOOL hscroll = [sv hasHorizontalScroller]; |
3546 BOOL scrolled = FALSE; | |
3546 | 3547 |
3548 /* Make sure word wrap is off for the first part */ | |
3547 if(!hscroll) | 3549 if(!hscroll) |
3548 { | 3550 { |
3549 [[object textContainer] setWidthTracksTextView:NO]; | 3551 [[object textContainer] setWidthTracksTextView:NO]; |
3550 [[object textContainer] setContainerSize:[object maxSize]]; | 3552 [[object textContainer] setContainerSize:[object maxSize]]; |
3551 [object setHorizontallyResizable:YES]; | 3553 [object setHorizontallyResizable:YES]; |
3552 [sv setHasHorizontalScroller:YES]; | 3554 [sv setHasHorizontalScroller:YES]; |
3553 } | 3555 } |
3556 /* Size the text view to fit */ | |
3554 [object sizeToFit]; | 3557 [object sizeToFit]; |
3555 size = [object bounds].size; | 3558 size = [object bounds].size; |
3559 size.width += 2.0; | |
3560 size.height += 2.0; | |
3561 /* Re-enable word wrapping if it was on */ | |
3556 if(!hscroll) | 3562 if(!hscroll) |
3557 { | 3563 { |
3558 [[object textContainer] setWidthTracksTextView:YES]; | 3564 [[object textContainer] setWidthTracksTextView:YES]; |
3559 [sv setHasHorizontalScroller:NO]; | 3565 [sv setHasHorizontalScroller:NO]; |
3560 } | 3566 } |
3567 /* If the un wrapped it is beyond the bounds... */ | |
3561 if(size.width > _DW_SCROLLED_MAX_WIDTH) | 3568 if(size.width > _DW_SCROLLED_MAX_WIDTH) |
3562 { | 3569 { |
3563 NSSize max = [object maxSize]; | 3570 NSSize max = [object maxSize]; |
3564 | 3571 |
3572 /* Set the flag for later */ | |
3573 scrolled = TRUE; | |
3574 /* Set the max size to the limit */ | |
3565 [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)]; | 3575 [object setMaxSize:NSMakeSize(_DW_SCROLLED_MAX_WIDTH, max.height)]; |
3576 /* Recalculate the size */ | |
3566 [object sizeToFit]; | 3577 [object sizeToFit]; |
3567 size = [object bounds].size; | 3578 size = [object bounds].size; |
3579 size.width += 2.0; | |
3580 size.height += 2.0; | |
3568 [object setMaxSize:max]; | 3581 [object setMaxSize:max]; |
3569 } | 3582 } |
3570 [sv setFrameSize:frame]; | 3583 [sv setFrameSize:frame]; |
3584 /* Take into account the horizontal scrollbar */ | |
3585 if(hscroll && scrolled) | |
3586 size.height += 16.0; | |
3571 } | 3587 } |
3572 else | 3588 else |
3573 size = [object frame].size; | 3589 size = [object frame].size; |
3574 | 3590 |
3575 thiswidth = size.width; | 3591 thiswidth = size.width; |