| 145 | | [_scrollView setHasHorizontalScroller:NO]; |
|---|
| 146 | | [_scrollView setHasVerticalScroller:NO]; |
|---|
| 147 | | |
|---|
| 148 | | visibleSize = [_scrollView documentVisibleRect].size; |
|---|
| 149 | | |
|---|
| 150 | | _adjustedImageScaling = _imageScaling; |
|---|
| 151 | | |
|---|
| 152 | | if(_imageScaling == FHScaleNone || |
|---|
| 153 | | _imageScaling == FHScaleWidthProportionally || |
|---|
| 154 | | _imageScaling == FHScaleHeightProportionally) { |
|---|
| 155 | | scrollerWidth = [NSScroller scrollerWidth]; |
|---|
| 156 | | widthAdjustment = heightAdjustment = 0.0; |
|---|
| 157 | | horizontalScroller = verticalScroller = NO; |
|---|
| 158 | | |
|---|
| 159 | | imageSize = [self _scaledSizeForSize:_rotatedImageSize usingScaling:_imageScaling bounds:visibleSize]; |
|---|
| 160 | | |
|---|
| 161 | | if(_imageScaling == FHScaleNone) { |
|---|
| 162 | | if(imageSize.height > visibleSize.height && imageSize.width > visibleSize.width) |
|---|
| 163 | | horizontalScroller = verticalScroller = YES; |
|---|
| 164 | | else if(imageSize.height > visibleSize.height) |
|---|
| 165 | | verticalScroller = YES; |
|---|
| 166 | | else if(imageSize.width > visibleSize.width) |
|---|
| 167 | | horizontalScroller = YES; |
|---|
| | 141 | if(_scrollView) { |
|---|
| | 142 | [_scrollView setHasHorizontalScroller:NO]; |
|---|
| | 143 | [_scrollView setHasVerticalScroller:NO]; |
|---|
| | 144 | |
|---|
| | 145 | visibleSize = [_scrollView documentVisibleRect].size; |
|---|
| | 146 | |
|---|
| | 147 | _adjustedImageScaling = _imageScaling; |
|---|
| | 148 | |
|---|
| | 149 | if(_imageScaling == FHScaleNone || |
|---|
| | 150 | _imageScaling == FHScaleWidthProportionally || |
|---|
| | 151 | _imageScaling == FHScaleHeightProportionally) { |
|---|
| | 152 | scrollerWidth = [NSScroller scrollerWidth]; |
|---|
| | 153 | widthAdjustment = heightAdjustment = 0.0; |
|---|
| | 154 | horizontalScroller = verticalScroller = NO; |
|---|
| | 155 | |
|---|
| | 156 | imageSize = [self _scaledSizeForSize:_rotatedImageSize usingScaling:_imageScaling bounds:visibleSize]; |
|---|
| | 157 | |
|---|
| | 158 | if(_imageScaling == FHScaleNone) { |
|---|
| | 159 | if(imageSize.height > visibleSize.height && imageSize.width > visibleSize.width) |
|---|
| | 160 | horizontalScroller = verticalScroller = YES; |
|---|
| | 161 | else if(imageSize.height > visibleSize.height) |
|---|
| | 162 | verticalScroller = YES; |
|---|
| | 163 | else if(imageSize.width > visibleSize.width) |
|---|
| | 164 | horizontalScroller = YES; |
|---|
| | 165 | } |
|---|
| | 166 | else if(_imageScaling == FHScaleWidthProportionally) { |
|---|
| | 167 | if(imageSize.height - visibleSize.height > scrollerWidth) { |
|---|
| | 168 | diff = scrollerWidth - (visibleSize.width - imageSize.width); |
|---|
| | 169 | |
|---|
| | 170 | if(diff > 0.0) |
|---|
| | 171 | heightAdjustment = ceil((imageSize.height / imageSize.width) * diff); |
|---|
| | 172 | |
|---|
| | 173 | verticalScroller = YES; |
|---|
| | 174 | } else { |
|---|
| | 175 | _adjustedImageScaling = FHScaleProportionally; |
|---|
| | 176 | } |
|---|
| | 177 | } |
|---|
| | 178 | else if(_imageScaling == FHScaleHeightProportionally) { |
|---|
| | 179 | if(imageSize.width - visibleSize.width > scrollerWidth) { |
|---|
| | 180 | diff = scrollerWidth - (visibleSize.height - imageSize.height); |
|---|
| | 181 | |
|---|
| | 182 | if(diff > 0.0) |
|---|
| | 183 | widthAdjustment = ceil((imageSize.width / imageSize.height) * diff); |
|---|
| | 184 | |
|---|
| | 185 | horizontalScroller = YES; |
|---|
| | 186 | } else { |
|---|
| | 187 | _adjustedImageScaling = FHScaleProportionally; |
|---|
| | 188 | } |
|---|
| | 189 | } |
|---|
| | 190 | |
|---|
| | 191 | if(_imageScaling != _adjustedImageScaling) |
|---|
| | 192 | imageSize = [self _scaledSizeForSize:_rotatedImageSize usingScaling:_adjustedImageScaling bounds:visibleSize]; |
|---|
| | 193 | |
|---|
| | 194 | frameSize = NSMakeSize(MAX(visibleSize.width, imageSize.width), MAX(visibleSize.height, imageSize.height)); |
|---|
| | 195 | frameSize.width -= widthAdjustment; |
|---|
| | 196 | frameSize.height -= heightAdjustment; |
|---|
| | 197 | |
|---|
| | 198 | [self setFrameSize:frameSize]; |
|---|
| | 199 | |
|---|
| | 200 | [_scrollView setHasHorizontalScroller:horizontalScroller]; |
|---|
| | 201 | [_scrollView setHasVerticalScroller:verticalScroller]; |
|---|
| | 202 | |
|---|
| | 203 | [self scrollPoint:NSMakePoint(0.0, frameSize.height)]; |
|---|
| | 204 | } else { |
|---|
| | 205 | [self setFrameSize:visibleSize]; |
|---|
| 169 | | else if(_imageScaling == FHScaleWidthProportionally) { |
|---|
| 170 | | if(imageSize.height - visibleSize.height > scrollerWidth) { |
|---|
| 171 | | diff = scrollerWidth - (visibleSize.width - imageSize.width); |
|---|
| 172 | | |
|---|
| 173 | | if(diff > 0.0) |
|---|
| 174 | | heightAdjustment = ceil((imageSize.height / imageSize.width) * diff); |
|---|
| 175 | | |
|---|
| 176 | | verticalScroller = YES; |
|---|
| 177 | | } else { |
|---|
| 178 | | _adjustedImageScaling = FHScaleProportionally; |
|---|
| 179 | | } |
|---|
| 180 | | } |
|---|
| 181 | | else if(_imageScaling == FHScaleHeightProportionally) { |
|---|
| 182 | | if(imageSize.width - visibleSize.width > scrollerWidth) { |
|---|
| 183 | | diff = scrollerWidth - (visibleSize.height - imageSize.height); |
|---|
| 184 | | |
|---|
| 185 | | if(diff > 0.0) |
|---|
| 186 | | widthAdjustment = ceil((imageSize.width / imageSize.height) * diff); |
|---|
| 187 | | |
|---|
| 188 | | horizontalScroller = YES; |
|---|
| 189 | | } else { |
|---|
| 190 | | _adjustedImageScaling = FHScaleProportionally; |
|---|
| 191 | | } |
|---|
| 192 | | } |
|---|
| 193 | | |
|---|
| 194 | | if(_imageScaling != _adjustedImageScaling) |
|---|
| 195 | | imageSize = [self _scaledSizeForSize:_rotatedImageSize usingScaling:_adjustedImageScaling bounds:visibleSize]; |
|---|
| 196 | | |
|---|
| 197 | | frameSize = NSMakeSize(MAX(visibleSize.width, imageSize.width), MAX(visibleSize.height, imageSize.height)); |
|---|
| 198 | | frameSize.width -= widthAdjustment; |
|---|
| 199 | | frameSize.height -= heightAdjustment; |
|---|
| 200 | | |
|---|
| 201 | | [self setFrameSize:frameSize]; |
|---|
| 202 | | |
|---|
| 203 | | [_scrollView setHasHorizontalScroller:horizontalScroller]; |
|---|
| 204 | | [_scrollView setHasVerticalScroller:verticalScroller]; |
|---|
| 205 | | |
|---|
| 206 | | [self scrollPoint:NSMakePoint(0.0, frameSize.height)]; |
|---|