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.11 by cebix, 2004-01-12T15:29:24Z

# Line 3 | Line 3
3   *
4   *      $Id$
5   *
6 < *  Basilisk II (C) 1997-2001 Christian Bauer
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
# 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 <
72 <        if ( type == NSKeyUp || type == NSKeyDown || type == NSFlagsChanged )
72 <                [self dispatchKeyEvent: event
73 <                                                  type: type];
70 >        if ( [self isAnyEmulatorDisplayingSheets] ||
71 >                        [[thePrefsEditor window] isVisible] || ! [self isAnyEmulatorRunning] )
72 >                [super sendEvent: event];
73          else
74 <                [self dispatchEvent:    event
75 <                                           type:        type];
74 >        {
75 >                NSEventType     type = [event type];
76 >
77 >                if ( type == NSKeyUp || type == NSKeyDown || type == NSFlagsChanged )
78 >                        [self dispatchKeyEvent: event
79 >                                                          type: type];
80 >                else
81 >                        [self dispatchEvent: event
82 >                                                   type: type];
83 >        }
84   }
85  
86   // NSApplication methods which are invoked through delegation
# Line 101 | Line 108
108   //
109   //              switch ( NSRunAlertPanel(title, msg, def, alt, other, nil) )
110   //              {
111 < //                      case NSAlertDefault:   savePrefs();
112 < //                      case NSAlertAlternate: return NSTerminateNow;
113 < //                      case NSAlertOther:     return NSTerminateCancel;
111 > //                      case NSAlertDefault:    savePrefs();
112 > //                      case NSAlertAlternate:  return NSTerminateNow;
113 > //                      case NSAlertOther:              return NSTerminateCancel;
114   //              }
115   //      }
116  
# Line 144 | Line 151
151          for ( tmp = 0; tmp < [emulators count], ++tmp )
152          {
153                  theEmulator = [emulators objectAtIndex: tmp];
154 <                if ( [ theEmulator isRunning ] && [[theEmulator window] isKeyWindow ] )
154 >                view = [theEmulator screen];
155 >
156 >                if ( [ theEmulator isRunning ] &&
157 >                                ( [[theEmulator window] isKeyWindow] || [view isFullScreen] ) )
158                          break;
159          }
160          
161          if ( tmp < [emulators count] )          // i.e. if we exited the for loop
162   #else
163 <        if ( [theEmulator isRunning] && [[theEmulator window] isKeyWindow ] )
163 >        view = [theEmulator screen];
164 >
165 >        if ( [theEmulator isRunning] &&
166 >                                ( [[theEmulator window] isKeyWindow] || [view isFullScreen] ) )
167   #endif
168          {
169 <                view = [theEmulator screen];
157 <
169 >                D(NSLog(@"Got a key event - %d\n", [event keyCode]));
170                  switch ( type )
171                  {
172                          case NSKeyUp:
# Line 181 | Line 193
193   - (void) dispatchEvent: (NSEvent *)event
194                                    type: (NSEventType)type                              
195   {
196 +        EmulatorView    *view;
197 +        BOOL                    fullScreen;
198 +
199   #ifdef ENABLE_MULTIPLE
200          // We need to work out what window's Emulator should receive these messages
201  
# Line 190 | Line 205
205          for ( tmp = 0; tmp < [emulators count], ++tmp )
206          {
207                  theEmulator = [emulators objectAtIndex: tmp];
208 <                if ( [ theEmulator isRunning ] &&  [[theEmulator window] isMainWindow ] )
208 >                view = [theEmulator screen];
209 >                fullScreen = [view isFullScreen];
210 >
211 >                if ( [theEmulator isRunning] &&
212 >                                ( fullScreen || [[theEmulator window] isMainWindow] ) )
213                          break;
214          }
215          
216          if ( tmp < [emulators count] )          // i.e. if we exited the for loop
217   #else
218 <        if ( FULLSCREEN ||
219 <                ( [theEmulator isRunning] && [[theEmulator window] isMainWindow ] ) )
218 >        view = [theEmulator screen];
219 >        fullScreen = [view isFullScreen];
220 >
221 >        if ( [theEmulator isRunning] &&
222 >                                ( fullScreen || [[theEmulator window] isMainWindow] ) )
223   #endif
224          {
225 <                EmulatorView    *view = [theEmulator screen];
204 <
205 < //              if ( [view mouseInView] )
206 <                if ( [view mouseInView: event] || FULLSCREEN )
225 >                if ( fullScreen || [view mouseInView: event] )
226                  {
227                          switch ( type )
228                          {
# Line 215 | Line 234
234                                          break;
235                                  case NSLeftMouseDragged:
236                                  case NSMouseMoved:
237 <                                        [view processMouseMove: event];
237 >                                        if ( fullScreen )
238 >                                                [view fullscreenMouseMove];
239 >                                        else
240 >                                                [view processMouseMove: event];
241                                          break;
242                                  default:
243                                          [super sendEvent: event];               // NSApplication default
# Line 234 | Line 256
256                  [super sendEvent: event];
257   }
258  
259 +
260 + // Methods to display documentation:
261 +
262 + - (IBAction) HelpHowTo: (id)sender
263 + {
264 +        NSString        *path = [[NSBundle mainBundle] pathForResource: @"HowTo"
265 +                                                                                                                ofType: @"html"];
266 +
267 +        if ( ! path )
268 +                InfoSheet(@"Cannot find HowTo.html", [theEmulator window]);
269 +        else
270 +                if ( ! [[NSWorkspace sharedWorkspace] openFile: path] )
271 +                        InfoSheet(@"Cannot open HowTo.html with default app", [theEmulator window]);
272 + }
273 +
274 + - (IBAction) HelpToDo: (id)sender
275 + {
276 +        NSString        *path = [[NSBundle mainBundle] pathForResource: @"ToDo"
277 +                                                                                                                ofType: @"html"];
278 +
279 +        if ( ! path )
280 +                InfoSheet(@"Cannot find ToDo.html", [theEmulator window]);
281 +        else
282 +                if ( ! [[NSWorkspace sharedWorkspace] openFile: path
283 +                                                                           withApplication: @"TextEdit"] )
284 +                        InfoSheet(@"Cannot open ToDo.html with TextEdit", [theEmulator window]);
285 + }
286 +
287 + - (IBAction) HelpVersions: (id)sender
288 + {
289 +        NSString        *path = [[NSBundle mainBundle] pathForResource: @"Versions"
290 +                                                                                                                ofType: @"html"];
291 +
292 +        if ( ! path )
293 +                InfoSheet(@"Cannot find Versions.html", [theEmulator window]);
294 +        else
295 +                if ( ! [[NSWorkspace sharedWorkspace] openFile: path
296 +                                                                           withApplication: @"TextEdit"] )
297 +                        InfoSheet(@"Cannot open Versions.html with TextEdit",
298 +                                                                                                [theEmulator window]);
299 + }
300 +
301 +
302 + // Menu items which for managing more than one window
303 +
304   #ifdef ENABLE_MULTIPLE
305  
306   - (IBAction) NewEmulator: (id)sender
# Line 277 | Line 344
344  
345   #endif
346  
347 + - (BOOL) isAnyEmulatorDisplayingSheets
348 + {
349 + #ifdef ENABLE_MULTIPLE
350 +        int     tmp;
351 +
352 +        for ( tmp = 0; tmp < [emulators count], ++tmp )
353 +                if ( [[[emulators objectAtIndex: tmp] window] attachedSheet] )
354 +                        break;
355 +        
356 +        if ( tmp < [emulators count] )          // i.e. if we exited the for loop
357 + #else
358 +        if ( [[theEmulator window] attachedSheet] )
359 + #endif
360 +                return TRUE;
361 +
362 +        return FALSE;
363 + }
364 +
365   - (BOOL) isAnyEmulatorRunning
366   {
367   #ifdef ENABLE_MULTIPLE
# Line 312 | Line 397
397          return count;
398   }
399  
400 < @end
400 > @end

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines