1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
/* $Id: main.m 12052 2002-01-08 18:23:01Z nico $ */
#import <AppKit/AppKit.h>
#import "AppController.h"
#define APP_NAME @"HostAddress"
/*
* Create the application's menu
*/
void createMenu();
/*
* Initialise and go!
*/
int main(int argc, const char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AppController *controller;
[NSApplication sharedApplication];
createMenu();
controller = [[AppController alloc] init];
[NSApp setDelegate:controller];
RELEASE(pool);
return NSApplicationMain (argc, argv);
}
void createMenu()
{
NSMenu *menu;
NSMenu *info;
NSMenu *edit;
NSMenu *services;
NSMenu *windows;
SEL action = @selector(method:);
menu = [[NSMenu alloc] initWithTitle:APP_NAME];
[menu addItemWithTitle:@"Info" action:action keyEquivalent:@""];
[menu addItemWithTitle:@"Edit" action:action keyEquivalent:@""];
[menu addItemWithTitle:@"Resolver..." action:@selector(showResolverWindow:) keyEquivalent:@""];
[menu addItemWithTitle:@"Windows" action:action keyEquivalent:@""];
[menu addItemWithTitle:@"Services" action:action keyEquivalent:@""];
[menu addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"];
[menu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
info = AUTORELEASE([[NSMenu alloc] init]);
[menu setSubmenu:info forItem:[menu itemWithTitle:@"Info"]];
[info addItemWithTitle:@"Info Panel..." action:@selector(showInfoPanel:) keyEquivalent:@""];
[info addItemWithTitle:@"Preferences" action:@selector(showPrefPanel:) keyEquivalent:@""];
[info addItemWithTitle:@"Help" action:action keyEquivalent:@"?"];
edit = AUTORELEASE([[NSMenu alloc] init]);
[edit addItemWithTitle:@"Cut"
action:@selector(cut:)
keyEquivalent:@"x"];
[edit addItemWithTitle:@"Copy"
action:@selector(copy:)
keyEquivalent:@"c"];
[edit addItemWithTitle:@"Paste"
action:@selector(paste:)
keyEquivalent:@"v"];
[edit addItemWithTitle:@"Delete"
action:@selector(delete:)
keyEquivalent:@""];
[edit addItemWithTitle:@"Select All"
action:@selector(selectAll:)
keyEquivalent:@"a"];
[menu setSubmenu:edit forItem:[menu itemWithTitle:@"Edit"]];
windows = AUTORELEASE([[NSMenu alloc] init]);
[windows addItemWithTitle:@"Arrange"
action:@selector(arrangeInFront:)
keyEquivalent:@""];
[windows addItemWithTitle:@"Miniaturize"
action:@selector(performMiniaturize:)
keyEquivalent:@"m"];
[windows addItemWithTitle:@"Close"
action:@selector(performClose:)
keyEquivalent:@"w"];
[menu setSubmenu:windows forItem:[menu itemWithTitle:@"Windows"]];
services = AUTORELEASE([[NSMenu alloc] init]);
[menu setSubmenu:services forItem:[menu itemWithTitle:@"Services"]];
[[NSApplication sharedApplication] setMainMenu:menu];
[[NSApplication sharedApplication] setServicesMenu: services];
[[NSApplication sharedApplication] setWindowsMenu: windows];
}
|