home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Libraries / WASTE 1.1a4 / Demo Source / WEDemoPictures.p < prev    next >
Encoding:
Text File  |  1994-10-30  |  1.8 KB  |  76 lines  |  [TEXT/PJMM]

  1. unit DemoPictures;
  2.  
  3. { WASTE DEMO PROJECT: }
  4. { Object Handlers for embedded pictures }
  5.  
  6. { Copyright © 1993-1994 Merzwaren }
  7. { All Rights Reserved }
  8.  
  9. interface
  10.     uses
  11.         DemoIntf;
  12.  
  13.     function HandleNewPicture (var defaultObjectSize: Point;
  14.                                     objectRef: WEObjectReference): OSErr;
  15.     function HandleDisposePicture (objectRef: WEObjectReference): OSErr;
  16.     function HandleDrawPicture (destRect: Rect;
  17.                                     objectRef: WEObjectReference): OSErr;
  18.     function HandleDrawSound (destRect: Rect;
  19.                                     objectRef: WEObjectReference): OSErr;
  20.  
  21. implementation
  22.  
  23.     function HandleNewPicture (var defaultObjectSize: Point;
  24.                                     objectRef: WEObjectReference): OSErr;
  25.         var
  26.             thePicture: PicHandle;
  27.             frame: Rect;
  28.     begin
  29.  
  30. { get handle to object data (in this case, a picture handle) }
  31.         thePicture := PicHandle(WEGetObjectDataHandle(objectRef));
  32.  
  33. { figure out the default object size by looking at the picFrame record }
  34.         frame := thePicture^^.picFrame;
  35.         OffsetRect(frame, -frame.left, -frame.top);
  36.         defaultObjectSize := frame.botRight;
  37.  
  38. { return error code }
  39.         HandleNewPicture := noErr;
  40.  
  41.     end;  { HandleNewPicture }
  42.  
  43.     function HandleDisposePicture (objectRef: WEObjectReference): OSErr;
  44.         var
  45.             thePicture: PicHandle;
  46.     begin
  47.  
  48. { get handle to object data (in this case, a picture handle) }
  49.         thePicture := PicHandle(WEGetObjectDataHandle(objectRef));
  50.  
  51. { kill the picture }
  52.         KillPicture(thePicture);
  53.  
  54. { return error code }
  55.         HandleDisposePicture := MemError;
  56.  
  57.     end;  { HandleDisposePicture }
  58.  
  59.     function HandleDrawPicture (destRect: Rect;
  60.                                     objectRef: WEObjectReference): OSErr;
  61.         var
  62.             thePicture: PicHandle;
  63.     begin
  64.  
  65. { get handle to object data (in this case, a picture handle) }
  66.         thePicture := PicHandle(WEGetObjectDataHandle(objectRef));
  67.  
  68. { draw the picture }
  69.         DrawPicture(thePicture, destRect);
  70.  
  71. { return error code }
  72.         HandleDrawPicture := noErr;
  73.  
  74.     end;  { HandleDrawPicture }
  75.  
  76. end.