ftp.nice.ch/pub/next/unix/audio/sms.N.bs.tar.gz#/sms/smsEditor/AsciiView.m

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

/* Generated by Interface Builder */

#import "AsciiView.h"
#import "AsciiController.h"
#import "SmsObject.h"
#import <strings.h>

@implementation AsciiView

- getTheSmsObject
{
  if (!winDelegate)
    winDelegate = [window delegate];

  if ([winDelegate respondsTo:@selector(getTheSmsObject)])
    return [winDelegate getTheSmsObject];
  else
    return NULL;
}

- initFrame:(NXRect const *)theFrame
{
    NXRect tempRect = *theFrame;
    int borderType = NX_NOBORDER;
     
    [ScrollView getContentSize:&tempRect.size forFrameSize:&theFrame->size
    		horizScroller:NO vertScroller:YES borderType:borderType];
    theTextView = [[Text alloc] initFrame:&tempRect text:NULL
   		                alignment:NX_LEFTALIGNED];
    [super initFrame:theFrame];
      /* specify scrollbars */
    [self setVertScrollerRequired:YES]; 
    [self setHorizScrollerRequired:NO];
    [self setBorderType:borderType];
    [self setDynamicScrolling:YES];
    [self setDocView:theTextView];
    [self setBackgroundGray:NX_WHITE];
    [self setAutoresizeSubviews:YES];
    [self setAutosizing:NX_WIDTHSIZABLE|NX_HEIGHTSIZABLE];
    [theTextView notifyAncestorWhenFrameChanged:YES];
    [theTextView setVertResizable:YES];
    [theTextView setHorizResizable:NO];
    [theTextView setOpaque:YES];
    [theTextView setCharFilter:NXEditorFilter];
    [theTextView setEditable:YES];
    [theTextView setSelectable:YES];
    [[theTextView superview] setAutoresizeSubviews:YES];
    [[theTextView superview] setAutosizing:NX_HEIGHTSIZABLE|NX_WIDTHSIZABLE];
    return self;
}

//-------------------------------------------------------------------
// - drawFrame: - write the ASCII representation of a frame
- copyFrame:(int)iFrame :(char *)pString
{
  id theSmsObject = [self getTheSmsObject];
  int iFirstTraj = [winDelegate getLowestTraj];
  int iLastTraj = [winDelegate getHighestTraj];
  int iTraj;
  float fFreq, fMag, fStocMag, fStocCoeff;
  char pTmpString[256];
  
  sprintf (pTmpString, "\n Frame %d (%.3f): \n ", iFrame, 
            (float) iFrame / [theSmsObject getFrameRate]); 
  strcat (pString, pTmpString);

  if ([winDelegate getDeterministicFreqState] ||
      [winDelegate getDeterministicMagState])
  {
    sprintf (pTmpString, "Deterministic: ");
    strcat (pString, pTmpString);
  }
  
  for(iTraj = iFirstTraj; iTraj < iLastTraj; iTraj++)
  {
    if ([winDelegate getDeterministicFreqState] &&
        [winDelegate getDeterministicMagState])
    {
       fFreq = [theSmsObject getDeterministicFreq:iFrame iTraj:iTraj];
       fMag = [theSmsObject getDeterministicMag:iFrame iTraj:iTraj];
       sprintf (pTmpString, "%.0f [%.0f], ", fFreq, fMag); 
       strcat (pString, pTmpString);
    }
    else if ([winDelegate getDeterministicFreqState])
    {
       fFreq = [theSmsObject getDeterministicFreq:iFrame iTraj:iTraj];
       sprintf (pTmpString, "%.0f, ", fFreq); 
       strcat (pString, pTmpString);
    }
    else if ([winDelegate getDeterministicMagState])
    {
       fMag = [theSmsObject getDeterministicMag:iFrame iTraj:iTraj];
       sprintf (pTmpString, "%.0f, ", fMag); 
       strcat (pString, pTmpString);
    }
  } 
  
  if ([winDelegate getStochasticState])
  {
    fMag = [theSmsObject getStochasticGain:iFrame];

    sprintf (pTmpString, "\n Stochastic Gain:  %.0f", fMag);
    strcat (pString, pTmpString);
  }

  return self;  
}

//-------------------------------------------------------------------
// - drawSelf:: - write the ASCII representation

- drawSelf:(const NXRect *)rects :(int)rectCount
{
  int iFrame = [winDelegate getFirstFrame];
  int iLastFrame = [winDelegate getLastFrame];
  id theSmsObject = [self getTheSmsObject];
  char pString[100000];
  
  NXEraseRect(&bounds);

  if (theSmsObject != NULL)
  {
    while(iFrame <= iLastFrame)
    {
      [self copyFrame:iFrame :pString];
      iFrame++;
    }
    [theTextView setText:pString];
  }
  return self;
}


@end

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