1 |
/* |
2 |
* $Id: misc_macosx.mm,v 1.3 2002/05/30 12:28:38 nigel Exp $ |
3 |
* |
4 |
* misc_macosx.m - Miscellaneous Mac OS X routines. |
5 |
* |
6 |
* Basilisk II (C) 1997-2004 Christian Bauer |
7 |
* |
8 |
* This program is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License as published by |
10 |
* the Free Software Foundation; either version 2 of the License, or |
11 |
* (at your option) any later version. |
12 |
* |
13 |
* This program is distributed in the hope that it will be useful, |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
* GNU General Public License for more details. |
17 |
* |
18 |
* You should have received a copy of the GNU General Public License |
19 |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
#import <AppKit/AppKit.h> |
24 |
|
25 |
#import "sysdeps.h" // Types used in Basilisk C++ code |
26 |
|
27 |
#import <prefs.h> |
28 |
|
29 |
#define DEBUG 0 |
30 |
#import <debug.h> |
31 |
|
32 |
|
33 |
|
34 |
/************************************************************************/ |
35 |
/* Display Errors and Warnings in a sliding thingy attached to a */ |
36 |
/* particular window, instead of as a separate window (Panel or Dialog) */ |
37 |
/************************************************************************/ |
38 |
|
39 |
void ErrorSheet (NSString * message, NSWindow * window) |
40 |
{ |
41 |
NSLog(message); |
42 |
NSBeginCriticalAlertSheet(message, nil, nil, nil, window, |
43 |
nil, nil, nil, NULL, @""); |
44 |
while ( [window attachedSheet] ) |
45 |
sleep(1); |
46 |
//[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 1.0]]; |
47 |
} |
48 |
|
49 |
void ErrorSheet (NSString * message1, NSString * message2, |
50 |
NSString * button, NSWindow * window) |
51 |
{ |
52 |
NSLog(message1); |
53 |
NSLog(message2); |
54 |
NSBeginCriticalAlertSheet(message1, button, nil, nil, window, |
55 |
nil, nil, nil, NULL, message2); |
56 |
while ( [window attachedSheet] ) |
57 |
sleep(1); |
58 |
//[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow: 1.0]]; |
59 |
} |
60 |
|
61 |
|
62 |
void WarningSheet (NSString * message, NSWindow * window) |
63 |
{ |
64 |
NSLog(message); |
65 |
NSBeginAlertSheet(message, nil, nil, nil, window, |
66 |
nil, nil, nil, NULL, @""); |
67 |
} |
68 |
|
69 |
void WarningSheet (NSString * message1, NSString * message2, |
70 |
NSString * button, NSWindow * window) |
71 |
{ |
72 |
NSLog(message1); |
73 |
NSLog(message2); |
74 |
NSBeginAlertSheet(message1, button, nil, nil, window, |
75 |
nil, nil, nil, NULL, message2); |
76 |
} |
77 |
|
78 |
|
79 |
void InfoSheet (NSString * message, NSWindow * window) |
80 |
{ |
81 |
NSLog(message); |
82 |
NSBeginInformationalAlertSheet(message, nil, nil, nil, window, |
83 |
nil, nil, nil, NULL, @""); |
84 |
} |
85 |
|
86 |
void InfoSheet (NSString * message1, NSString * message2, |
87 |
NSString * button, NSWindow * window) |
88 |
{ |
89 |
NSLog(message1); |
90 |
NSLog(message2); |
91 |
NSBeginInformationalAlertSheet(message1, nil, nil, nil, window, |
92 |
nil, nil, nil, NULL, message2); |
93 |
} |
94 |
|
95 |
void EndSheet (NSWindow * window) |
96 |
{ |
97 |
[[window attachedSheet] close]; |
98 |
} |
99 |
|
100 |
// Convert a frequency (i.e. updates per second) to a 60hz tick delay, and update prefs |
101 |
int frequencyToTickDelay (float freq) |
102 |
{ |
103 |
if ( freq == 0.0 ) |
104 |
return 0; |
105 |
else |
106 |
{ |
107 |
int delay = (int) (60.0 / freq); |
108 |
|
109 |
PrefsReplaceInt32("frameskip", delay); |
110 |
return delay; |
111 |
} |
112 |
} |