ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/PrefsEditor.mm
(Generate patch)

Comparing BasiliskII/src/MacOSX/PrefsEditor.mm (file contents):
Revision 1.5 by nigel, 2002-12-18T11:56:12Z vs.
Revision 1.10 by nigel, 2003-04-02T02:19:53Z

# Line 4 | Line 4
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
# Line 109 | Line 109
109  
110   #import <AppKit/NSImage.h>              // For [NSBundle pathForImageResource:] proto
111  
112 + #include <string>
113 + using std::string;
114 + extern string UserPrefsPath;    // from prefs_unix.cpp
115 +
116   #import "sysdeps.h"                             // Types used in Basilisk C++ code
117   #import "video_macosx.h"                // some items that we edit here
118   #import "misc_macosx.h"                 // WarningSheet() prototype
# Line 218 | Line 222
222          }
223   }
224  
225 + - (IBAction) BrowsePrefs:               (id)sender
226 + {
227 +        NSOpenPanel *oP = [NSOpenPanel openPanel];
228 +
229 +        [oP setCanChooseFiles: YES];
230 +        [oP setTitle:  @"Select a Preferences file"];
231 +        D(NSLog(@"%s - home = %@", __PRETTY_FUNCTION__, home));
232 +        if ( [oP runModalForDirectory: ([prefsFile stringValue] ? [prefsFile stringValue] : home)
233 +                                                         file:nil
234 +                                                        types:nil] == NSOKButton )
235 +        {
236 +                [prefsFile setStringValue: [oP filename] ];
237 +                UserPrefsPath = [[oP filename] cString];
238 +        }
239 + }
240 +
241   - (IBAction) BrowseROM:         (id)sender
242   {
243          NSOpenPanel *oP = [NSOpenPanel openPanel];
# Line 281 | Line 301
301          edited = YES;
302   }
303  
304 < // This is called when any of the screen/openGL/window,
304 >
305 > // If we are not using the CGIMAGEREF drawing strategy,
306 > // then source bitmaps must be 32bits deep.
307 >
308 > - (short) testWinDepth: (int) newbpp
309 > {
310 > #ifdef CGIMAGEREF
311 >        return newbpp;
312 > #else
313 >        if ( newbpp != 32 )
314 >                WarningSheet(@"Sorry - In windowed mode, depth must be 32", panel);
315 >        return 32
316 > #endif
317 > }
318 >
319 > // This is called when the screen/window,
320   // width, height or depth is clicked.
321   //
322   // Note that sender may not actually be an NSMatrix.
# Line 296 | Line 331
331          short newtype;
332          char  str[20];
333  
334 <        if ( cell == openGL )
300 <                newtype = DISPLAY_OPENGL;
301 <        else if ( cell == screen )
334 >        if ( cell == screen )
335                  newtype = DISPLAY_SCREEN;
336          else if ( cell == window )
337                  newtype = DISPLAY_WINDOW;
# Line 314 | Line 347
347          }
348  
349          // If we are changing type, supply some sensible defaults
350 +
351 +        short   screenx = CGDisplayPixelsWide(kCGDirectMainDisplay),
352 +                        screeny = CGDisplayPixelsHigh(kCGDirectMainDisplay),
353 +                        screenb = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
354 +
355          if ( newtype != display_type )
356          {
357                  D(NSLog(@"Changing display type in ChangeScreen"));
320                if ( newtype == DISPLAY_SCREEN )                // If changing to full screen
321                {
322                        // supply main screen dimensions as a default
323                        newx   = CGDisplayPixelsWide  (kCGDirectMainDisplay);
324                        newy   = CGDisplayPixelsHigh  (kCGDirectMainDisplay);
325                        newbpp = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
326                }
358  
359 <                if ( display_type == DISPLAY_SCREEN )   // If changing from full screen
359 >                // If changing to full screen, supply main screen dimensions as a default
360 >                if ( newtype == DISPLAY_SCREEN )
361 >                        newx = screenx, newy = screeny, newbpp = screenb;
362 >
363 >                // If changing from full screen, use minimum screen resolutions
364 >                if ( display_type == DISPLAY_SCREEN )
365 >        {
366                          newx = MIN_WIDTH, newy = MIN_HEIGHT;
367 <
368 <                [width  setIntValue: newx];
332 <                [height setIntValue: newy];
333 <                [depth  setIntValue: newbpp];
367 >                        newbpp = [self testWinDepth: newbpp];
368 >        }
369          }
370          else
371          {
372 +                newbpp = [self testWinDepth: newbpp];
373 +
374                  // Check size is within ranges of MIN_WIDTH ... MAX_WIDTH
375                  //                                                      and MIN_HEIGHT ... MAX_HEIGHT
376                  // ???
377          }
378  
379 +        [width  setIntValue: newx];
380 +        [height setIntValue: newy];
381 +        [depth  setIntValue: newbpp];
382 +
383  
384          // Store new prefs
385          *str = '\0';
# Line 350 | Line 391
391                          else
392                                  sprintf(str, "win/%hd/%hd",  newx, newy);
393                          break;
353                case DISPLAY_OPENGL:
354                        if ( newbpp )
355                                sprintf(str, "opengl/%hd/%hd/%hd",  newx, newy, newbpp);
356                        else
357                                sprintf(str, "opengl/%hd/%hd",  newx, newy);
358                        break;
394                  case DISPLAY_SCREEN:
395                          if ( newbpp )
396                                  sprintf(str, "full/%hd/%hd/%hd", newx, newy, newbpp);
# Line 586 | Line 621 | shouldProceedAfterError: (NSDictionary *
621          [self RemoveVolumeEntry];
622   }
623  
624 < - (IBAction) ResetPrefs: (id)sender
624 > - (void) loadPrefs: (int) argc
625 >                          args: (char **) argv
626   {
591        int             argc = 0;
592        char    **argv = NULL;
593
627          [panel close];                          // Temporarily hide preferences panel
628  
629          PrefsExit();                            // Purge all the old pref values
# Line 606 | Line 639 | shouldProceedAfterError: (NSDictionary *
639          edited = NO;
640   }
641  
642 + - (IBAction) LoadPrefs: (id)sender
643 + {
644 +        int             argc = 2;
645 +        char    *argv[2];
646 +
647 +        argv[0] = "--prefs",
648 +        argv[1] = (char *) [[prefsFile stringValue] cString];
649 +
650 +        [self loadPrefs: argc
651 +                           args: argv];
652 + }
653 +
654 + - (IBAction) ResetPrefs: (id)sender
655 + {
656 +        [self loadPrefs: 0
657 +                           args: NULL];
658 + }
659 +
660   - (void) setStringOf: (NSTextField *) field
661                          fromPref: (const char *)  prefName
662   {
# Line 651 | Line 702 | shouldProceedAfterError: (NSDictionary *
702          [self setStringOf: printer       fromPref: "serialb"];
703      [self setStringOf: ROMfile   fromPref: "rom"        ];
704  
705 +        [prefsFile setStringValue: [NSString stringWithCString: UserPrefsPath.c_str()] ];
706 +
707  
708          parse_screen_prefs(PrefsFindString("screen"));
709  
# Line 658 | Line 711 | shouldProceedAfterError: (NSDictionary *
711          [height setIntValue: init_height];
712          [depth  setIntValue: init_depth];
713  
714 <        [window setState: NO];
714 >        [screen setState: NO];
715          switch ( display_type )
716          {
717                  case DISPLAY_WINDOW: [window setState: YES]; break;
665                case DISPLAY_OPENGL: [openGL setState: YES]; break;
718                  case DISPLAY_SCREEN: [screen setState: YES]; break;
719          }
720  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines