|
|
1.1 root 1: /*
2: Hatari - CreateFloppyController.m
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6:
7: Create floppy image window controller implementation file
8:
9: Feb-Mar 2006, Sébastien Molines - Created
10: */
11:
12: #import "CreateFloppyController.h"
13: #import "Shared.h"
14:
15: #include "main.h"
16: #include "configuration.h"
17: #include "createBlankImage.h"
18:
19: @implementation CreateFloppyController
20:
21: - (IBAction)createFloppyImage:(id)sender
22: {
23: // Create a SavePanel
24: NSSavePanel *savePanel = [NSSavePanel savePanel];
25:
26: // Set its allowed file types
27: NSArray* allowedFileTypes = [NSArray arrayWithObjects: @"st", @"msa", @"dim", @"gz", nil];
28: [savePanel setAllowedFileTypes:allowedFileTypes];
29:
30: // Get the default images directory
31: NSString* defaultDir = [NSString stringWithCString:ConfigureParams.DiskImage.szDiskImageDirectory];
32:
33: // Run the SavePanel, then check if the user clicked OK
34: if ( NSOKButton == [savePanel runModalForDirectory:defaultDir file:nil] )
35: {
36: // Get the path to the chosen file
37: NSString *path = [savePanel filename];
38:
39: // Make a non-const C string out of it
40: const char* constSzPath = [path cString];
41: size_t cbPath = strlen(constSzPath) + 1;
42: char szPath[cbPath];
43: strncpy(szPath, constSzPath, cbPath);
44:
45: // Get the tracks, sectors and sides values
46: int cTracks = [[tracks selectedCell] tag];
47: int cSectors = [[sectors selectedCell] tag];
48: int cSides = [[sides selectedCell] tag];
49:
50: // Create the image
51: CreateBlankImage_CreateFile(szPath, cTracks, cSectors, cSides);
52: }
53: }
54:
55: - (void)awakeFromNib
56: {
57: // Fill the "Tracks" dropdown
58: [tracks removeAllItems];
59: int i;
60: for (i = 40; i <= 85; i++)
61: {
62: [tracks addItemWithTitle:[NSString stringWithFormat:@"%d", i]];
63: [[tracks lastItem] setTag:i];
64: }
65:
66: // Select the default value of 80 tracks
67: [tracks selectItemAtIndex:[tracks indexOfItemWithTag:80]]; // Equivalent to Tiger-only [tracks selectItemWithTag:80];
68:
69:
70: }
71:
72: - (IBAction)runModal:(id)sender
73: {
74: [[ModalWrapper alloc] runModal:window];
75: }
76:
77:
78: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.