~ubuntu-branches/ubuntu/feisty/pygame/feisty

« back to all changes in this revision

Viewing changes to src/SDLmain.m

  • Committer: Bazaar Package Importer
  • Author(s): Ed Boraas
  • Date: 2004-08-08 00:10:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040808001010-nts9g4z69jf1ryb1
Tags: 1.6-2
* Actually build-depend on python (for dh_python)
  * Closes: #264086

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
       Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
3
 
       Non-NIB-Code & other changes: Max Horn <max@quendi.de>
4
 
       Hacked for pygame: Bob Ippolito <bob@redivi.com>
5
 
 
6
 
       Feel free to customize this file to suit your needs
7
 
*/
8
 
 
9
 
#import "SDL.h"
10
 
#import <sys/param.h>
11
 
#import <unistd.h>
12
 
#import <Cocoa/Cocoa.h>
13
 
#import <Carbon/Carbon.h>
14
 
#import "CPS.h"
15
 
 
16
 
@interface SDLMain : NSObject
17
 
@end
18
 
 
19
 
/* Create a window menu */
20
 
void setupWindowMenu(void)
21
 
{
22
 
    NSMenu      *windowMenu;
23
 
    NSMenuItem  *windowMenuItem;
24
 
    NSMenuItem  *menuItem;
25
 
 
26
 
 
27
 
    windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
28
 
    
29
 
    /* "Minimize" item */
30
 
    menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
31
 
    [windowMenu addItem:menuItem];
32
 
    [menuItem release];
33
 
    
34
 
    /* Put menu into the menubar */
35
 
    windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
36
 
    [windowMenuItem setSubmenu:windowMenu];
37
 
    [[NSApp mainMenu] addItem:windowMenuItem];
38
 
    
39
 
    /* Tell the application object that this is now the window menu */
40
 
    [NSApp setWindowsMenu:windowMenu];
41
 
 
42
 
    /* Finally give up our references to the objects */
43
 
    [windowMenu release];
44
 
    [windowMenuItem release];
45
 
}
46
 
 
47
 
/* The main class of the application, the application's delegate */
48
 
@implementation SDLMain
49
 
- (void)quit:(id)sender
50
 
{
51
 
    /* Post a SDL_QUIT event */
52
 
    SDL_Event event;
53
 
    event.type = SDL_QUIT;
54
 
    SDL_PushEvent(&event);
55
 
}
56
 
 
57
 
- (void)terminate:(id)sender
58
 
{
59
 
    /* Post a SDL_QUIT event */
60
 
    SDL_Event event;
61
 
    event.type = SDL_QUIT;
62
 
    SDL_PushEvent(&event);
63
 
}
64
 
 
65
 
 
66
 
NSAutoreleasePool *global_pool;
67
 
SDLMain *sdlMain;
68
 
 
69
 
void StartTheDamnApplication (void)
70
 
{
71
 
    CPSProcessSerNum PSN;
72
 
    //OSErr err;
73
 
    NSImage *pygameIcon;
74
 
    global_pool = [[NSAutoreleasePool alloc] init];
75
 
    [NSApplication sharedApplication];
76
 
    if (!CPSGetCurrentProcess(&PSN))
77
 
        if (!CPSSetProcessName(&PSN,"pygame"))
78
 
            if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
79
 
                if (!CPSSetFrontProcess(&PSN))
80
 
                    [NSApplication sharedApplication];
81
 
    [NSApp setMainMenu:[[NSMenu alloc] init]];
82
 
    setupWindowMenu();
83
 
    sdlMain = [[SDLMain alloc] init];
84
 
    [NSApp setDelegate:sdlMain];
85
 
    [NSApp finishLaunching];
86
 
    [NSApp requestUserAttention:NSCriticalRequest];
87
 
    [NSApp updateWindows];
88
 
    pygameIcon = [[NSImage alloc] initWithContentsOfFile: @"/Library/Frameworks/Python.framework/Versions/Current/lib/python2.2/site-packages/pygame/pygame_icon.tiff"];
89
 
    [NSApp setApplicationIconImage:pygameIcon];
90
 
 
91
 
}
92
 
 
93
 
void WeAreDoneFreeSomeMemory(void)
94
 
{
95
 
    [sdlMain release];
96
 
    [global_pool release];
97
 
}
98
 
 
99
 
@end
 
 
b'\\ No newline at end of file'