
#import "MyView.h"

#import <appkit/Form.h>
#import <appkit/Slider.h>
#include <dpsclient/wraps.h>

@implementation MyView

- initFrame:(const NXRect *)frameRect
{
    [super initFrame:frameRect];
    foreground = NX_BLACK;
    background = NX_WHITE;
    aRectangle.origin.x = 120.0;
    aRectangle.origin.y = 50.0;
    aRectangle.size.width = 200.0;
    aRectangle.size.height = 50.0;
    return self;
}

- setBgByForm:sender
{
    background = [sender floatValueAt:1];
    [bgSlider setFloatValue:background];
    [self display];
    return self;
}

- setBgBySlider:sender
{
    background = [sender floatValue];
    [myForm setFloatValue:background at:1];
    [self display];
    return self;
}

- setFgByForm:sender
{
    foreground = [sender floatValueAt:0];
    [fgSlider setFloatValue:foreground];
    [self display];
    return self;
}

- setFgBySlider:sender
{
    foreground = [sender floatValue];
    [myForm setFloatValue:foreground at:0];
    [self display];
    return self;
}

- drawSelf:(const NXRect *)rects :(int)rectCount
{
    int		i;
    
    PSsetgray(background);
    for (i = (rectCount > 1) ? 1 : 0; i < rectCount; i++) {
	NXRectFill(&rects[i]);
    }
    PSsetgray(foreground);
    NXRectFill(&aRectangle);
    PSmoveto(220, 120);
    PSlineto(300, 200);
    PSlineto(220, 280);
    PSlineto(140, 200);
    PSfill();
    return self;
}
@end
