ftp.nice.ch/pub/next/developer/objc/appkit/Starter.1.1.s.tar.gz#/Starter1.1/STMenuCategory.m

This is STMenuCategory.m in view mode; [Download] [Up]

/* STMenuCategory.m - written by Robert Vasvari 6/94
   this class is created solely for the purpose of dealing with
   menus */

#import "STMenuCategory.h"

@implementation STAppController(MenuController)


- setupMenus:sender
{
id  matrix;
	
	/* take care of the document menu */
	matrix=[documentMenu itemList];
	[[matrix cellAt:2 :0] //save
		setUpdateAction:@selector(updateDocMenus:) forMenu:documentMenu];
	[[matrix cellAt:3 :0] //saveAs
		setUpdateAction:@selector(updateDocMenus:) forMenu:documentMenu];
	[[matrix cellAt:4 :0] //SaveTo
		setUpdateAction:@selector(updateDocMenus:) forMenu:documentMenu];
	[[matrix cellAt:5 :0] //SaveAll
		setUpdateAction:@selector(updateDocMenus:) forMenu:documentMenu];
	[[matrix cellAt:6 :0] //Revert
		setUpdateAction:@selector(updateDocMenus:) forMenu:documentMenu];
	[[matrix cellAt:7 :0] //Close
		setUpdateAction:@selector(updateDocMenus:) forMenu:documentMenu];

	/* take care of the window menu */
    [windowsMiniaturize setUpdateAction:
	     @selector(updateWindowsMiniaturize:) forMenu:[NXApp windowsMenu]];
    [windowsClose setUpdateAction:
		 @selector(updateWindowsClose:) forMenu:[NXApp windowsMenu]];

    /* this will fix all of the edit menus */
    matrix=[editMenu itemList];
	[[matrix cellAt:0 :0] setUpdateAction:
		 @selector(updateEditMenus:) forMenu:editMenu];
	[[matrix cellAt:1 :0] setUpdateAction:
		 @selector(updateEditMenus:) forMenu:editMenu];
	[[matrix cellAt:2 :0] setUpdateAction:
		 @selector(updateEditMenus:) forMenu:editMenu];
	[[matrix cellAt:3 :0] setUpdateAction:
		 @selector(updateEditMenus:) forMenu:editMenu];
	[[matrix cellAt:4 :0] setUpdateAction:
		 @selector(updateEditMenus:) forMenu:editMenu];

	return self;
}

/* menu update methods */

- (BOOL)updateDocMenus:aMenuCell
{	
	return [self setMenu:aMenuCell
			     enable:([self currentDoc]!=nil)];
}

- (BOOL)updateWindowsMiniaturize:aMenuCell
{
    id t;

    t=[NXApp calcTargetForAction:[aMenuCell action]];
	return [self setMenu:aMenuCell
			     enable:(t && ([t buttonMask]&NX_MINIATURIZEBUTTONMASK)!=0)];
}

- (BOOL)updateWindowsClose:aMenuCell
{
    id t=[NXApp calcTargetForAction:[aMenuCell action]];
	return [self setMenu:aMenuCell
			     enable:(t && ([t buttonMask]&NX_CLOSEBUTTONMASK)!=0)];
}

- (BOOL)updateEditMenus:aMenuCell
{	
	return [self setMenu:aMenuCell
			     enable:[[[NXApp keyWindow] firstResponder]
				 			respondsTo:@selector(paste:)]];
}

- (BOOL)isDeleteEnabled
{	return [editDelete isEnabled];
}

- (BOOL)setMenu:aMenuCell enable:(BOOL)flag
{	if(flag)
	 { 	if(![aMenuCell isEnabled]) 
		 { 	[aMenuCell setEnabled:YES];
			return YES;
		 }
	 }
	else
	 { if([aMenuCell isEnabled]) 
		{ [aMenuCell setEnabled:NO];
		return YES;
		}
	 } 
	  
	return NO;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.