branches/kale/src/osd/modules/debugger/osx/debugwindowhandler.m
| r244569 | r244570 | |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | - (void)cascadeWindowWithDesiredSize:(NSSize)desired forView:(NSView *)view { |
| 319 | | NSRect available = [[NSScreen mainScreen] visibleFrame]; |
| 320 | | NSRect windowFrame = [window frame]; |
| 321 | | NSSize current = [view frame].size; |
| 322 | | |
| 319 | // convert desired size to an adjustment and apply it to the current window frame |
| 320 | NSSize const current = [view frame].size; |
| 323 | 321 | desired.width -= current.width; |
| 324 | 322 | desired.height -= current.height; |
| 323 | NSRect windowFrame = [window frame]; |
| 324 | windowFrame.size.width += desired.width; |
| 325 | windowFrame.size.height += desired.height; |
| 325 | 326 | |
| 326 | | windowFrame.size.width += desired.width; |
| 327 | // limit the size to the minimum size |
| 328 | NSSize const minimum = [window minSize]; |
| 329 | windowFrame.size.width = MAX(windowFrame.size.width, minimum.width); |
| 330 | windowFrame.size.height = MAX(windowFrame.size.height, minimum.height); |
| 331 | |
| 332 | // limit the size to the main screen size |
| 333 | NSRect const available = [[NSScreen mainScreen] visibleFrame]; |
| 327 | 334 | windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); |
| 328 | | windowFrame.size.height += desired.height; |
| 329 | | windowFrame.size.height = MIN(MIN(MAX(windowFrame.size.height, 120), 320), available.size.height); |
| 335 | windowFrame.size.height = MIN(windowFrame.size.height, available.size.height); |
| 336 | |
| 337 | // arbitrary additional height limit |
| 338 | windowFrame.size.height = MIN(windowFrame.size.height, 320); |
| 339 | |
| 340 | // place it in the bottom right corner and apply |
| 330 | 341 | windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; |
| 331 | 342 | windowFrame.origin.y = available.origin.y; |
| 332 | 343 | [window setFrame:windowFrame display:YES]; |
| 333 | 344 | [[self class] cascadeWindow:window]; |
| 334 | | |
| 335 | | windowFrame = [[window contentView] frame]; |
| 336 | | desired = [window contentMinSize]; |
| 337 | | [window setContentMinSize:NSMakeSize(MIN(windowFrame.size.width, desired.width), |
| 338 | | MIN(windowFrame.size.height, desired.height))]; |
| 339 | 345 | } |
| 340 | 346 | |
| 341 | 347 | @end |