ftp.nice.ch/peanuts/GeneralData/Documents/adobe/_NX_Clock/ClockView.h

This is ClockView.h in view mode; [Download] [Up]

/*
 * (C) 1990 by Adobe Systems Incorporated. All rights reserved.
 *
 * This file may be freely copied and redistributed as long as:
 *   1) This entire notice continues to be included in the file, 
 *   2) If the file has been modified in any way, a notice of such
 *      modification is conspicuously indicated.
 *
 * PostScript, Display PostScript, and Adobe are registered trademarks of
 * Adobe Systems Incorporated.
 * 
 * ************************************************************************
 * THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT
 * NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS
 * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR 
 * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY 
 * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, 
 * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR PARTICULAR PURPOSES AND NONINFINGEMENT OF THIRD PARTY RIGHTS.
 * ************************************************************************
 */

/*
 * ClockView.h
 *
 * This class handles the drawing of the clock and the moving of the alarm.
 * The clock face is drawn into a bitmap and then composited into the 
 * buffered window before drawing the hands. The hands are stored in the 
 * server as user paths. Each hand also has a graphic state associated 
 * with it. Before hand is drawn, its graphic state is installed and then 
 * rotated to its current angle and then the user path is rendered.
 *
 *	Most of the literals below are for drawing the clock face and the hands.
 */

#import <appkit/View.h>
#import <appkit/timer.h>
#import <math.h>

#define CLRVIEW			0.01
#define CLRCIRC			NX_BLACK

#define SIZENUMS		0.75
#define SIZEDASHES		0.90

#define WIDMIN			3.5	
#define CLRMIN			NX_WHITE	
#define LENMIN			(19.0/20.0)
#define DEGMIN			(-6.0)

#define WIDHOUR			6.0	
#define CLRHOUR			NX_WHITE	
#define LENHOUR			(14.0/15.0)
#define DEGHOUR		(-30.0)

#define CLRHANDS		NX_WHITE
#define CLRSECOND		NX_LTGRAY
#define CLRSHADOW		0.20
#define CLRALARMTOP	0.8
#define CLRALARMBOT	NX_DKGRAY

#define LNWIDSECOND	1.0
#define LNWIDHANDS		3.0

#define OFFSETHANDSX	1.0
#define OFFSETHANDSY	(-1.0)
#define OFFSETSHADX	2.0
#define OFFSETSHADY	(-2.0)

#define TICKSEC			(-360.0/60.0)	
#define TICKMIN			(TICKSEC/60.0)	
#define TICKHOUR		(TICKMIN/12.0)	

#define MAX_PTS			300
#define MAX_OPS			150

#define  MAX_PTS_HIT	12
#define  MAX_OPS_HIT	6

#define  HITSETTING		8

#define  RADIAN			(M_PI/180)

#define  ALARM		0
#define  HOUR		1
#define  MINUTE		2
#define  SHADOW		3
#define  SECOND		4

/*
 * This structure is used to hold the hit detection user path.
 * The infill operator is used which takes a user path and checks
 * to see whether any portion of it is covered by the
 * current  path. The user path passed in is a rectangle around
 * the mouse down location. The current path is the alarm hand.
 */
typedef struct _UPath {
	float 	* pts;
	int		num_pts;
	char		*ops;
	int		num_ops;
} UPath;

/*
 * The BOOL arguments specify whether to use gstates or not and
 * whether to use the userpaths stored in the server or send them 
 * with each drawing.
 */
@interface ClockView:View
{
	id		animatorId, bitmapId, displayTime;

	BOOL	gstatesOn, upathsServer;

	int		gstateHour, gstateMin, gstateSec, gstateShad,
			upathHour, upathMin, upathSec, upathAlarmTop, upathAlarmBot;
	
	float		angleHour, angleMin, angleSec, angleAlarm,
			totalTime, numIterations;

	UPath	hitPoint;
}

+ new;
- initializeHitPoint;

- free;

- setDisplayTime:anObject;
- toggleGstate:sender;
- toggleUpath:sender;

- drawFace;
- defineUPaths;
- defineGStates;

- tick:sender;

- sizeTo:(NXCoord)width :(NXCoord)height;

- setAlarm:(NXEvent *)event;
- setHitPoint:(const NXPoint *)p;
- (BOOL) isHit:(const NXPoint *) p;

- mouseDown:(NXEvent *)event;

- setStateAndDraw;
- drawSelf:(NXRect *)r :(int) count;

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.