home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula
/
nebula.bin
/
SourceCode
/
Classes
/
Gauges
/
Gauge.h
< prev
next >
Wrap
Text File
|
1993-01-19
|
6KB
|
189 lines
/**********************************************************************/
/* Gauge super class
/* Subclasses need to override
/* drawself should assume that the bitmap is correct
/* refreshBackground: should call display so we see immediately
/* sizeTo:: if they alter orientation
/*
/* Rev 0.x Works but other objects must look for overflow (subclass of View)
/* Rev 0.9 First revision that I started log for.
/* 11/24/89 Made this a control so it could do target action (per DS)
/*
/*
/* will notify target (via target/action) of any overflow
/* not all subclasses will use the title capabillity
/*
/*
/* for speed:
/* turn off autoscaling
/* set modulus tic = 0.0
/*
/* Bugs:
/* Overflow is not detected if the value is set and then scale changed
/* no way to autoscale and still have a cap
/*
/* AutoScaling:
/* Autoscaling with no labels will cause the number of tics to change.
/* when blowing up or shrinking tic mark values otherwise...
/*
/* This will rescale the tic marks or start values under thse rules
/* Underrun:
/* if .aThreshLo > 0.0
/* then move low point so we are centered
/* else if aThreshHi < 1.0
/* then rescale tic marks to blow up
/*
/* Overrun
/* if .aThreshHi < 1.0
/* then move the tic marks to shrink
/* else if .aThreshLo > 0.0
/* then move up low so this is centered
/*
/*
/**********************************************************************/
/* Generated by Interface Builder */
#import <appkit/Control.h>
#import <appkit/Box.h> /* border styles */
#import <appkit/Font.h> /* font object commands */
#define GAUGEMAX ((GaugeDat.ticSize*(GaugeDat.numMajor-1))+GaugeDat.startValue)
#define GAUGESIZE (GaugeDat.ticSize*(GaugeDat.numMajor-1))
#define GAUGEHI ((GAUGESIZE*GaugeDat.aThreshHi)+GaugeDat.startValue)
#define GAUGELO ((GAUGESIZE*GaugeDat.aThreshLo)+GaugeDat.startValue)
#define CONDITIONAL_REFRESH \
if (GaugeFlags.autoRenderBit) [self refreshBackground:self]
#define FancyRect(tR)\
if (GaugeFlags.borderType == NX_LINE)\
NXFrameRect(tR);\
else if (GaugeFlags.borderType == NX_BEZEL)\
NXDrawButton(tR, (const NXRect * ) tR);\
else if (GaugeFlags.borderType == NX_RIDGE)\
NXDrawGroove(tR, (const NXRect *) tR);\
#define FancyBack(tR)\
if (GaugeFlags.borderType == NX_LINE)\
NXFrameRect(tR);\
else if (GaugeFlags.borderType == NX_BEZEL)\
NXDrawGrayBezel(tR, (const NXRect *) tR);\
else if (GaugeFlags.borderType == NX_RIDGE)\
NXDrawGroove(tR, (const NXRect *) tR);\
@interface Gauge:Control
{
struct _GaugeFlags{
unsigned int titleOn:1; /* display title ? */
unsigned int ticsOn:1; /* display tic marks */
unsigned int labelTicsOn:1; /* show values of the major tics */
unsigned int autoScaleOn:1; /* autoscale on overrun or underrun */
unsigned int jumpChange:1; /* jump or smooth change */
unsigned int overFlow:1; /* is data out of range */
unsigned int autoRenderBit:1;/* re-render bitmap on all changes? */
unsigned int dummy:9; /* place holder for future */
int borderType; /* what kind of border */
/* NX_NOBORDER, NX_LINE, NX_BEZEL, NX_RIDGE */
} GaugeFlags;
struct _GaugeDat{
float backGray; /* backdrop gray (around gauge) */
float faceGray; /* gray of gauge background */
float ticGray;
float textGray;
float ptGray;
id bm; /* off screen window */
int bmgState; /* gstate of the off screen window */
double startValue; /* base value of gauge */
double ticSize; /* the size of a major tic mark */
double value;
int numMajor; /* number of tic marks, including base mark */
int numMinor; /* minor tics per major tic */
double ticQuanta; /* quanta of tick (0.0) = any */
/* forces tic size */
double aThreshHi; /* threshold to auto scale */
double aThreshLo; /* % of scale */
char *labelTicPat; /* fprintf pattern for the labels for tics */
char *ticFontName; /* the font of the tic labels */
char *title; /* the title string */
char *titleFontName; /* name of font for title string */
} GaugeDat;
id target;
SEL action;
}
/**********************************************************************/
/* Factory Methods
/**********************************************************************/
+ newFrame: (NXRect *) r;
/**********************************************************************/
/* Public Methods
/**********************************************************************/
- changeBMSize; /* resizes the bitmap to our current bounds size */
- refreshBackground:sender; /* overriden gens [self display]*/
/*____________________________________________________________________*/
- setBackGray:(float)bg Face:(float)fg Tic:(float)tg Text:(float)teg
Point:(float)pg;
- setBackgroundGray:(float)tC;
- setFaceGray:(float)tc;
- setTicGray:(float)tC;
- setTextGray:(float)tC;
- setPointerGray:(float)tC;
- (float)backgroundGray;
- (float)faceGray;
- (float)ticGray;
- (float)textGray;
- (float)pointerGray;
/*____________________________________________________________________*/
- setLowThresh:(double)lT HighThresh:(double)hT AndQuanta:(double)qT;
- setTic:(double)sTic AndStart:(double)aStart;
- setTicSize:(double)sTic;
- setStartValue:(double)aStart;
- setDoubleValue:(double)aD;
- setFloatValue:(float)aF;
- takeDoubleValueFrom:sender;
- takeFloatValueFrom:sender;
- (double)maxValue;
- (double)ticSize;
- (double)startValue;
- (double)doubleValue;
- (float)floatValue;
- (BOOL)overFlowDetected;
/*____________________________________________________________________*/
- setMajorTics:(int)nTic;
- setMinorTics:(int)nTic;
- setTitle:(char *)nTitle;
- (int)majorTics;
- (int)minorTics;
- (char *)title;
/*____________________________________________________________________*/
- setTitleEnable:(BOOL)aFlag;
- setTicsEnable:(BOOL)aFlag;
- setLabelTicsEnable:(BOOL)aFlag;
- setAutoScaleEnable:(BOOL)aFlag;
- setJumpChangeEnable:(BOOL)aFlag;
- setBorderType:(int)aType;
- (BOOL)titleEnabled;
- (BOOL)ticsEnabled;
- (BOOL)labelTicsEnabled;
- (BOOL)autoScaleEnabled;
- (BOOL)jumpChangeEnabled;
- (int)borderType;
/*____________________________________________________________________*/
- setTarget:aTarget;
- setAction:(SEL)anAction;
@end