home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / Misc / HigherEducationMailbox.mbox / Archives_provide_val_.attach / May_91 / ib.249 < prev    next >
Text File  |  1991-05-21  |  2KB  |  36 lines

  1. cursor ib
  2.  
  3. Q:  How can I define a cursor in IB?  Just like for bitmaps, I do
  4.  
  5.     myCursor = [Cursor findBitmapFor:"myCursor"];
  6.  
  7. and get back the bitmap; however, the bitmap is an instance of Bitmap and not of the Cursor class, so the [myCursor set] message results in an "Unrecognized Method" error.
  8.  
  9. A:  This bug has been fixed in release 2.0.  If you're still running release 1.0, read on.
  10.  
  11. The problem arises when IB creates bitmaps from the .nib file being loaded; the bitmaps are created as instances of Bitmap.  When you invoke "findBitmapFor:," if the named bitmap already exists, you simply get a pointer to it.  Unfortunately, when you call findBitmapFor: for Cursor, the same thing happens and you get a pointer to an instance of Bitmap.  Cursor should override findBitmapFor: and do the right thing.
  12.  
  13. Two workarounds: One is to put the image in the __TIFF segment of your MachO,
  14. rather than entering the image into your .nib file, and use newFromMachO: to read it in.  Change your Makefile.preamble to create the new segment.
  15.  
  16. The other is to leave the Bitmap in your .nib file, and write the image into a Cursor object as follows.  This way preserves the same Makefile(s) but at the expense of using additional memory for the Cursor object.
  17.  
  18.   {
  19.      id theBitmap, myCursor;
  20.      NXPoint zeropoint = {0.0, 0.0};
  21.  
  22.      theBitmap = [Bitmap findBitmapFor:"myCursor"];
  23.      myCursor = [Cursor new];
  24.      [myCursor lockFocus];
  25.      [theBitmap composite:NX_COPY toPoint:&zeropoint];
  26.      [myCursor unlockFocus];
  27.    }
  28.  
  29.  
  30. QA249
  31.  
  32. Valid for 1.0
  33. Not Valid for 2.0
  34.  
  35.  
  36.