home *** CD-ROM | disk | FTP | other *** search
-
- /* Generated by Interface Builder */
-
- #import "MyView.h"
- #include <dpsclient/wraps.h>
- #include <appkit/Application.h>
- #include <appkit/Pasteboard.h>
-
- @implementation MyView
-
- - copy:sender {
- id pb = [NXApp pasteboard]; /* global Pasteboard object */
- NXStream *st; /* stream to collect data in */
- char *data; /* actual data buffer */
- int length; /* length of data */
- int maxLength; /* (not used here) */
-
- // To see how to use the pasteboard see page 10-33 of
- // the SysRefMan
- // declare that we will supply a single type of data: PostScript
- [pb declareTypes:&NXPostScriptPboard num:1 owner:self];
-
- /* get a stream which writes to memory */
- st = NXOpenMemory( NULL, 0, NX_WRITEONLY );
-
- /* write PostScript code for this view into the stream */
- [self copyPSCodeInside:NULL to:st];
-
- /* get actual data buffer from stream */
- NXGetMemoryBuffer( st, &data, &length, &maxLength );
-
- /* write PostScript data to pasteboard */
- [pb writeType:NXPostScriptPboard data:data length:length];
-
- /* deallocate stream, including its buffer */
- NXCloseMemory( st, NX_FREEBUFFER );
-
- return self;
- }
-
- /* make this view accept first responder so it will understand copy */
- -(BOOL)acceptsFirstResponder
- {
- return (YES);
- }
-
- -resignFirstResponder
- {
- return self;
- }
-
-
- - drawSelf:(NXRect*)r :(int)c
- {
- PSsetgray(1.0);
- NXRectFill(r);
- PSsetgray(0.0);
- PSsetlinewidth(4);
- PSnewpath();
- PSmoveto(50.0, 50.0);
- PSlineto(200.0, 200.0);
- PSstroke();
- return self;
- }
-
-
-
- @end
-