home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula
/
nebula.bin
/
SourceCode
/
Palettes
/
Clocks
/
Clock.h
< prev
next >
Wrap
Text File
|
1992-12-06
|
13KB
|
354 lines
//----------------------------------------------------------------------------------------------------
//
// Clock
//
// Inherits From: Control
//
// Declared In: Clock.h
//
// Class Description
//
// The Clock class models the general functionality of a basic clock
// with alarm capability. Subclasses will, for the most part, only need
// to implement drawing methods to support their unique graphical
// representation. Clock uses the 'tm' struct (defined in time.h) to
// maintain its time and date information. See time.h or the supporting
// file ClockConstantsAndTypes.h for information on valid tm struct
// values. In general, the underlying use of the tm struct is transparent.
// The class and instance methods setTimeAndDate, and macros defined
// in the constants and types file have been provided to work with tm if
// required.
//
// Display
// Clock is a graphical object, however, if you prefer to use only its
// functionality, display may be disabled. A Clock is drawn in the following
// manner. A background image or color is painted over the entirity of the
// bounds rect. A clock face image is then composited (centered) over this
// rect. If the alarm is enabled, an optional visible alarm indicator is displayed
// in the lower left hand corner of the rect. Then the time and date are drawn
// as appropriate for the particular style of clock (implemented by subclass).
// At any given time, a Clock may be asked to display its current clock time,
// its current alarm time, the current system time, or any other arbitrary time
// as specified by the user. These alternate displays will not affect the value
// of the current running clock (to resume display of the current running clock,
// use the resumeClockDisplay: method).
//
// Timer
// A clock instance does not have to be running. It may be used simply to
// display static time and date information. To start the timer, use the following;
// startFromSystem:, startFromSelf:, or startFromTime:. If startFromSystem: is
// used, the current clock time will always be the current system time. If the
// startFromSelf: method is used, the clock will start from its current clock setting
// (i.e. it will begin at 12:00 if the current clock time is 12:00). If startFromTime:
// is used, the timer begins from the time information passed to it in the tm struct.
// The stop: method will stop the current timer.
//
// Alarm
// An alarm mechanism is provided such that when the specified alarm setting
// is matched, the clock's action will be sent to the clock's target (optionally,
// an audible notification will be sounded). An alarm setting may be matched
// in one of three ways; by time only, by time and date, or by time and day of
// week. Setting the alarm does not enable it (you must explicitly enable via
// the enableAlarm: method). Also, an enabled alarm will have no affect if the
// timer is not running.
//
// Drag and Drop
// Clocks support drag and drop via the ClockPboardType. The following
// operations are provided: Holding down the command key or no key while
// dropping will copy both clock and alarm information. Holding down the
// alternate key while dropping will copy only alarm information. Holding down
// the control key while dropping will copy only clock information.
//
//
// Disclaimer
//
// You may freely copy, distribute and reuse this software and its
// associated documentation. I disclaim any warranty of any kind,
// expressed or implied, as to its fitness for any particular use.
//
//----------------------------------------------------------------------------------------------------
#import <appkit/appkit.h>
#import "ClockConstantsAndTypes.h"
@interface Clock : Control
{
struct tm clockTimeAndDate;
struct tm alarmTimeAndDate;
struct tm* displayTimeAndDate;
NXColor backgroundColor;
NXImage* backgroundImage;
NXImage* clockFace;
Sound* alarmSound;
DPSTimedEntry timedEntry;
int previousClock;
struct _flags
{
unsigned int wantsDisplay:1;
unsigned int wantsMilitaryTime:1;
unsigned int wantsSeconds:1;
unsigned int wantsDate:1;
unsigned int isDraggable:1;
unsigned int willAcceptDrop:1;
unsigned int isAlarmEnabled:1;
unsigned int wantsAlarmIndicator:1;
unsigned int activateOnAwake:2;
} flags;
struct _privateFlags
{
unsigned int timerMode:1;
unsigned int alarmMode:3;
unsigned int displayMode:2;
unsigned int backgroundIsColor:1;
unsigned int initRelativeTimerMode:1;
unsigned int alarmSleep:1;
} privateFlags;
}
//----------------------------------------------------------------------------------------------------
// Accessing Display Characteristics
//----------------------------------------------------------------------------------------------------
- backgroundImage: (NXImage*) anImage;
- backgroundColor: (NXColor) aColor;
- clockFace: (NXImage*) anImage;
- setDisplayEnabled: (BOOL) aFlag;
- wantsMilitaryTime: (BOOL) aFlag;
- wantsDate: (BOOL) aFlag;
- wantsSeconds: (BOOL) aFlag;
- (NXImage*) backgroundImage;
- (NXColor) backgroundColor;
- (NXImage*) clockFace;
- (BOOL) isDisplayEnabled;
- (BOOL) wantsMilitaryTime;
- (BOOL) wantsDate;
- (BOOL) wantsSeconds;
//----------------------------------------------------------------------------------------------------
// Accessing Clock Time and Date
//----------------------------------------------------------------------------------------------------
- clockTimeAndDate: (struct tm*) theClockTimeAndDate;
- clockSecond: (int) theSecond;
- clockMinute: (int) theMinute;
- clockHour: (int) theHour;
- clockDay: (int) theDay;
- clockMonth: (int) theMonth;
- clockYear: (int) theYear;
- clockWeekday: (int) theWeekday;
- (struct tm*) clockTimeAndDate;
- (int) clockSecond;
- (int) clockMinute;
- (int) clockHour;
- (int) clockDay;
- (int) clockMonth;
- (int) clockYear;
- (int) clockWeekday;
//----------------------------------------------------------------------------------------------------
// Setting, Enabling and Executing the Alarm
//----------------------------------------------------------------------------------------------------
- enableAlarm: (BOOL) aFlag;
- (BOOL) isAlarmEnabled;
- wantsAlarmIndicator: (BOOL) aFlag;
- (BOOL) wantsAlarmIndicator;
- setAlarmTime: (struct tm*) theTime;
- setAlarmTimeAndDate: (struct tm*) theTimeAndDate;
- setAlarmTimeAndWeekday: (struct tm*) theTimeAndWeekday;
- executeAlarmAction: sender;
//----------------------------------------------------------------------------------------------------
// Accessing Alarm Time and Date
//----------------------------------------------------------------------------------------------------
- alarmTimeAndDate: (struct tm*) theAlarmTimeAndDate;
- alarmSecond: (int) theSecond;
- alarmMinute: (int) theMinute;
- alarmHour: (int) theHour;
- alarmDay: (int) theDay;
- alarmMonth: (int) theMonth;
- alarmYear: (int) theYear;
- alarmWeekday: (int) theWeekday;
- (struct tm*) alarmTimeAndDate;
- (int) alarmSecond;
- (int) alarmMinute;
- (int) alarmHour;
- (int) alarmDay;
- (int) alarmMonth;
- (int) alarmYear;
- (int) alarmWeekday;
//----------------------------------------------------------------------------------------------------
// Accessing Alarm Sound
//----------------------------------------------------------------------------------------------------
- alarmSound: aSound;
- alarmSound;
//----------------------------------------------------------------------------------------------------
// Starting and Stopping the Clock
//----------------------------------------------------------------------------------------------------
- startFromSystem: sender;
- startFromSelf: sender;
- startFromTime: (struct tm*) theTime;
- stop: sender;
- activateOnAwake: (int) aFlag;
- (int) activateOnAwake;
//----------------------------------------------------------------------------------------------------
// Timer Status
//----------------------------------------------------------------------------------------------------
- (BOOL) isClockRunning;
//----------------------------------------------------------------------------------------------------
// Utility Methods
//----------------------------------------------------------------------------------------------------
+ setTimeAndDate:(struct tm*)time :(int)hour :(int)minute :(int)second :(int)month :(int)day :(int)year;
- setTimeAndDate:(struct tm*)time :(int)hour :(int)minute :(int)second :(int)month :(int)day :(int)year;
- (int) weekDay: (struct tm*) aTime;
//----------------------------------------------------------------------------------------------------
// Display Methods
//----------------------------------------------------------------------------------------------------
- showClockTime: sender;
- showSystemTime: sender;
- showAlarmTime: sender;
- showTime: (struct tm*) aTime;
- resumeClockDisplay: sender;
//----------------------------------------------------------------------------------------------------
// IB Action Methods
//----------------------------------------------------------------------------------------------------
- takeDisplayEnabledFlagFrom: sender;
- takeWantsSecondsFlagFrom: sender;
- takeWantsDateFlagFrom: sender;
- takeWantsMilitaryTimeFlagFrom: sender;
- takeIsDraggableFlagFrom: sender;
- takeWillAcceptDropFlagFrom: sender;
- takeEnableAlarmFlagFrom: sender;
- takeWantsAlarmIndicatorFlagFrom: sender;
- takeBackgroundColorFrom: sender;
- takeClockSecondIntValueFrom: sender;
- takeClockMinuteIntValueFrom: sender;
- takeClockHourIntValueFrom: sender;
- takeClockDayIntValueFrom: sender;
- takeClockMonthIntValueFrom: sender;
- takeClockYearIntValueFrom: sender;
- takeClockWeekdayIntValueFrom: sender;
- takeAlarmSecondIntValueFrom: sender;
- takeAlarmMinuteIntValueFrom: sender;
- takeAlarmHourIntValueFrom: sender;
- takeAlarmDayIntValueFrom: sender;
- takeAlarmMonthIntValueFrom: sender;
- takeAlarmYearIntValueFrom: sender;
- takeAlarmWeekdayIntValueFrom: sender;
- takeAlarmModeIntValueFrom: sender;
- incrementClockSecond: sender;
- incrementClockMinute: sender;
- incrementClockHour: sender;
- incrementClockDay: sender;
- incrementClockMonth: sender;
- incrementClockYear: sender;
- incrementClockWeekday: sender;
- decrementClockSecond: sender;
- decrementClockMinute: sender;
- decrementClockHour: sender;
- decrementClockDay: sender;
- decrementClockMonth: sender;
- decrementClockYear: sender;
- decrementClockWeekday: sender;
- incrementAlarmSecond: sender;
- incrementAlarmMinute: sender;
- incrementAlarmHour: sender;
- incrementAlarmDay: sender;
- incrementAlarmMonth: sender;
- incrementAlarmYear: sender;
- incrementAlarmWeekday: sender;
- decrementAlarmSecond: sender;
- decrementAlarmMinute: sender;
- decrementAlarmHour: sender;
- decrementAlarmDay: sender;
- decrementAlarmMonth: sender;
- decrementAlarmYear: sender;
- decrementAlarmWeekday: sender;
//----------------------------------------------------------------------------------------------------
// Draw Methods
//----------------------------------------------------------------------------------------------------
- drawBackground;
- drawClockFace;
- drawTime;
- drawDate;
- drawAlarmIndicator;
//----------------------------------------------------------------------------------------------------
// Drag and Drop Support
//----------------------------------------------------------------------------------------------------
- isDraggable: (BOOL) aFlag;
- willAcceptDrop: (BOOL) aFlag;
- (BOOL) isDraggable;
- (BOOL) willAcceptDrop;
- (BOOL)acceptsFirstMouse;
- mouseDown: (NXEvent*) theEvent;
- beginDragOperationFor: (NXEvent*) originalEvent nextEvent: (NXEvent*) nextEvent;
- (NXImage*) dragImage;
//----------------------------------------------------------------------------------------------------
// Clock Drag Operations
//----------------------------------------------------------------------------------------------------
- dragOperationCopy: pasteboardClock;
- dragOperationLink: pasteboardClock;
- dragOperationGeneric: pasteboardClock;
//----------------------------------------------------------------------------------------------------
// Pasteboard Methods
//----------------------------------------------------------------------------------------------------
- writeToPasteboard: aPasteboard;
- readFromPasteboard: aPasteboard;
//----------------------------------------------------------------------------------------------------
// Private Mode Accessors (made public for IB Inspectors)
//----------------------------------------------------------------------------------------------------
- (int) _timerMode;
- (int) _alarmMode;
- (int) _displayMode;
- (BOOL) _backgroundIsColor;
- _timerMode: (int) aMode;
- _alarmMode: (int) aMode;
- _backgroundIsColor: (BOOL)aFlag;
@end