Forge updates. The app controller now has methods for bundles to call,

to register functionality with the app.
This commit is contained in:
Jeff Teunissen 2001-11-28 23:46:37 +00:00
parent 74e2f63188
commit a7dfe849fd
9 changed files with 48 additions and 22 deletions

View file

@ -62,6 +62,15 @@
@end @end
/*
Forge bundles need an owner to send their messages to
*/
@protocol ForgeBundle <NSObject>
- (id) initWithOwner: (id <BundleDelegate>) anOwner;
@end
@interface BundleController: NSObject @interface BundleController: NSObject
{ {
id delegate; id delegate;

View file

@ -129,6 +129,7 @@ static const char rcsid[] =
*/ */
- (void) applicationWillFinishLaunching: (NSNotification *) not; - (void) applicationWillFinishLaunching: (NSNotification *) not;
{ {
#if 0
NSMenu *menu = [[[NSMenu alloc] init] autorelease]; NSMenu *menu = [[[NSMenu alloc] init] autorelease];
NSMenu *info; NSMenu *info;
NSMenu *project; NSMenu *project;
@ -260,6 +261,7 @@ static const char rcsid[] =
[menu setSubmenu: services forItem: [menu itemWithTitle: _(@"Services")]]; [menu setSubmenu: services forItem: [menu itemWithTitle: _(@"Services")]];
[NSApp setMainMenu: menu]; [NSApp setMainMenu: menu];
#endif
{ // yeah, yeah, shaddap { // yeah, yeah, shaddap
id controller = [[BundleController alloc] init]; id controller = [[BundleController alloc] init];
@ -284,23 +286,29 @@ static const char rcsid[] =
- (void) bundleController: (BundleController *) aController didLoadBundle: (NSBundle *) aBundle - (void) bundleController: (BundleController *) aController didLoadBundle: (NSBundle *) aBundle
{ {
NSDictionary *info = nil;
if (!aBundle) { if (!aBundle) {
NSLog (@"Controller -bundleController: sent nil bundle"); NSLog (@"Controller -bundleController: sent nil bundle");
return; return;
} }
info = [aBundle infoDictionary];
if (![aBundle principalClass]) { if (![aBundle principalClass]) {
NSDictionary *info = [aBundle infoDictionary];
if (!(info || [info objectForKey: @"NSExecutable"])) { if (!(info || [info objectForKey: @"NSExecutable"])) {
NSLog (@"%@ has no principal class and no info dictionary", aBundle); NSLog (@"%@ has no principal class and no info dictionary", aBundle);
return; return;
} }
NSLog (@"Bundle `%@' has no principal class!", [info objectForKey: @"NSExecutable"]); NSLog (@"Bundle `%@' has no principal class!", [[info objectForKey: @"NSExecutable"] lastPathComponent]);
return; return;
} }
[[[aBundle principalClass] alloc] init]; if (![[aBundle principalClass] conformsToProtocol: @protocol(ForgeBundle)]) {
NSLog (@"Bundle %@'s principal class does not conform to the ForgeBundle protocol.", [[info objectForKey: @"NSExecutable"] lastPathComponent]);
return;
}
[[(id <ForgeBundle>) [aBundle principalClass] alloc] initWithOwner: self];
} }
- (BOOL) registerPrefsController: (id <PrefsViewController>) aPrefsController - (BOOL) registerPrefsController: (id <PrefsViewController>) aPrefsController

View file

@ -12,9 +12,11 @@
Actions = ( Actions = (
createNew:, createNew:,
createNewProject:, createNewProject:,
infoPanel:,
open:, open:,
openProject:, openProject:,
saveAll: saveAll:,
showPreferencesPanel:
); );
Outlets = ( Outlets = (
); );

Binary file not shown.

View file

@ -1,5 +1,5 @@
{ {
ApplicationDescription = "A map editor for QuakeForge"; ApplicationDescription = "A game editor for QuakeForge";
ApplicationIcon = "Forge.tiff"; ApplicationIcon = "Forge.tiff";
ApplicationName = Forge; ApplicationName = Forge;
ApplicationRelease = "0.1.0 (Development)"; ApplicationRelease = "0.1.0 (Development)";
@ -7,7 +7,7 @@
Authors = ( Authors = (
"Jeff Teunissen <deek@d2dc.net>", "Jeff Teunissen <deek@d2dc.net>",
); );
Copyright = "Copyright (C) 2001 Dusk To Dawn Computing"; Copyright = "Copyright (C) 2001 Dusk To Dawn Computing, Inc.";
CopyrightDescription = "This program is released under the GNU General Public License"; CopyrightDescription = "Released under the GNU GPL. See COPYING for details.";
FullVersionID = "0.1.0 (Development)"; FullVersionID = "0.1.0 (Development)";
} }

View file

@ -153,8 +153,7 @@ static NSMutableArray *prefsViews = nil;
[controller autorelease]; [controller autorelease];
} }
[[prefsPanel prefsViewBox] setContentView: [controller view]]; [prefsPanel addPrefsViewButton: controller];
[[prefsPanel prefsViewBox] setNeedsDisplay: YES];
} }
@end @end

View file

@ -1,7 +1,7 @@
/* /*
PrefsWindow.h PrefsPanel.h
Preferences window class Preferences panel class
Copyright (C) 2001 Dusk to Dawn Computing, Inc. Copyright (C) 2001 Dusk to Dawn Computing, Inc.
@ -47,7 +47,11 @@
- (void) initUI; - (void) initUI;
- (void) dealloc; - (void) dealloc;
- (void) addPrefsViewButtonWithTitle: (NSString *) desc andImage: (NSImage *) img; #if 0
- (NSButtonCell *) addPrefsViewButtonWithTitle: (NSString *) desc andImage: (NSImage *) img;
#else
- (void) addPrefsViewButton: (NSButtonCell *) aButton;
#endif
- (NSBox *) prefsViewBox; - (NSBox *) prefsViewBox;
- (NSMatrix *) prefsViewList; - (NSMatrix *) prefsViewList;

View file

@ -1,7 +1,7 @@
/* /*
PrefsWindow.m PrefsPanel.m
Preferences window class Preferences panel class
Copyright (C) 2001 Dusk to Dawn Computing, Inc. Copyright (C) 2001 Dusk to Dawn Computing, Inc.
@ -41,6 +41,7 @@ static const char rcsid[] =
#import <AppKit/NSMatrix.h> #import <AppKit/NSMatrix.h>
#import <AppKit/NSScrollView.h> #import <AppKit/NSScrollView.h>
#import "BundleController.h"
#import "PrefsPanel.h" #import "PrefsPanel.h"
@implementation PrefsPanel @implementation PrefsPanel
@ -81,7 +82,6 @@ static const char rcsid[] =
[prefsViewList setPrototype: prototype]; [prefsViewList setPrototype: prototype];
[prefsViewList setTarget: [self windowController]]; [prefsViewList setTarget: [self windowController]];
[prefsViewList setAction: @selector(cellWasClicked:)]; [prefsViewList setAction: @selector(cellWasClicked:)];
[prefsViewList addRow]; // No columns yet, they'll get added as views do
iconScrollView = [[NSScrollView alloc] initWithFrame: NSMakeRect (8, 290, 500, 86)]; iconScrollView = [[NSScrollView alloc] initWithFrame: NSMakeRect (8, 290, 500, 86)];
[iconScrollView autorelease]; [iconScrollView autorelease];
@ -136,15 +136,17 @@ static const char rcsid[] =
[super dealloc]; [super dealloc];
} }
- (void) addPrefsViewButtonWithTitle: (NSString *) desc andImage: (NSImage *) img - (void) addPrefsViewButton: (id <PrefsViewController>) aController
{ {
NSButtonCell *button = [[NSButtonCell alloc] init]; NSButtonCell *button = [[NSButtonCell alloc] init];
[button setTag: _topTag++]; [button setTag: _topTag++];
[button setTitle: desc]; [button setTitle: [aController buttonCaption]];
[button setFont: [NSFont systemFontOfSize: 8]]; [button setFont: [NSFont systemFontOfSize: 9]];
[button setImage: img]; [button setImage: [aController buttonImage]];
[button setImagePosition: NSImageAbove]; [button setImagePosition: NSImageAbove];
[button setTarget: aController];
[button setAction: [aController buttonSelector]];
[prefsViewList addColumnWithCells: [NSArray arrayWithObject: button]]; [prefsViewList addColumnWithCells: [NSArray arrayWithObject: button]];
[prefsViewList sizeToCells]; [prefsViewList sizeToCells];
[prefsViewList setNeedsDisplay: YES]; [prefsViewList setNeedsDisplay: YES];

View file

@ -31,7 +31,9 @@
# include "Config.h" # include "Config.h"
#endif #endif
#import <Foundation/NSObject.h>
#import <AppKit/NSView.h> #import <AppKit/NSView.h>
#import <AppKit/NSButtonCell.h>
// size of a PrefsView // size of a PrefsView
#define PrefsRect NSMakeRect (0, 0, 486, 228) #define PrefsRect NSMakeRect (0, 0, 486, 228)
@ -42,9 +44,9 @@
- (void) loadPrefs: (id) sender; - (void) loadPrefs: (id) sender;
- (void) resetPrefsToDefault: (id) sender; - (void) resetPrefsToDefault: (id) sender;
- (NSString *) buttonCaption;
- (NSImage *) buttonImage;
- (SEL) buttonSelector;
- (NSView *) view; - (NSView *) view;
@end @end
@interface PrefsViewController <PrefsViewController>
@end