home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscClockViewInspector.m -- a simple view class for displaying date/time
- // Written by Scott Anguish (c) 1993 by Scott Anguish.
- // Version 1.0. All rights reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- #import "MiscClockViewInspector.h"
- #import <appkit/appkit.h>
- #import "MiscClockView.subproj/MiscClockView.h"
-
- @implementation MiscClockViewInspector
-
- - init
- {
- char buf[MAXPATHLEN + 1];
- id bundle;
-
- [super init];
- bundle = [NXBundle bundleForClass:[MiscClockView class]];
- [bundle getPath:buf forResource:"MiscClockViewInspector" ofType:"nib"];
- [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
- return self;
- }
-
- - (BOOL)wantsButtons { return YES; }
-
- - revert:sender
- {
- // Put string in text object
- [dayText setIntValue:[object weekday]];
- [dateText setIntValue:[object date]];
- [monthText setIntValue:[object month]];
- [yearText setIntValue:[object year]];
- [hourText setIntValue:[object hours]];
- [minuteText setIntValue:[object minutes]];
- [secondText setIntValue:[object seconds]];
- [militaryTime setState:[object militaryTime]];
- [showYear setState:[object showYear]];
-
- return [super revert:sender];
- }
-
- - ok:sender
- {
- [object setSeconds:[secondText intValue]];
- [object setMinutes:[minuteText intValue]];
- [object takeHoursFrom:hourText]; // to set the meridian right
- [object setDate:[dateText intValue]];
- [object setWeekday:[dayText intValue]];
- [object setMonth:[monthText intValue]];
- [object setYear:[yearText intValue]];
- [object setMilitaryTime:[militaryTime state]];
- [object setShowYear:[showYear state]];
-
-
- [object display];
- return [super ok:sender];
- }
-
- - setToCurrentTime:sender
- {
- struct timeval tp;
- struct timezone tzp;
- struct tm *tv;
-
- gettimeofday(&tp, &tzp);
- tv = localtime(&tp.tv_sec);
- [object setTime:tv];
- [object display];
- [self revert:self]; // load values into the text fields
- return [self ok:self]; // show change in the object
- }
-
- @end
-