|
|
1.1 root 1: /*
1.1.1.6 ! root 2: Hatari - Shared.m
1.1 root 3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6:
7: Helper code used by the other Cocoa code files
8:
9: June 2006, Sébastien Molines - Created
10: */
11:
12: #import <Cocoa/Cocoa.h>
13: #import "Shared.h"
14: #import "AlertHooks.h"
15: #include "main.h"
16:
17: @implementation ModalWrapper
18:
19: // Runs an NSWindow modally
20: - (void)runModal:(NSWindow*)window
21: {
22: // Grab the window
23: modalWindow = window;
24:
25: // Set the window's delegate
26: [window setDelegate:self];
27:
28: // Change emulation and UI state
1.1.1.3 root 29: GuiOsx_Pause();
1.1 root 30:
31: // Run it as modal
32: [NSApp runModalForWindow:window];
33:
34: // Restore emulation and UI state
1.1.1.3 root 35: GuiOsx_Resume();
1.1 root 36: }
37:
38: // On closure of the NSWindow, end the modal session
39: - (void) windowWillClose:(NSNotification *)notification
40: {
41: NSWindow *windowAboutToClose = [notification object];
42:
43: // Is this our modal window?
44: if (windowAboutToClose == modalWindow)
45: {
46: // Stop the modal loop
47: [NSApp stopModal];
48: }
49: }
50:
51: @end
52:
53: /*-----------------------------------------------------------------------*/
54: /*
55: Helper function to write the contents of a path as an NSString to a string
56: */
57: void GuiOsx_ExportPathString(NSString* path, char* szTarget, size_t cchTarget)
58: {
59: NSCAssert((szTarget), @"Target buffer must not be null.");
60: NSCAssert((cchTarget > 0), @"Target buffer size must be greater than zero.");
61:
62: // Copy the string
1.1.1.5 root 63: strncpy(szTarget, [[path stringByExpandingTildeInPath] cStringUsingEncoding:[NSString defaultCStringEncoding]], cchTarget);
1.1 root 64:
65: // Make sure it is null terminated (as strncpy does not null-terminate if the buffer is too small)
66: szTarget[cchTarget - 1] = 0;
67: }
68:
69: /*-----------------------------------------------------------------------*/
70: /*
1.1.1.3 root 71: Pauses emulation
1.1 root 72: */
1.1.1.4 root 73: void GuiOsx_Pause(void)
1.1 root 74: {
75: // Pause emulation
1.1.1.3 root 76: Main_PauseEmulation(false);
1.1 root 77: }
78:
79: /*-----------------------------------------------------------------------*/
80: /*
1.1.1.3 root 81: Switches back to emulation mode
1.1 root 82: */
1.1.1.4 root 83: void GuiOsx_Resume(void)
1.1 root 84: {
85: // Resume emulation
86: Main_UnPauseEmulation();
87: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.