home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Palettes / MiscClockPalette / MiscClockViewInspector.m < prev    next >
Encoding:
Text File  |  1993-10-01  |  2.2 KB  |  82 lines

  1. //
  2. //    MiscClockViewInspector.m -- a simple view class for displaying date/time
  3. //        Written by Scott Anguish (c) 1993 by Scott Anguish.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This object is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. #import "MiscClockViewInspector.h"
  15. #import <appkit/appkit.h>
  16. #import "MiscClockView.subproj/MiscClockView.h"
  17.  
  18. @implementation MiscClockViewInspector
  19.  
  20. - init
  21. {
  22.     char buf[MAXPATHLEN + 1];
  23.     id bundle;
  24.     
  25.     [super init];
  26.     bundle = [NXBundle bundleForClass:[MiscClockView class]];
  27.     [bundle getPath:buf forResource:"MiscClockViewInspector" ofType:"nib"];
  28.     [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
  29.     return self;
  30. }
  31.  
  32. - (BOOL)wantsButtons { return YES; }
  33.  
  34. - revert:sender
  35. {
  36.     // Put string in text object
  37.     [dayText setIntValue:[object weekday]];
  38.     [dateText setIntValue:[object date]];
  39.     [monthText setIntValue:[object month]];
  40.     [yearText setIntValue:[object year]];
  41.     [hourText setIntValue:[object hours]];
  42.     [minuteText setIntValue:[object minutes]];
  43.     [secondText setIntValue:[object seconds]];
  44.     [militaryTime setState:[object militaryTime]];
  45.     [showYear setState:[object showYear]];
  46.  
  47.     return [super revert:sender];
  48. }
  49.  
  50. - ok:sender
  51. {
  52.     [object setSeconds:[secondText intValue]];
  53.     [object setMinutes:[minuteText intValue]];
  54.     [object takeHoursFrom:hourText]; // to set the meridian right
  55.     [object setDate:[dateText intValue]];
  56.     [object setWeekday:[dayText intValue]];
  57.     [object setMonth:[monthText intValue]];
  58.     [object setYear:[yearText intValue]];
  59.     [object setMilitaryTime:[militaryTime state]];
  60.     [object setShowYear:[showYear state]];
  61.  
  62.  
  63.     [object display];
  64.     return [super ok:sender];
  65. }
  66.  
  67. - setToCurrentTime:sender
  68. {
  69.     struct timeval tp;
  70.     struct timezone tzp;
  71.     struct tm *tv;
  72.     
  73.     gettimeofday(&tp, &tzp);
  74.     tv = localtime(&tp.tv_sec);
  75.     [object setTime:tv];
  76.     [object display];
  77.     [self revert:self]; // load values into the text fields
  78.     return [self ok:self]; // show change in the object
  79. }
  80.  
  81. @end
  82.