4 |
|
* |
5 |
|
* $Id$ |
6 |
|
* |
7 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
7 |
> |
* Basilisk II (C) 1997-2003 Christian Bauer |
8 |
|
* |
9 |
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
* it under the terms of the GNU General Public License as published by |
30 |
|
self = [super init]; |
31 |
|
|
32 |
|
numItems = 0; |
33 |
< |
col1 = [[NSMutableArray alloc] init]; |
34 |
< |
col2 = [[NSMutableArray alloc] init]; |
33 |
> |
col1 = [NSMutableArray new]; |
34 |
> |
col2 = [NSMutableArray new]; |
35 |
|
|
36 |
|
return self; |
37 |
|
} |
115 |
|
|
116 |
|
#import <prefs.h> |
117 |
|
|
118 |
< |
#define DEBUG 1 |
118 |
> |
#define DEBUG 0 |
119 |
|
#import <debug.h> |
120 |
|
|
121 |
|
- (PrefsEditor *) init |
126 |
|
|
127 |
|
devs = @"/dev"; |
128 |
|
home = NSHomeDirectory(); |
129 |
< |
volsDS = [[TableDS alloc] init]; |
130 |
< |
SCSIds = [[TableDS alloc] init]; |
129 |
> |
volsDS = [TableDS new]; |
130 |
> |
SCSIds = [TableDS new]; |
131 |
|
|
132 |
< |
lockCell = [[NSImageCell alloc] init]; |
132 |
> |
lockCell = [NSImageCell new]; |
133 |
|
if ( lockCell == nil ) |
134 |
|
NSLog (@"%s - Can't create NSImageCell?", __PRETTY_FUNCTION__); |
135 |
|
|
136 |
< |
blank = [[NSImage alloc] init]; |
136 |
> |
blank = [NSImage new]; |
137 |
|
locked = [NSImage alloc]; |
138 |
|
if ( [locked initWithContentsOfFile: |
139 |
|
[[NSBundle mainBundle] |
281 |
|
edited = YES; |
282 |
|
} |
283 |
|
|
284 |
– |
// Screen/window changing stuff |
284 |
|
|
285 |
< |
// This is called when any of the screen/window, width, height or depth is changed |
285 |
> |
// If we are not using the CGIMAGEREF drawing strategy, |
286 |
> |
// then source bitmaps must be 32bits deep. |
287 |
|
|
288 |
< |
- (IBAction) ChangeScreen: (id)sender |
288 |
> |
- (short) testWinDepth: (int) newbpp |
289 |
|
{ |
290 |
+ |
#ifdef CGIMAGEREF |
291 |
+ |
return newbpp; |
292 |
+ |
#else |
293 |
+ |
if ( newbpp != 32 ) |
294 |
+ |
WarningSheet(@"Sorry - In windowed mode, depth must be 32", panel); |
295 |
+ |
return 32 |
296 |
+ |
#endif |
297 |
+ |
} |
298 |
+ |
|
299 |
+ |
// This is called when the screen/window, |
300 |
+ |
// width, height or depth is clicked. |
301 |
+ |
// |
302 |
+ |
// Note that sender may not actually be an NSMatrix. |
303 |
+ |
|
304 |
+ |
- (IBAction) ChangeScreen: (NSMatrix *)sender |
305 |
+ |
{ |
306 |
+ |
NSButton *cell = [sender selectedCell]; |
307 |
+ |
|
308 |
|
short newx = [width intValue]; |
309 |
|
short newy = [height intValue]; |
310 |
|
short newbpp = [depth intValue]; |
311 |
|
short newtype; |
312 |
|
char str[20]; |
313 |
|
|
314 |
< |
if ( [openGL state] ) |
297 |
< |
newtype = DISPLAY_OPENGL; |
298 |
< |
else if ( [screen state] ) |
314 |
> |
if ( cell == screen ) |
315 |
|
newtype = DISPLAY_SCREEN; |
316 |
< |
else if ( [window state] ) |
316 |
> |
else if ( cell == window ) |
317 |
|
newtype = DISPLAY_WINDOW; |
318 |
|
else |
319 |
|
newtype = display_type; |
322 |
|
if ( newbpp == init_depth && newx == init_width && |
323 |
|
newy == init_height && newtype == display_type ) |
324 |
|
{ |
325 |
< |
NSLog(@"No changed GUI items in ChangeScreen"); |
325 |
> |
D(NSLog(@"No changed GUI items in ChangeScreen")); |
326 |
|
return; |
327 |
|
} |
328 |
|
|
329 |
|
// If we are changing type, supply some sensible defaults |
330 |
+ |
|
331 |
+ |
short screenx = CGDisplayPixelsWide(kCGDirectMainDisplay), |
332 |
+ |
screeny = CGDisplayPixelsHigh(kCGDirectMainDisplay), |
333 |
+ |
screenb = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
334 |
+ |
|
335 |
|
if ( newtype != display_type ) |
336 |
|
{ |
337 |
< |
NSLog(@"Changing disylay type in ChangeScreen"); |
317 |
< |
if ( newtype == DISPLAY_SCREEN ) // If changing to full screen |
318 |
< |
{ |
319 |
< |
// supply main screen dimensions as a default |
320 |
< |
NSScreen *s = [NSScreen mainScreen]; |
321 |
< |
NSRect sr = [s frame]; |
322 |
< |
|
323 |
< |
newx = (short) sr.size.width; |
324 |
< |
newy = (short) sr.size.height; |
325 |
< |
// This always returns 24, despite the mode |
326 |
< |
//newbpp = NSBitsPerPixelFromDepth([s depth]); |
327 |
< |
newbpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay); |
328 |
< |
} |
337 |
> |
D(NSLog(@"Changing display type in ChangeScreen")); |
338 |
|
|
339 |
< |
if ( display_type == DISPLAY_SCREEN ) // If changing from full screen |
339 |
> |
// If changing to full screen, supply main screen dimensions as a default |
340 |
> |
if ( newtype == DISPLAY_SCREEN ) |
341 |
> |
newx = screenx, newy = screeny, newbpp = screenb; |
342 |
> |
|
343 |
> |
// If changing from full screen, use minimum screen resolutions |
344 |
> |
if ( display_type == DISPLAY_SCREEN ) |
345 |
> |
{ |
346 |
|
newx = MIN_WIDTH, newy = MIN_HEIGHT; |
347 |
< |
|
348 |
< |
[width setIntValue: newx]; |
334 |
< |
[height setIntValue: newy]; |
335 |
< |
[depth setIntValue: newbpp]; |
347 |
> |
newbpp = [self testWinDepth: newbpp]; |
348 |
> |
} |
349 |
|
} |
350 |
|
else |
351 |
|
{ |
352 |
+ |
newbpp = [self testWinDepth: newbpp]; |
353 |
+ |
|
354 |
|
// Check size is within ranges of MIN_WIDTH ... MAX_WIDTH |
355 |
|
// and MIN_HEIGHT ... MAX_HEIGHT |
356 |
|
// ??? |
357 |
|
} |
358 |
|
|
359 |
+ |
[width setIntValue: newx]; |
360 |
+ |
[height setIntValue: newy]; |
361 |
+ |
[depth setIntValue: newbpp]; |
362 |
+ |
|
363 |
|
|
364 |
|
// Store new prefs |
365 |
|
*str = '\0'; |
371 |
|
else |
372 |
|
sprintf(str, "win/%hd/%hd", newx, newy); |
373 |
|
break; |
355 |
– |
case DISPLAY_OPENGL: |
356 |
– |
if ( newbpp ) |
357 |
– |
sprintf(str, "opengl/%hd/%hd/%hd", newx, newy, newbpp); |
358 |
– |
else |
359 |
– |
sprintf(str, "opengl/%hd/%hd", newx, newy); |
360 |
– |
break; |
374 |
|
case DISPLAY_SCREEN: |
375 |
|
if ( newbpp ) |
376 |
|
sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp); |
386 |
|
|
387 |
|
if ( display_type != DISPLAY_SCREEN ) |
388 |
|
{ |
389 |
< |
NSLog(@"Display type is not SCREEN (%d), resizing window", display_type); |
389 |
> |
D(NSLog(@"Display type is not SCREEN (%d), resizing window", |
390 |
> |
display_type)); |
391 |
|
resizeWinTo(newx, newy); |
392 |
|
} |
393 |
|
} |
426 |
|
} |
427 |
|
} |
428 |
|
|
429 |
+ |
- (BOOL) fileManager: (NSFileManager *) manager |
430 |
+ |
shouldProceedAfterError: (NSDictionary *) errorDict |
431 |
+ |
{ |
432 |
+ |
NSRunAlertPanel(@"File operation error", |
433 |
+ |
@"%@ %@, toPath %@", |
434 |
+ |
@"Bugger!", nil, nil, |
435 |
+ |
[errorDict objectForKey:@"Error"], |
436 |
+ |
[errorDict objectForKey:@"Path"], |
437 |
+ |
[errorDict objectForKey:@"ToPath"]); |
438 |
+ |
return NO; |
439 |
+ |
} |
440 |
+ |
|
441 |
|
- (IBAction) DeleteVolume: (id)sender |
442 |
|
{ |
443 |
< |
const char *path = [self RemoveVolumeEntry]; |
444 |
< |
if ( unlink(path) == -1 ) |
443 |
> |
// const char *path = [self RemoveVolumeEntry]; |
444 |
> |
// if ( unlink(path) == -1 ) |
445 |
> |
NSString *Path = [self RemoveVolumeEntry]; |
446 |
> |
|
447 |
> |
if ( ! [[NSFileManager defaultManager] removeFileAtPath: Path |
448 |
> |
handler: self] ) |
449 |
|
{ |
450 |
< |
NSLog(@"%s unlink(%s) failed", __PRETTY_FUNCTION__, path, strerror(errno)); |
450 |
> |
WarningSheet(@"Unable to delete volume", panel); |
451 |
> |
// NSLog(@"%s unlink(%s) failed - %s", __PRETTY_FUNCTION__, path, strerror(errno)); |
452 |
|
} |
453 |
|
} |
454 |
|
|
551 |
|
PrefsRemoveItem(pref,0); |
552 |
|
} |
553 |
|
|
554 |
< |
- (const char *) RemoveVolumeEntry |
554 |
> |
//- (const char *) RemoveVolumeEntry |
555 |
> |
- (NSString *) RemoveVolumeEntry |
556 |
|
{ |
557 |
|
int row = [diskImages selectedRow]; |
558 |
|
|
559 |
|
if ( row != -1 ) |
560 |
|
{ |
561 |
< |
const char *path = [[volsDS pathAtRow: row] cString], |
561 |
> |
NSString *Path = [volsDS pathAtRow: row]; |
562 |
> |
const char *path = [Path cString], |
563 |
|
*str; |
564 |
|
int tmp = 0; |
565 |
|
|
568 |
|
if ( strcmp(str, path) == 0 ) |
569 |
|
{ |
570 |
|
PrefsRemoveItem("disk", tmp); |
571 |
< |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", __PRETTY_FUNCTION__, tmp)); |
571 |
> |
D(NSLog(@"%s - Deleted prefs entry \"disk\", %d", |
572 |
> |
__PRETTY_FUNCTION__, tmp)); |
573 |
|
edited = YES; |
574 |
|
break; |
575 |
|
} |
578 |
|
|
579 |
|
if ( str == NULL ) |
580 |
|
{ |
581 |
< |
NSLog(@"%s - Couldn't find any disk preference to match %s", __PRETTY_FUNCTION__, path); |
581 |
> |
NSLog(@"%s - Couldn't find any disk preference to match %s", |
582 |
> |
__PRETTY_FUNCTION__, path); |
583 |
|
return NULL; |
584 |
|
} |
585 |
|
|
586 |
|
if ( ! [volsDS deleteRow: row] ) |
587 |
|
NSLog (@"%s - RemoveVolume %d failed", __PRETTY_FUNCTION__, tmp); |
588 |
|
[diskImages reloadData]; |
589 |
< |
return path; |
589 |
> |
// return path; |
590 |
> |
return Path; |
591 |
|
} |
592 |
|
else |
593 |
|
{ |
677 |
|
switch ( display_type ) |
678 |
|
{ |
679 |
|
case DISPLAY_WINDOW: [window setState: YES]; break; |
644 |
– |
case DISPLAY_OPENGL: [openGL setState: YES]; break; |
680 |
|
case DISPLAY_SCREEN: [screen setState: YES]; break; |
681 |
|
} |
682 |
|
|