2001-11-05 19:58:25 +00:00
|
|
|
/*
|
|
|
|
Controller.m
|
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
Controller class for Forge
|
2001-11-05 19:58:25 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
|
2001-11-05 19:58:25 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
|
|
|
License along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
2001-11-05 19:58:25 +00:00
|
|
|
*/
|
|
|
|
|
2001-11-06 13:20:23 +00:00
|
|
|
#import <AppKit/NSApplication.h>
|
|
|
|
#import <AppKit/NSMenu.h>
|
2001-11-05 19:58:25 +00:00
|
|
|
#import "Controller.h"
|
2001-11-11 20:54:59 +00:00
|
|
|
#import "Preferences.h"
|
2001-11-05 19:58:25 +00:00
|
|
|
|
|
|
|
@implementation Controller
|
|
|
|
|
|
|
|
- (BOOL) application: (NSApplication *) app openFile: (NSString *) filename;
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) application: (NSApplication *) app openTempFile: (NSString *) filename;
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) applicationOpenUntitledFile: (NSApplication *) app;
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) app;
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) applicationShouldTerminate: (NSApplication *) app;
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app;
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Action methods
|
|
|
|
*/
|
|
|
|
- (void) createNew: (id) sender;
|
|
|
|
{
|
|
|
|
NSLog (@"This _would_ create a new file, but it doesn't.");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) createNewProject: (id) sender;
|
|
|
|
{
|
|
|
|
NSLog (@"This _would_ create a new project, but it doesn't.");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) infoPanel: (id) sender;
|
|
|
|
{
|
|
|
|
[NSApp orderFrontStandardAboutPanel: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) open: (id) sender;
|
|
|
|
{
|
|
|
|
NSLog (@"This _would_ open a file, but it doesn't.");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) openProject: (id) sender;
|
|
|
|
{
|
|
|
|
NSLog (@"This _would_ open a project, but it doesn't.");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) saveAll: (id) sender;
|
|
|
|
{
|
|
|
|
NSLog (@"This _would_ save, but it doesn't.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Notifications
|
|
|
|
*/
|
|
|
|
|
2001-11-06 13:20:23 +00:00
|
|
|
/*
|
|
|
|
applicationDidFinishLaunching:
|
|
|
|
|
|
|
|
Sent when the app has finished starting up
|
|
|
|
*/
|
2001-11-05 19:58:25 +00:00
|
|
|
- (void) applicationDidFinishLaunching: (NSNotification *) not;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-11-06 13:20:23 +00:00
|
|
|
/*
|
|
|
|
applicationWillFinishLaunching:
|
|
|
|
|
|
|
|
Sent when the app is just about to complete its startup
|
|
|
|
*/
|
2001-11-05 19:58:25 +00:00
|
|
|
- (void) applicationWillFinishLaunching: (NSNotification *) not;
|
|
|
|
{
|
|
|
|
NSMenu *menu = [[[NSMenu alloc] init] autorelease];
|
|
|
|
NSMenu *info;
|
|
|
|
NSMenu *project;
|
2001-11-06 13:20:23 +00:00
|
|
|
NSMenu *file;
|
2001-11-05 19:58:25 +00:00
|
|
|
NSMenu *edit;
|
|
|
|
NSMenu *bsp;
|
|
|
|
NSMenu *brush;
|
|
|
|
NSMenu *windows;
|
|
|
|
NSMenu *services;
|
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu addItemWithTitle: _(@"Info") action: NULL keyEquivalent: @""];
|
|
|
|
[menu addItemWithTitle: _(@"Project") action: NULL keyEquivalent: @""];
|
|
|
|
[menu addItemWithTitle: _(@"File") action: NULL keyEquivalent: @""];
|
|
|
|
[menu addItemWithTitle: _(@"Edit") action: NULL keyEquivalent: @""];
|
|
|
|
[menu addItemWithTitle: _(@"BSP") action: NULL keyEquivalent: @""];
|
|
|
|
[menu addItemWithTitle: _(@"Brush") action: NULL keyEquivalent: @""];
|
|
|
|
[menu addItemWithTitle: _(@"Windows") action: NULL keyEquivalent: @""];
|
|
|
|
[menu addItemWithTitle: _(@"Services") action: NULL keyEquivalent: @""];
|
2001-11-05 19:58:25 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu addItemWithTitle: _(@"Hide") action: @selector(hide:) keyEquivalent: @"h"];
|
|
|
|
[menu addItemWithTitle: _(@"Quit") action: @selector(terminate:) keyEquivalent: @"q"];
|
2001-11-05 19:58:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Info
|
|
|
|
*/
|
|
|
|
info = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: info forItem: [menu itemWithTitle: _(@"Info")]];
|
2001-11-05 19:58:25 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[info addItemWithTitle: _(@"Info Panel...")
|
2001-11-05 19:58:25 +00:00
|
|
|
action: @selector (orderFrontStandardAboutPanel:)
|
|
|
|
keyEquivalent: @""];
|
2001-11-11 20:54:59 +00:00
|
|
|
[info addItemWithTitle: _(@"Preferences...")
|
2001-11-05 19:58:25 +00:00
|
|
|
action: @selector (orderFrontPreferencesPanel:)
|
|
|
|
keyEquivalent: @""];
|
2001-11-11 20:54:59 +00:00
|
|
|
[info addItemWithTitle: _(@"Help")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (orderFrontHelpPanel:)
|
2001-11-05 19:58:25 +00:00
|
|
|
keyEquivalent: @"?"];
|
|
|
|
|
|
|
|
/*
|
|
|
|
Project
|
|
|
|
*/
|
|
|
|
project = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: project forItem: [menu itemWithTitle: _(@"Project")]];
|
2001-11-05 19:58:25 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[project addItemWithTitle: _(@"Open...")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (openProject:)
|
2001-11-11 20:54:59 +00:00
|
|
|
keyEquivalent: @"~o"];
|
|
|
|
[project addItemWithTitle: _(@"New")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (createNewProject:)
|
2001-11-11 20:54:59 +00:00
|
|
|
keyEquivalent: @"~n"];
|
|
|
|
[project addItemWithTitle: _(@"Save...")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (saveProject:)
|
2001-11-11 20:54:59 +00:00
|
|
|
keyEquivalent: @"~s"];
|
|
|
|
[project addItemWithTitle: _(@"Save As...")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (saveProjectAs:)
|
2001-11-11 20:54:59 +00:00
|
|
|
keyEquivalent: @"~S"];
|
|
|
|
[project addItemWithTitle: _(@"Close")
|
2001-11-05 19:58:25 +00:00
|
|
|
action: @selector (closeProject:)
|
|
|
|
keyEquivalent: @""];
|
|
|
|
|
2001-11-06 13:20:23 +00:00
|
|
|
/*
|
|
|
|
File
|
|
|
|
*/
|
|
|
|
file = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: file forItem: [menu itemWithTitle: _(@"File")]];
|
2001-11-06 13:20:23 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[file addItemWithTitle: _(@"Open...")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (open:)
|
|
|
|
keyEquivalent: @"o"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[file addItemWithTitle: _(@"New")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (createNew:)
|
|
|
|
keyEquivalent: @"n"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[file addItemWithTitle: _(@"Save...")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (save:)
|
|
|
|
keyEquivalent: @"s"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[file addItemWithTitle: _(@"Save As...")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (saveAs:)
|
|
|
|
keyEquivalent: @"S"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[file addItemWithTitle: _(@"Save All")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (saveAll:)
|
|
|
|
keyEquivalent: @""];
|
2001-11-11 20:54:59 +00:00
|
|
|
[file addItemWithTitle: _(@"Revert to Saved")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (revertToSaved:)
|
|
|
|
keyEquivalent: @""];
|
2001-11-11 20:54:59 +00:00
|
|
|
[file addItemWithTitle: _(@"Close")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (close:)
|
|
|
|
keyEquivalent: @""];
|
|
|
|
|
|
|
|
/*
|
|
|
|
Edit
|
|
|
|
*/
|
|
|
|
edit = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: edit forItem: [menu itemWithTitle: _(@"Edit")]];
|
2001-11-06 13:20:23 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[edit addItemWithTitle: _(@"Undo")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (undo:)
|
|
|
|
keyEquivalent: @"z"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[edit addItemWithTitle: _(@"Redo")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (redo:)
|
|
|
|
keyEquivalent: @"Z"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[edit addItemWithTitle: _(@"Cut")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (cut:)
|
|
|
|
keyEquivalent: @"x"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[edit addItemWithTitle: _(@"Copy")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (copy:)
|
|
|
|
keyEquivalent: @"c"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[edit addItemWithTitle: _(@"Paste")
|
2001-11-06 13:20:23 +00:00
|
|
|
action: @selector (paste:)
|
|
|
|
keyEquivalent: @"v"];
|
2001-11-11 20:54:59 +00:00
|
|
|
[edit addItemWithTitle: _(@"Delete")
|
|
|
|
action: @selector (delete:)
|
|
|
|
keyEquivalent: @""];
|
|
|
|
[edit addItemWithTitle: _(@"Select All")
|
|
|
|
action: @selector (selectAll:)
|
|
|
|
keyEquivalent: @"a"];
|
2001-11-06 13:20:23 +00:00
|
|
|
|
2001-11-07 02:50:54 +00:00
|
|
|
/*
|
|
|
|
BSP
|
|
|
|
*/
|
|
|
|
bsp = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: bsp forItem: [menu itemWithTitle: _(@"BSP")]];
|
2001-11-07 02:50:54 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[bsp addItemWithTitle: _(@"None") action: @selector(nothing:) keyEquivalent: @""];
|
|
|
|
|
2001-11-07 02:50:54 +00:00
|
|
|
/*
|
|
|
|
Brush
|
|
|
|
*/
|
|
|
|
brush = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: brush forItem: [menu itemWithTitle: _(@"Brush")]];
|
2001-11-07 02:50:54 +00:00
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
[brush addItemWithTitle: _(@"none") action: @selector(nothing:) keyEquivalent: @""];
|
2001-11-07 02:50:54 +00:00
|
|
|
|
2001-11-05 19:58:25 +00:00
|
|
|
/*
|
|
|
|
Windows
|
|
|
|
*/
|
|
|
|
windows = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
|
2001-11-05 19:58:25 +00:00
|
|
|
[NSApp setWindowsMenu: windows];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: windows forItem: [menu itemWithTitle: _(@"Windows")]];
|
2001-11-05 19:58:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Services
|
|
|
|
*/
|
|
|
|
services = [[[NSMenu alloc] init] autorelease];
|
2001-11-11 20:54:59 +00:00
|
|
|
|
2001-11-05 19:58:25 +00:00
|
|
|
[NSApp setServicesMenu: services];
|
2001-11-11 20:54:59 +00:00
|
|
|
[menu setSubmenu: services forItem: [menu itemWithTitle: _(@"Services")]];
|
2001-11-05 19:58:25 +00:00
|
|
|
|
|
|
|
[NSApp setMainMenu: menu];
|
|
|
|
}
|
|
|
|
|
2001-11-06 13:20:23 +00:00
|
|
|
/*
|
|
|
|
applicationWillTerminate:
|
|
|
|
|
2001-11-11 20:54:59 +00:00
|
|
|
Sort of like SIGQUIT. App is about to die, but has a chance to clean up
|
2001-11-06 13:20:23 +00:00
|
|
|
*/
|
2001-11-05 19:58:25 +00:00
|
|
|
- (void) applicationWillTerminate: (NSNotification *) not;
|
|
|
|
{
|
|
|
|
}
|