3 |
|
* |
4 |
|
* $Id$ |
5 |
|
* |
6 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
6 |
> |
* Basilisk II (C) 1997-2008 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 |
23 |
|
#import "Controller.h" |
24 |
|
#import "Emulator.h" |
25 |
|
|
26 |
– |
@implementation Controller |
27 |
– |
|
26 |
|
#import "sysdeps.h" // Types used in Basilisk C++ code |
27 |
|
|
28 |
|
#import <main.h> |
34 |
|
#import "misc_macosx.h" |
35 |
|
#import "video_macosx.h" |
36 |
|
|
37 |
+ |
@implementation Controller |
38 |
+ |
|
39 |
|
// |
40 |
|
// Standard NSApplication methods that we override |
41 |
|
// |
67 |
|
|
68 |
|
- (void) sendEvent: (NSEvent *)event; |
69 |
|
{ |
70 |
< |
if ( [self isAnyEmulatorDisplayingSheets] || ! [self isAnyEmulatorRunning] ) |
71 |
< |
[super sendEvent: event]; |
70 |
> |
// We can either process the event ourselves, |
71 |
> |
// or pass it to our superclass for the other UI objects to process |
72 |
> |
bool passToSuper = false; |
73 |
> |
|
74 |
> |
if ( [self isAnyEmulatorDisplayingSheets] || |
75 |
> |
[[thePrefsEditor window] isVisible] || ! [self isAnyEmulatorRunning] ) |
76 |
> |
passToSuper = true; |
77 |
> |
|
78 |
> |
if ( [[theEmulator screen] isFullScreen] ) |
79 |
> |
passToSuper = false; |
80 |
> |
|
81 |
> |
if ( passToSuper ) |
82 |
> |
[super sendEvent: event]; // NSApplication default |
83 |
|
else |
84 |
|
{ |
85 |
|
NSEventType type = [event type]; |
118 |
|
// |
119 |
|
// switch ( NSRunAlertPanel(title, msg, def, alt, other, nil) ) |
120 |
|
// { |
121 |
< |
// case NSAlertDefault: savePrefs(); |
122 |
< |
// case NSAlertAlternate: return NSTerminateNow; |
123 |
< |
// case NSAlertOther: return NSTerminateCancel; |
121 |
> |
// case NSAlertDefault: savePrefs(); |
122 |
> |
// case NSAlertAlternate: return NSTerminateNow; |
123 |
> |
// case NSAlertOther: return NSTerminateCancel; |
124 |
|
// } |
125 |
|
// } |
126 |
|
|
204 |
|
type: (NSEventType)type |
205 |
|
{ |
206 |
|
EmulatorView *view; |
207 |
+ |
BOOL fullScreen; |
208 |
|
|
209 |
|
#ifdef ENABLE_MULTIPLE |
210 |
|
// We need to work out what window's Emulator should receive these messages |
216 |
|
{ |
217 |
|
theEmulator = [emulators objectAtIndex: tmp]; |
218 |
|
view = [theEmulator screen]; |
219 |
+ |
fullScreen = [view isFullScreen]; |
220 |
|
|
221 |
|
if ( [theEmulator isRunning] && |
222 |
< |
( [[theEmulator window] isMainWindow] || [view isFullScreen] ) ) |
222 |
> |
( fullScreen || [[theEmulator window] isMainWindow] ) ) |
223 |
|
break; |
224 |
|
} |
225 |
|
|
226 |
|
if ( tmp < [emulators count] ) // i.e. if we exited the for loop |
227 |
|
#else |
228 |
|
view = [theEmulator screen]; |
229 |
+ |
fullScreen = [view isFullScreen]; |
230 |
|
|
231 |
|
if ( [theEmulator isRunning] && |
232 |
< |
( [[theEmulator window] isMainWindow] || [view isFullScreen] ) ) |
232 |
> |
( fullScreen || [[theEmulator window] isMainWindow] ) ) |
233 |
|
#endif |
234 |
|
{ |
235 |
< |
if ( [view mouseInView: event] ) |
235 |
> |
if ( fullScreen || [view mouseInView: event] ) |
236 |
|
{ |
237 |
|
switch ( type ) |
238 |
|
{ |
244 |
|
break; |
245 |
|
case NSLeftMouseDragged: |
246 |
|
case NSMouseMoved: |
247 |
< |
[view processMouseMove: event]; |
247 |
> |
if ( fullScreen ) |
248 |
> |
[view fullscreenMouseMove]; |
249 |
> |
else |
250 |
> |
[view processMouseMove: event]; |
251 |
|
break; |
252 |
|
default: |
253 |
|
[super sendEvent: event]; // NSApplication default |
269 |
|
|
270 |
|
// Methods to display documentation: |
271 |
|
|
272 |
+ |
- (IBAction) HelpHowTo: (id)sender |
273 |
+ |
{ |
274 |
+ |
NSString *path = [[NSBundle mainBundle] pathForResource: @"HowTo" |
275 |
+ |
ofType: @"html"]; |
276 |
+ |
|
277 |
+ |
if ( ! path ) |
278 |
+ |
InfoSheet(@"Cannot find HowTo.html", [theEmulator window]); |
279 |
+ |
else |
280 |
+ |
if ( ! [[NSWorkspace sharedWorkspace] openFile: path] ) |
281 |
+ |
InfoSheet(@"Cannot open HowTo.html with default app", [theEmulator window]); |
282 |
+ |
} |
283 |
+ |
|
284 |
|
- (IBAction) HelpToDo: (id)sender |
285 |
|
{ |
286 |
< |
NSString *path = [[NSBundle mainBundle] pathForResource: @"ToDo" |
287 |
< |
ofType: @"html"]; |
286 |
> |
NSString *path = [[NSBundle mainBundle] pathForResource: @"ToDo" |
287 |
> |
ofType: @"html"]; |
288 |
|
|
289 |
< |
if ( ! path ) |
290 |
< |
InfoSheet(@"Cannot find ToDo.html", [theEmulator window]); |
291 |
< |
else |
292 |
< |
if ( ! [[NSWorkspace sharedWorkspace] openFile: path |
293 |
< |
withApplication: @"TextEdit"] ) |
294 |
< |
InfoSheet(@"Cannot open ToDo.html with TextEdit", [theEmulator window]); |
289 |
> |
if ( ! path ) |
290 |
> |
InfoSheet(@"Cannot find ToDo.html", [theEmulator window]); |
291 |
> |
else |
292 |
> |
if ( ! [[NSWorkspace sharedWorkspace] openFile: path |
293 |
> |
withApplication: @"TextEdit"] ) |
294 |
> |
InfoSheet(@"Cannot open ToDo.html with TextEdit", [theEmulator window]); |
295 |
|
} |
296 |
|
|
297 |
|
- (IBAction) HelpVersions: (id)sender |
298 |
|
{ |
299 |
< |
NSString *path = [[NSBundle mainBundle] pathForResource: @"Versions" |
300 |
< |
ofType: @"html"]; |
299 |
> |
NSString *path = [[NSBundle mainBundle] pathForResource: @"Versions" |
300 |
> |
ofType: @"html"]; |
301 |
|
|
302 |
< |
if ( ! path ) |
303 |
< |
InfoSheet(@"Cannot find Versions.html", [theEmulator window]); |
304 |
< |
else |
305 |
< |
if ( ! [[NSWorkspace sharedWorkspace] openFile: path |
306 |
< |
withApplication: @"TextEdit"] ) |
307 |
< |
InfoSheet(@"Cannot open Versions.html with TextEdit", [theEmulator window]); |
302 |
> |
if ( ! path ) |
303 |
> |
InfoSheet(@"Cannot find Versions.html", [theEmulator window]); |
304 |
> |
else |
305 |
> |
if ( ! [[NSWorkspace sharedWorkspace] openFile: path |
306 |
> |
withApplication: @"TextEdit"] ) |
307 |
> |
InfoSheet(@"Cannot open Versions.html with TextEdit", |
308 |
> |
[theEmulator window]); |
309 |
|
} |
310 |
|
|
311 |
|
|
407 |
|
return count; |
408 |
|
} |
409 |
|
|
410 |
< |
@end |
410 |
> |
@end |