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

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