home *** CD-ROM | disk | FTP | other *** search
-
- /* Generated by Interface Builder */
-
- #import "UPView.h"
-
- @implementation UPView
-
- - initFrame:(const NXRect *)theFrame
- {
- [super initFrame:theFrame];
- sqSide=100.; // and length of a side
- NXSetRect(&sqRect,bounds.size.width/2.0,bounds.size.height/2.0,3*sqSide,sqSide);
- backgroundGray=NX_WHITE; // init the background gray level
- userPath = newUserPath(); // create a user path
-
- return self;
- }
-
- - (float)backgroundGray
- {
- return backgroundGray;
- }
-
- - takeBackgroundGrayFrom:sender
- {
- backgroundGray = [sender floatValue]; // read the background gray slider
- [self display];
- return self;
- }
-
- - drawSelf:(const NXRect *)r :(int)c
- {
- int i, length = sqSide/8;
-
- /* Draw background */
- PSsetgray(backgroundGray);
- NXRectFill(&bounds);
- /* Start Drawing */
- PSsetgray(NX_BLACK);
- PSsetlinewidth(5.0);
-
- beginUserPath(userPath, YES); // start generating a stroke path with cache (boolean)
-
- UPmoveto(userPath, sqRect.origin.x, sqRect.origin.y);
- for(i = 0; i<12; i++){
- UPrlineto(userPath, length, 0.0); // update bounding box at every step
- UPrlineto(userPath,0.0, 8*length);
- UPrlineto(userPath, length,0.0);
- UPrlineto(userPath,0.0,-8*length);
- }
-
- endUserPath(userPath, dps_ustroke); // specify the stroke type
- sendUserPath(userPath); // send the path to server
-
- return self;
- }
-
- - mouseDownAction:(NXPoint *)currentLocation
- {
- [self mouseDraggedAction:currentLocation]; //now do same as when dragging
- return self;
- }
-
- - mouseDraggedAction:(NXPoint *)currentLocation
- {
- xOffset = sqRect.size.width/2; // set the offsets for movement wrt the center
- yOffset = sqRect.size.height/2; // of drawing
- sqRect.origin.x = currentLocation->x - xOffset; // new x and y locations are center
- sqRect.origin.y = currentLocation->y - yOffset; // of drawing
- [self display];
- return self;
- }
-
- - free
- {
- freeUserPath(userPath);
- return [super free];
- }
-
- @end
-