ftp.nice.ch/pub/next/science/mathematics/HippoDraw.2.0.s.tar.gz#/HippoDraw/HDController.m

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

/* HDController.m		by Paul Kunz	January 1993
 * Application delegate to make Hippo.bundle into HippoDraw application.
 * Also serves as example on how to incorporate Hippo into an application.
 *
 * Copyright (C)  1993  The Board of Trustees of
 * The Leland Stanford Junior University.  All Rights Reserved.
 */
 
#import "HDController.h"

const char HDController_h_rcsid[] = HDCONTROLLER_H_ID;
const char HDController_m_rcsid[] = "$Id: HDController.m,v 1.10 1993/08/04 21:54:45 pfkeb Exp $";

#import <appkit/appkit.h>

#import "HDrawApp.h"
#import "sym/MailSpeaker.h"

@implementation HDController

- init
{
    NXBundle	*bundle;
    BOOL	ok;
    
    char buffer[MAXPATHLEN+1];
   
    ok = [[NXBundle mainBundle] getPath:buffer
            forResource:"Hippo"  ofType:"bundle"];
    if ( ok ) {
	bundle = [[NXBundle alloc] initForDirectory:buffer];
	if (bundle) {
	    hippoDraw = [[[bundle classNamed:"HDrawApp"] alloc] init];
	} else {
	    ok = NO;
	}
    }
    if (!ok) {
	NXRunAlertPanel( "Error",
	    "Can not find or load Hippo bundle", "Ok", NULL, NULL );
    }
   return self;
}

- appDidInit:(Application *)sender
{
    return [hippoDraw appDidInit:sender];
}
- addToAvailFuncs:sender
{
    return [hippoDraw addToAvailFuncs:sender];
}
- (BOOL)validateCommand:(MenuCell *)menuCell
{
    return [hippoDraw validateCommand:menuCell];
}

- info:sender
{
    [hippoDraw info:sender];
    return self;
}
- legal:sender
{
    [hippoDraw legal:sender];
    return self;
}
- cernPanel:sender
{
    [hippoDraw cernPanel:sender];
    return self;
}
- new:sender
{
    return [hippoDraw new:sender];
}
- open:sender
{
    return [hippoDraw open:sender];
}
- openTuple:sender
{
    return [hippoDraw openTuple:sender];
}
- openTupleAsText:sender
{
    return [hippoDraw openTupleAsText:sender];
}

- closeTuple:sender
{
    return [hippoDraw closeTuple:sender];
}

- setCurrentGraphic:sender
{
    return [hippoDraw setCurrentGraphic:sender];
}
- terminate:sender
{
    return [hippoDraw terminate:sender];
}

- orderFrontTools:sender
{
    return [hippoDraw orderFrontTools:sender];
}

- orderFrontInspector:sender
{
    return [hippoDraw orderFrontTupleInsp:sender];
}

- showTupleAsTable:sender
{
    return [hippoDraw showTupleAsTable:sender];
}

- showHelpPanel:sender
{
    NXHelpPanel	*panel = [NXHelpPanel new];
    
    [panel makeKeyAndOrderFront:self];
    return self;
}
- (int)app:sender openFile:(const char *)path type:(const char *)type
 /*
  * This method is performed whenever a user double-clicks on an icon
  * in the Workspace Manager representing a Draw program document.
  */
{
    return [hippoDraw app:sender openFile:path type:type];
}
- (BOOL)appAcceptsAnotherFile:(Application *)sender
 /*
  * We accept any number of appOpenFile:type: messages.
  */
{
    return YES;
}

- app:sender powerOffIn:(int)ms andSave:(int)andSave
{
    return [hippoDraw app:sender powerOffIn:ms andSave:andSave];
}    

- (BOOL)menuItemUpdate:(MenuCell *)menuCell
{
    return [hippoDraw menuItemUpdate:menuCell];
}
- mailSpeaker
{
    id		worksp;
    id		speaker;
    port_t 	mail;
    
    worksp = [Application workspace];
    if ( ![worksp launchApplication:"Mail"] ) {
        NXRunAlertPanel("Error", 
	   "Can not find Mail.app for unknown reason.",
	   "OK", NULL, NULL);
	return nil;
    }
    speaker = [MailSpeaker new];
    mail = NXPortFromName("MailSendDemo", ""); // ACK for now it works
    [speaker setSendPort:mail];
    return speaker;
}
- sendBug:sender
{
    id 	speaker;
    int theWin;
  
    speaker = [self mailSpeaker];
    [speaker openSend:&theWin];
    [speaker setSubject:"Bug report" inWindow:theWin];
    [speaker setTo:"Hippo_Bug@ebnextk.slac.stanford.edu" inWindow:theWin];
    [speaker free];
    return self;
}
- sendSuggestion:sender
{
    id 	speaker;
    int theWin;
    
    speaker = [self mailSpeaker];
    [speaker openSend:&theWin];
    [speaker setSubject:"Suggestion" inWindow:theWin];
    [speaker setTo:"Hippo_Comment@ebnextk.slac.stanford.edu" inWindow:theWin];
    [speaker free];
    return self;
}
@end

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