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.7 by nigel, 2003-03-11T11:31:01Z

# 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 +        BOOL                    fullScreen;
197 +
198   #ifdef ENABLE_MULTIPLE
199          // We need to work out what window's Emulator should receive these messages
200  
# Line 190 | Line 204
204          for ( tmp = 0; tmp < [emulators count], ++tmp )
205          {
206                  theEmulator = [emulators objectAtIndex: tmp];
207 <                if ( [ theEmulator isRunning ] &&  [[theEmulator window] isMainWindow ] )
207 >                view = [theEmulator screen];
208 >                fullScreen = [view isFullScreen];
209 >
210 >                if ( [theEmulator isRunning] &&
211 >                                ( fullScreen || [[theEmulator window] isMainWindow] ) )
212                          break;
213          }
214          
215          if ( tmp < [emulators count] )          // i.e. if we exited the for loop
216   #else
217 <        if ( FULLSCREEN ||
218 <                ( [theEmulator isRunning] && [[theEmulator window] isMainWindow ] ) )
217 >        view = [theEmulator screen];
218 >        fullScreen = [view isFullScreen];
219 >
220 >        if ( [theEmulator isRunning] &&
221 >                                ( fullScreen || [[theEmulator window] isMainWindow] ) )
222   #endif
223          {
224 <                EmulatorView    *view = [theEmulator screen];
204 <
205 < //              if ( [view mouseInView] )
206 <                if ( [view mouseInView: event] || FULLSCREEN )
224 >                if ( fullScreen || [view mouseInView: event] )
225                  {
226                          switch ( type )
227                          {
# Line 215 | Line 233
233                                          break;
234                                  case NSLeftMouseDragged:
235                                  case NSMouseMoved:
236 <                                        [view processMouseMove: event];
236 >                                        if ( fullScreen )
237 >                                                [view fullscreenMouseMove];
238 >                                        else
239 >                                                [view processMouseMove: event];
240                                          break;
241                                  default:
242                                          [super sendEvent: event];               // NSApplication default
# Line 234 | Line 255
255                  [super sendEvent: event];
256   }
257  
258 +
259 + // Methods to display documentation:
260 +
261 + - (IBAction) HelpToDo: (id)sender
262 + {
263 +    NSString    *path = [[NSBundle mainBundle] pathForResource: @"ToDo"
264 +                                                        ofType: @"html"];
265 +
266 +    if ( ! path )
267 +        InfoSheet(@"Cannot find ToDo.html", [theEmulator window]);
268 +    else
269 +        if ( ! [[NSWorkspace sharedWorkspace] openFile: path
270 +                                       withApplication: @"TextEdit"] )
271 +            InfoSheet(@"Cannot open ToDo.html with TextEdit", [theEmulator window]);
272 + }
273 +
274 + - (IBAction) HelpVersions: (id)sender
275 + {
276 +    NSString    *path = [[NSBundle mainBundle] pathForResource: @"Versions"
277 +                                                        ofType: @"html"];
278 +
279 +    if ( ! path )
280 +        InfoSheet(@"Cannot find Versions.html", [theEmulator window]);
281 +    else
282 +        if ( ! [[NSWorkspace sharedWorkspace] openFile: path
283 +                                       withApplication: @"TextEdit"] )
284 +            InfoSheet(@"Cannot open Versions.html with TextEdit", [theEmulator window]);
285 + }
286 +
287 +
288 + // Menu items which for managing more than one window
289 +
290   #ifdef ENABLE_MULTIPLE
291  
292   - (IBAction) NewEmulator: (id)sender
# Line 277 | Line 330
330  
331   #endif
332  
333 + - (BOOL) isAnyEmulatorDisplayingSheets
334 + {
335 + #ifdef ENABLE_MULTIPLE
336 +        int     tmp;
337 +
338 +        for ( tmp = 0; tmp < [emulators count], ++tmp )
339 +                if ( [[[emulators objectAtIndex: tmp] window] attachedSheet] )
340 +                        break;
341 +        
342 +        if ( tmp < [emulators count] )          // i.e. if we exited the for loop
343 + #else
344 +        if ( [[theEmulator window] attachedSheet] )
345 + #endif
346 +                return TRUE;
347 +
348 +        return FALSE;
349 + }
350 +
351   - (BOOL) isAnyEmulatorRunning
352   {
353   #ifdef ENABLE_MULTIPLE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines