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

  1. /***** ButtonPresenter.m -- Button data display object implementation
  2.     NeXTstep Measurement Kit
  3.     by Alex Meyer <ameyer@phoenix.Princeton.EDU>
  4.     for computer science senior thesis
  5.     17 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 "ButtonPresenter.h"
  15.  
  16. @implementation ButtonPresenter
  17.  
  18. static id instance = nil;
  19.  
  20. + new
  21. {
  22.     if (instance == nil) {
  23.         instance = [self alloc];
  24.         [NXApp loadNibSection:"ButtonPresenter.nib"
  25.             owner:instance];
  26.     }
  27.     return (instance);
  28. }
  29.  
  30.  
  31. - showData:sender
  32. {
  33.     NXAtom key;
  34.     int i,tag;
  35.     float x,y,width,height;
  36.     char *p,*text;
  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 setIntValue:rec.numCancel
  61.         at:7];
  62.     [form setDoubleValue:rec.timeIn
  63.         at:8];
  64.     [form setDoubleValue:rec.timeBetween
  65.         at:9];
  66.     free(text);
  67.     [window orderFront:self];
  68.     return (self);
  69. }
  70.  
  71.  
  72. - hide:sender
  73. {
  74.     [window orderOut:self];
  75.     return (self);
  76. }
  77.  
  78.  
  79. - (NXAtom)identify
  80. {
  81.     return (NXUniqueString("Buttons"));
  82. }
  83.  
  84. @end
  85.