This is MiscClockViewInspector.m in view mode; [Download] [Up]
//
// MiscClockViewInspector.m -- a simple view class for displaying date/time
// Written by Scott Anguish Copyright (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]];
[hiddenSwitch setState:[object isHidden]];
return [super revert:sender];
}
- ok:sender
{
[object setMilitaryTime:[militaryTime state]];
[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 setShowYear:[showYear state]];
[object setHide:[hiddenSwitch state]];
[object display];
return [super ok:sender];
}
- setToCurrentTime:sender
{
struct timeval tp;
struct timezone tzp;
struct tm *tv;
BOOL militaryTimeState;
gettimeofday(&tp, &tzp);
tv = localtime(&tp.tv_sec);
[object setTime:tv];
[object display];
militaryTimeState = [militaryTime state]; // buffer militaryTime
[self revert:self]; // load values into the text fields
[militaryTime setState:militaryTimeState]; // redisoplay militaryTime
return [self ok:self]; // show change in the object
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.