home *** CD-ROM | disk | FTP | other *** search
- Objective:
- Learn how to copy postscript into the pastboard.
-
- Terms:
- responder - the view on the screen that is responding to messages.
- In this case the correct plot view must be selected with the mouse
- just before the copy method has been used.
- pasteboard - the structure used to copy text, graphics and sound
- between different NextStep applications.
-
- Complexity:
- 4 methods
- 2 calls to NX library
-
- Discussion:
- To use this you have to click on the view you would like to copy.
- It will then become the FirstResponder. You then select the copy
- command and the postscript code that did the drawing will be copied
- to the pastboard. You can then copy the code to WriteNow, Draw or
- even YAP program.
-
- Method:
- Add the following code to the line program:
- -----------------------------------------------
- - 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;
- }
- -----------------------------------------------
- Connect the Edit/Copy menu to the FirstResponder Icon in the lower left
- window of the Interface Builder.
-
- Summary:
-
-
-