Forge updates: Windows are now remembered and stuff is in general a bit

cleaner. Committing this so that the stuff I'm about to write won't totally
fubar everything. :)
This commit is contained in:
Jeff Teunissen 2002-05-29 07:13:42 +00:00
parent 8025dfd2ce
commit 6c9c62139a
7 changed files with 105 additions and 79 deletions

View file

@ -36,6 +36,8 @@
#import <Foundation/NSBundle.h>
#import <Foundation/NSObject.h>
#import <AppKit/NSNibDeclarations.h>
#import "PrefsController.h"
#import "PrefsView.h"
@ -75,7 +77,7 @@
@interface BundleController: NSObject
{
id delegate;
IBOutlet id delegate;
NSMutableArray *loadedBundles;
}

View file

@ -61,12 +61,16 @@
- (void) applicationWillTerminate: (NSNotification *) not;
// Action methods
- (IBAction) createNew: (id) sender;
- (IBAction) createNewProject: (id) sender;
- (IBAction) infoPanel: (id) sender;
- (IBAction) open: (id) sender;
- (IBAction) openProject: (id) sender;
- (IBAction) saveProject: (id) sender;
- (IBAction) showPreferencesPanel: (id) sender;
// Projects
- (IBAction) newProject: (id) sender;
- (IBAction) openProject: (id) sender;
- (IBAction) saveProject: (id) sender;
- (IBAction) closeProject: (id) sender;
// Files
- (IBAction) addFileToProject: (id) sender;
- (IBAction) addNewFileToProject: (id) sender;
- (IBAction) open: (id) sender;
@end

View file

@ -37,6 +37,7 @@ static const char rcsid[] =
#import <AppKit/NSApplication.h>
#import <AppKit/NSMenu.h>
#import <AppKit/NSWindow.h>
#import "Controller.h"
#import "PrefsController.h"
@ -73,38 +74,9 @@ static const char rcsid[] =
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) saveProject: (id) sender;
{
NSLog (@"This _would_ save, but it doesn't.");
}
******/
- (void) showPreferencesPanel: (id) sender;
{
@ -113,8 +85,49 @@ static const char rcsid[] =
}
/*
Notifications
Project management
*/
- (void) newProject: (id) sender;
{
NSLog (@"This _will_ create a new project, but it doesn't yet.");
}
- (void) openProject: (id) sender;
{
NSLog (@"This _will_ open a project, but it doesn't yet.");
}
- (void) saveProject: (id) sender;
{
NSLog (@"This _will_ save the project, but it doesn't yet.");
}
- (void) closeProject: (id) sender;
{
NSLog (@"This _will_ close the project, but it doesn't yet.");
}
/*
File-level stuff.
*/
- (void) addFileToProject: (id) sender;
{
NSLog (@"This _will_ copy/move a file into the project, but it doesn't yet.");
}
- (void) addNewFileToProject: (id) sender;
{
NSLog (@"This _will_ create a new file, but it doesn't yet.");
}
- (void) open: (id) sender;
{
NSLog (@"This _will_ open a file, but it doesn't yet.");
}
/******
Notifications
******/
/*
applicationDidFinishLaunching:
@ -162,6 +175,8 @@ static const char rcsid[] =
******/
- (void) awakeFromNib
{
[window setFrameAutosaveName: @"Project View"];
[window setFrameUsingName: @"Project View"];
}
/******

View file

@ -1,8 +1,5 @@
{
BundleController = {
Actions = (
setDelegate
);
Outlets = (
delegate
);
@ -13,10 +10,9 @@
addFileToProject:,
addNewFileToProject:,
closeProject:,
createNewProject:,
infoPanel:,
newProject:,
open:,
openProject:,
openSelectedFile:,
saveProject:,
showPreferencesPanel:
);

Binary file not shown.

View file

@ -54,22 +54,17 @@
- (id) init;
- (void) dealloc;
/*
Notification methods
*/
- (void) windowWillClose: (NSNotification *) aNotification;
/***
Stuff we do in our subclass
***/
- (void) orderFrontPreferencesPanel: (id) sender;
- (void) addPrefsViewController: (id <PrefsViewController>) aPrefsViewController;
- (IBAction) orderFrontPreferencesPanel: (id) sender;
- (IBAction) addPrefsViewController: (id <PrefsViewController>) aPrefsViewController;
- (void) savePreferences: (id) sender;
- (void) savePreferencesAndCloseWindow: (id) sender;
- (IBAction) savePreferences: (id) sender;
- (IBAction) savePreferencesAndCloseWindow: (id) sender;
- (void) loadPreferences: (id) sender;
- (void) resetToDefaults: (id) sender;
- (IBAction) loadPreferences: (id) sender;
- (IBAction) resetToDefaults: (id) sender;
- (NSBox *) prefsViewBox;
@end

View file

@ -47,11 +47,21 @@ static const char rcsid[] =
static PrefsController *sharedInstance = nil;
static NSMutableArray *prefsViews = nil;
/*
sharedPrefsController
Returns the shared instance
*/
+ (PrefsController *) sharedPrefsController
{
return (sharedInstance ? sharedInstance : [[self alloc] init]);
}
/*
init
Ensures that there is only one global instance of the class
*/
- (id) init
{
if (sharedInstance) {
@ -65,28 +75,28 @@ static NSMutableArray *prefsViews = nil;
return sharedInstance;
}
/*
awakeFromNib
Initialize stuff that can't be set in the nib/gorm file.
*/
- (void) awakeFromNib
{
NSButtonCell *prototype;
// Let the systen keep track of where it belongs
[window setFrameAutosaveName: @"Preferences"];
[window setFrameUsingName: @"Preferences"];
// keep the window out of the menu until it's seen
[window setExcludedFromWindowsMenu: YES];
if (iconList)
if (iconList) // stop processing if we already have an icon list
return;
/* Prototype button for the matrix */
prototype = [[[NSButtonCell alloc] init] autorelease];
[prototype setButtonType: NSPushOnPushOffButton];
[prototype setImagePosition: NSImageOverlaps];
/* What is the matrix? */
/* What is the matrix? :) */
iconList = [[NSMatrix alloc] initWithFrame: NSMakeRect (0, 0, 64, 64)];
[iconList setCellClass: [NSButtonCell class]];
[iconList setCellSize: NSMakeSize (64, 64)];
[iconList setMode: NSRadioModeMatrix];
[iconList setPrototype: prototype];
[iconList setTarget: self];
[iconList setAction: @selector(cellWasClicked:)];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: NO];
@ -101,24 +111,24 @@ static NSMutableArray *prefsViews = nil;
[super dealloc];
}
- (void) windowWillClose: (NSNotification *) aNotification
{
}
/*
orderFrontPreferencesPanel:
- (void) orderFrontPreferencesPanel: (id) sender
Display our window
*/
- (IBAction) orderFrontPreferencesPanel: (id) sender
{
[window setExcludedFromWindowsMenu: NO];
[window makeKeyAndOrderFront: self];
return;
}
- (void) savePreferencesAndCloseWindow: (id) sender
- (IBAction) savePreferencesAndCloseWindow: (id) sender
{
[self savePreferences: self];
[window close];
}
- (void) savePreferences: (id) sender
- (IBAction) savePreferences: (id) sender
{
NSEnumerator *enumerator = [prefsViews objectEnumerator];
id <PrefsViewController> current;
@ -131,7 +141,7 @@ static NSMutableArray *prefsViews = nil;
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void) loadPreferences: (id) sender
- (IBAction) loadPreferences: (id) sender
{
NSEnumerator *enumerator = [prefsViews objectEnumerator];
id <PrefsViewController> current;
@ -144,7 +154,7 @@ static NSMutableArray *prefsViews = nil;
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void) resetToDefaults: (id) sender
- (IBAction) resetToDefaults: (id) sender
{
NSEnumerator *enumerator = [prefsViews objectEnumerator];
id <PrefsViewController> current;
@ -157,7 +167,13 @@ static NSMutableArray *prefsViews = nil;
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void) addPrefsViewController: (id <PrefsViewController>) aController;
/*
addPrefsViewController:
Add a prefs view controller to our list, if it hasn't been added already.
Also, create an icon for the matrix.
*/
- (IBAction) addPrefsViewController: (id <PrefsViewController>) aController;
{
NSButtonCell *button = [[NSButtonCell alloc] init];
@ -175,8 +191,6 @@ static NSMutableArray *prefsViews = nil;
[iconList addColumnWithCells: [NSArray arrayWithObject: button]];
[iconList sizeToCells];
[iconList setNeedsDisplay: YES];
// [prefsPanel addPrefsViewButton: controller];
}
- (NSBox *) prefsViewBox