branches/kale/src/osd/modules/debugger/osx/debugview.m
| r244570 | r244571 | |
| 168 | 168 | // this gets all the lines that are at least partially visible |
| 169 | 169 | debug_view_xy origin(0, 0), size(totalWidth, totalHeight); |
| 170 | 170 | [self convertBounds:[self visibleRect] toFirstAffectedLine:&origin.y count:&size.y]; |
| 171 | size.y = MIN(size.y, totalHeight - origin.y); |
| 171 | 172 | |
| 172 | 173 | // tell the underlying view how much real estate is available |
| 173 | 174 | view->set_visible_size(size); |
| r244570 | r244571 | |
| 196 | 197 | |
| 197 | 198 | - (void)adjustSizeAndRecomputeVisible { |
| 198 | 199 | NSSize const clip = [[[self enclosingScrollView] contentView] bounds].size; |
| 199 | | NSSize const content = NSMakeSize((fontWidth * totalWidth) + (2 * [textContainer lineFragmentPadding]), |
| 200 | | fontHeight * totalHeight); |
| 201 | | [self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))]; |
| 200 | NSSize content = NSMakeSize((fontWidth * totalWidth) + (2 * [textContainer lineFragmentPadding]), |
| 201 | fontHeight * totalHeight); |
| 202 | if (wholeLineScroll) |
| 203 | content.height += (fontHeight * 2) - 1; |
| 204 | [self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)), |
| 205 | ceil(MAX(clip.height, content.height)))]; |
| 202 | 206 | [self recomputeVisible]; |
| 203 | 207 | } |
| 204 | 208 | |
| r244570 | r244571 | |
| 208 | 212 | } |
| 209 | 213 | |
| 210 | 214 | |
| 211 | | - (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m { |
| 215 | - (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m wholeLineScroll:(BOOL)w { |
| 212 | 216 | if (!(self = [super initWithFrame:f])) |
| 213 | 217 | return nil; |
| 214 | 218 | type = t; |
| r244570 | r244571 | |
| 218 | 222 | [self release]; |
| 219 | 223 | return nil; |
| 220 | 224 | } |
| 221 | | totalWidth = totalHeight = 0; |
| 225 | wholeLineScroll = w; |
| 226 | debug_view_xy const size = view->total_size(); |
| 227 | totalWidth = size.x; |
| 228 | totalHeight = size.y; |
| 222 | 229 | originTop = 0; |
| 223 | 230 | |
| 224 | 231 | text = [[NSTextStorage alloc] init]; |
| r244570 | r244571 | |
| 258 | 265 | if (scroller) |
| 259 | 266 | { |
| 260 | 267 | NSSize const clip = [[scroller contentView] bounds].size; |
| 261 | | NSSize const content = NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]), |
| 262 | | fontHeight * newSize.y); |
| 263 | | [self setFrameSize:NSMakeSize(MAX(clip.width, content.width), MAX(clip.height, content.height))]; |
| 264 | | [self recomputeVisible]; |
| 268 | NSSize content = NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]), |
| 269 | fontHeight * newSize.y); |
| 270 | if (wholeLineScroll) |
| 271 | content.height += (fontHeight * 2) - 1; |
| 272 | [self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)), |
| 273 | ceil(MAX(clip.height, content.height)))]; |
| 265 | 274 | } |
| 266 | 275 | totalWidth = newSize.x; |
| 267 | 276 | totalHeight = newSize.y; |
| r244570 | r244571 | |
| 273 | 282 | { |
| 274 | 283 | NSRect const visible = [self visibleRect]; |
| 275 | 284 | NSPoint scroll = NSMakePoint(visible.origin.x, newOrigin.y * fontHeight); |
| 276 | | if ((newOrigin.y + view->visible_size().y) == totalHeight) |
| 277 | | scroll.y += (view->visible_size().y * fontHeight) - visible.size.height; |
| 278 | 285 | [self scrollPoint:scroll]; |
| 279 | 286 | originTop = newOrigin.y; |
| 280 | 287 | } |
| r244570 | r244571 | |
| 287 | 294 | - (NSSize)maximumFrameSize { |
| 288 | 295 | debug_view_xy const max = view->total_size(); |
| 289 | 296 | return NSMakeSize(ceil((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding])), |
| 290 | | ceil(max.y * fontHeight)); |
| 297 | ceil((max.y + (wholeLineScroll ? 1 : 0)) * fontHeight)); |
| 291 | 298 | } |
| 292 | 299 | |
| 293 | 300 | |
| r244570 | r244571 | |
| 519 | 526 | selector:@selector(viewFrameDidChange:) |
| 520 | 527 | name:NSViewFrameDidChangeNotification |
| 521 | 528 | object:[scroller contentView]]; |
| 529 | [self adjustSizeAndRecomputeVisible]; |
| 522 | 530 | } |
| 523 | 531 | } |
| 524 | 532 | |
| r244570 | r244571 | |
| 558 | 566 | } |
| 559 | 567 | |
| 560 | 568 | |
| 569 | - (NSRect)adjustScroll:(NSRect)proposedVisibleRect { |
| 570 | if (wholeLineScroll) |
| 571 | { |
| 572 | CGFloat const clamp = [self bounds].size.height - fontHeight - proposedVisibleRect.size.height; |
| 573 | proposedVisibleRect.origin.y = MIN(proposedVisibleRect.origin.y, MAX(clamp, 0)); |
| 574 | proposedVisibleRect.origin.y -= fmod(proposedVisibleRect.origin.y, fontHeight); |
| 575 | } |
| 576 | return proposedVisibleRect; |
| 577 | } |
| 578 | |
| 579 | |
| 561 | 580 | - (void)drawRect:(NSRect)dirtyRect { |
| 562 | 581 | // work out what's available |
| 563 | 582 | [self recomputeVisible]; |