home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / NMK / Historian / SliderPresenter.m < prev    next >
Encoding:
Text File  |  1993-01-18  |  1.5 KB  |  86 lines

  1. /***** SliderPresenter.m -- Slider data display object implementation
  2.     NeXTstep Measurement Kit
  3.     by Alex Meyer <ameyer@phoenix.Princeton.EDU>
  4.     for computer science senior thesis
  5.     19 April 1992 -- created
  6.     22 April 1992 -- incorporated structs.h & added identify
  7. *****/
  8.  
  9. #import <stdlib.h>
  10. #import <stdio.h>
  11. #import <string.h>
  12. #import <appkit/Application.h>
  13. #import "Historian.h"
  14. #import "SliderPresenter.h"
  15.  
  16. @implementation SliderPresenter
  17.  
  18. static id instance = nil;
  19.  
  20. + new
  21. {
  22.     if (instance == nil) {
  23.         instance = [self alloc];
  24.         [NXApp loadNibSection:"SliderPresenter.nib"
  25.             owner:instance];
  26.     }
  27.     return (instance);
  28. }
  29.  
  30.  
  31. - showData:sender
  32. {
  33.     int i,tag;
  34.     float x,y,width,height;
  35.     char *p,*text;
  36.     NXAtom key;
  37.  
  38.     [sender copyDataTo:&rec];
  39.     key = [sender getKey];
  40.     for (p = key,i = 0;*p != '|';++p)
  41.         ++i;
  42.     text = malloc(i + 1);
  43.     strncpy(text,key,i);
  44.     text[i] = 0;
  45.     sscanf(p,"|%d|%f|%f|%f|%f",&tag,&x,&y,&width,&height);
  46.     [form setStringValue:text
  47.         at:0];
  48.     [form setIntValue:tag
  49.         at:1];
  50.     [form setFloatValue:x
  51.         at:2];
  52.     [form setFloatValue:y
  53.         at:3];
  54.     [form setFloatValue:width
  55.         at:4];
  56.     [form setFloatValue:height
  57.         at:5];
  58.     [form setIntValue:rec.numHits
  59.         at:6];            /* should be unsigned */
  60.     [form setDoubleValue:rec.timeIn
  61.         at:7];
  62.     [form setDoubleValue:rec.timeBetween
  63.         at:8];
  64.     [histView copyInNum:SLIDERHIST
  65.         data:rec.histogram];
  66.     [histView display];
  67.     free(text);
  68.     [window orderFront:self];
  69.     return self;
  70. }
  71.  
  72.  
  73. - hide:sender
  74. {
  75.     [window orderOut:self];
  76.     return self;
  77. }
  78.  
  79.  
  80. - (NXAtom)identify
  81. {
  82.     return (NXUniqueString("Sliders"));
  83. }
  84.  
  85. @end
  86.