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

Comparing BasiliskII/src/MacOSX/Controller.mm (file contents):
Revision 1.2 by nigel, 2002-03-16T10:00:18Z vs.
Revision 1.6 by nigel, 2003-01-10T23:01:48Z

# Line 33 | Line 33
33   #define DEBUG 0
34   #import <debug.h>
35  
36 + #import "misc_macosx.h"
37   #import "video_macosx.h"
38  
39   //
# Line 42 | Line 43
43   - (id) init
44   {
45   #ifdef ENABLE_MULTIPLE
46 <        emulators  = [[NSMutableArray alloc] init];
46 >        emulators  = [NSMutableArray new];
47   #endif
48          return [super init];
49   }
# Line 66 | Line 67
67  
68   - (void) sendEvent: (NSEvent *)event;
69   {
70 <        NSEventType     type = [event type];
71 <
71 <        if ( type == NSKeyUp || type == NSKeyDown || type == NSFlagsChanged )
72 <                [self dispatchKeyEvent: event
73 <                                                  type: type];
70 >        if ( [self isAnyEmulatorDisplayingSheets] || ! [self isAnyEmulatorRunning] )
71 >                [super sendEvent: event];
72          else
73 <                [self dispatchEvent:    event
74 <                                           type:        type];
73 >        {
74 >                NSEventType     type = [event type];
75 >
76 >                if ( type == NSKeyUp || type == NSKeyDown || type == NSFlagsChanged )
77 >                        [self dispatchKeyEvent: event
78 >                                                          type: type];
79 >                else
80 >                        [self dispatchEvent: event
81 >                                                   type: type];
82 >        }
83   }
84  
85   // NSApplication methods which are invoked through delegation
# Line 144 | Line 150
150          for ( tmp = 0; tmp < [emulators count], ++tmp )
151          {
152                  theEmulator = [emulators objectAtIndex: tmp];
153 <                if ( [ theEmulator isRunning ] && [[theEmulator window] isKeyWindow ] )
153 >                view = [theEmulator screen];
154 >
155 >                if ( [ theEmulator isRunning ] &&
156 >                                ( [[theEmulator window] isKeyWindow] || [view isFullScreen] ) )
157                          break;
158          }
159          
160          if ( tmp < [emulators count] )          // i.e. if we exited the for loop
161   #else
162 <        if ( [theEmulator isRunning] && [[theEmulator window] isKeyWindow ] )
162 >        view = [theEmulator screen];
163 >
164 >        if ( [theEmulator isRunning] &&
165 >                                ( [[theEmulator window] isKeyWindow] || [view isFullScreen] ) )
166   #endif
167          {
168 <                view = [theEmulator screen];
157 <
168 >                D(NSLog(@"Got a key event - %d\n", [event keyCode]));
169                  switch ( type )
170                  {
171                          case NSKeyUp:
# Line 181 | Line 192
192   - (void) dispatchEvent: (NSEvent *)event
193                                    type: (NSEventType)type                              
194   {
195 +        EmulatorView    *view;
196 +
197   #ifdef ENABLE_MULTIPLE
198          // We need to work out what window's Emulator should receive these messages
199  
# Line 190 | Line 203
203          for ( tmp = 0; tmp < [emulators count], ++tmp )
204          {
205                  theEmulator = [emulators objectAtIndex: tmp];
206 <                if ( [ theEmulator isRunning ] &&  [[theEmulator window] isMainWindow ] )
206 >                view = [theEmulator screen];
207 >
208 >                if ( [theEmulator isRunning] &&
209 >                                ( [[theEmulator window] isMainWindow] || [view isFullScreen] ) )
210                          break;
211          }
212          
213          if ( tmp < [emulators count] )          // i.e. if we exited the for loop
214   #else
215 <        if ( FULLSCREEN ||
216 <                ( [theEmulator isRunning] && [[theEmulator window] isMainWindow ] ) )
215 >        view = [theEmulator screen];
216 >
217 >        if ( [theEmulator isRunning] &&
218 >                                ( [[theEmulator window] isMainWindow] || [view isFullScreen] ) )
219   #endif
220          {
221 <                EmulatorView    *view = [theEmulator screen];
204 <
205 < //              if ( [view mouseInView] )
206 <                if ( [view mouseInView: event] || FULLSCREEN )
221 >                if ( [view mouseInView: event] )
222                  {
223                          switch ( type )
224                          {
# Line 234 | Line 249
249                  [super sendEvent: event];
250   }
251  
252 +
253 + // Methods to display documentation:
254 +
255 + - (IBAction) HelpToDo: (id)sender
256 + {
257 +    NSString    *path = [[NSBundle mainBundle] pathForResource: @"ToDo"
258 +                                                        ofType: @"html"];
259 +
260 +    if ( ! path )
261 +        InfoSheet(@"Cannot find ToDo.html", [theEmulator window]);
262 +    else
263 +        if ( ! [[NSWorkspace sharedWorkspace] openFile: path
264 +                                       withApplication: @"TextEdit"] )
265 +            InfoSheet(@"Cannot open ToDo.html with TextEdit", [theEmulator window]);
266 + }
267 +
268 + - (IBAction) HelpVersions: (id)sender
269 + {
270 +    NSString    *path = [[NSBundle mainBundle] pathForResource: @"Versions"
271 +                                                        ofType: @"html"];
272 +
273 +    if ( ! path )
274 +        InfoSheet(@"Cannot find Versions.html", [theEmulator window]);
275 +    else
276 +        if ( ! [[NSWorkspace sharedWorkspace] openFile: path
277 +                                       withApplication: @"TextEdit"] )
278 +            InfoSheet(@"Cannot open Versions.html with TextEdit", [theEmulator window]);
279 + }
280 +
281 +
282 + // Menu items which for managing more than one window
283 +
284   #ifdef ENABLE_MULTIPLE
285  
286   - (IBAction) NewEmulator: (id)sender
# Line 277 | Line 324
324  
325   #endif
326  
327 + - (BOOL) isAnyEmulatorDisplayingSheets
328 + {
329 + #ifdef ENABLE_MULTIPLE
330 +        int     tmp;
331 +
332 +        for ( tmp = 0; tmp < [emulators count], ++tmp )
333 +                if ( [[[emulators objectAtIndex: tmp] window] attachedSheet] )
334 +                        break;
335 +        
336 +        if ( tmp < [emulators count] )          // i.e. if we exited the for loop
337 + #else
338 +        if ( [[theEmulator window] attachedSheet] )
339 + #endif
340 +                return TRUE;
341 +
342 +        return FALSE;
343 + }
344 +
345   - (BOOL) isAnyEmulatorRunning
346   {
347   #ifdef ENABLE_MULTIPLE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines