home *** CD-ROM | disk | FTP | other *** search
-
- /* Generated by Interface Builder */
-
- #import "PlotView.h"
- #import <dpsclient/wraps.h>
- #import <appkit/Control.h>
- #import "plotview.h" /* pswrap stuff */
- #import <stdlib.h> /* for malloc and free */
- #import <strings.h> /* string handling functions */
-
-
- @implementation PlotView
-
- +newFrame:(const NXRect *)f
- {
- int i;
- self = [super newFrame:f];
- createPSDefs(); /* init up the definitions for PS */
- slope = DEFAULT_SLOPE;
- XIntercept = DEFAULT_XINTERCEPT;
- leftBorder = 40.0;
- bottomBorder = 40.0;
- rightBorder = 10.0;
- topBorder = 10.0;
-
- plotArea.origin.x = leftBorder;
- plotArea.origin.y = bottomBorder;
- plotArea.size.width = bounds.size.width - leftBorder - rightBorder;
- plotArea.size.height = bounds.size.height - bottomBorder - topBorder;
-
- return self;
- }
-
- // target/action methods
-
- - slopeSlider:sender
- {
- slope = [sender floatValue];
- [self display];
- return self;
- }
-
- - XInterceptSlider:sender
- {
- XIntercept = [sender floatValue];
- [self display];
- return self;
- }
-
- - drawSelf:(NXRect*)r :(int)c
- {
- NXEraseRect(&bounds);
- PSDrawAxis(NX_DKGRAY, leftBorder, bottomBorder, plotArea.size.width, plotArea.size.height);
- // translate the origin to be offset by the left and bottom border
- PStranslate(plotArea.origin.x, plotArea.origin.y);
- PSsetgray(NX_BLACK);
- PSsetlinewidth(5.0);
- PSnewpath();
- PSmoveto(0.0, -XIntercept);
- PSlineto(plotArea.size.width, slope*plotArea.size.width - XIntercept);
- PSstroke();
- return self;
- }
-
-
- @end
-