home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / AppleScript for Acrobat plug-in / MAC / StamperMAC.c < prev   
Encoding:
C/C++ Source or Header  |  2000-06-24  |  3.1 KB  |  121 lines

  1. /******************************************************************************
  2.  
  3. StamperMac.c
  4.  
  5. This file is furnished to you by Adobe Systems Incorporated 
  6. under the terms of the Acrobat(r) Plug-ins Software 
  7. Development Kit License Agreement.
  8.  
  9. Copyright (C) 1994-1997, Adobe Systems Inc.  All Rights Reserved.
  10.  
  11.  
  12. Implementation of Macintosh-specific functions for the Stamper plug-in
  13.  
  14. ******************************************************************************/
  15.  
  16. #include <Resources.h>
  17. //#include <Sound.h>
  18. #include <ToolUtils.h>
  19. #include <Windows.h>
  20. #include "PIQuickdraw.h"
  21. #include "SafeResources.h"
  22.  
  23. #include "AVCalls.h"
  24. #include "MacCalls.h"
  25. #include "StampPr.h"
  26.  
  27. #define CURSStamperCursor            150
  28. #define SICNStamperToolIcon            150
  29. #define cicnStamperIcon                150
  30. #define sndStamperSound                150
  31.  
  32. AVCursor GetStamperCursor(void)
  33. {
  34.     return (AVCursor)SafeGetCursor(CURSStamperCursor);
  35. }
  36.  
  37. void *GetStamperToolButtonIcon(void)
  38. {
  39.     return (void *)SafeGetResource('SICN', SICNStamperToolIcon);
  40. }
  41.  
  42. void *GetStamperMenuItemIcon(void)
  43. {
  44.     return (void *)SafeGetResource('SICN', SICNStamperToolIcon);
  45. }
  46.  
  47. /*void StampSound(void)
  48. {
  49.     Handle sndHdl = SafeGetResource('snd ', sndStamperSound);
  50.     if (sndHdl){
  51.         #if __MWERKS__
  52.         SndPlay(NULL, (SndListHandle)sndHdl, false);
  53.         #else
  54.         SndPlay(NULL, sndHdl, false);
  55.         #endif
  56.     }
  57. }*/
  58.  
  59. #define KNOBSIZE 5
  60.  
  61. static void DoForEachKnob(AVPageView pageView, const AVRect *annotRect,
  62.     void (*func)(const Rect *knobRect))
  63. {
  64.     Rect qdRect;
  65.     GrafPtr port;
  66.     AVRect aperture;
  67.     Rect knobRect;
  68.     
  69.     AVRectToRect(annotRect, &qdRect);
  70.     
  71.     /* AVPageViewAcquireMachinePort returns the pageView's
  72.     ** GrafPort.
  73.     */
  74.     port = (GrafPtr)AVPageViewAcquireMachinePort(pageView);
  75.  
  76.     /* The GrafPort's origin is located at the top left corner of the
  77.     ** AVPageView's gray area.  Since the AVPageView's aperture
  78.     ** is expressed in the coordinate space where the page's crop
  79.     ** box's origin is (0, 0), the QD coordinates of the top left
  80.     ** corner of the crop box are the inverse of the top left
  81.     ** corner of the aperture.
  82.     */
  83.     AVPageViewGetAperture(pageView, &aperture);
  84.     OffsetRect(&qdRect, -aperture.left, -aperture.top);
  85.     
  86.     SetRect(&knobRect, qdRect.left, qdRect.top, qdRect.left + KNOBSIZE,
  87.         qdRect.top + KNOBSIZE);
  88.     (*func)(&knobRect);
  89.     SetRect(&knobRect, qdRect.right - KNOBSIZE, qdRect.top, qdRect.right,
  90.         qdRect.top + KNOBSIZE);
  91.     (*func)(&knobRect);
  92.     SetRect(&knobRect, qdRect.left, qdRect.bottom - KNOBSIZE, qdRect.left + KNOBSIZE,
  93.         qdRect.bottom);
  94.     (*func)(&knobRect);
  95.     SetRect(&knobRect, qdRect.right - KNOBSIZE, qdRect.bottom - KNOBSIZE, qdRect.right,
  96.         qdRect.bottom);
  97.     (*func)(&knobRect);
  98.  
  99.     AVPageViewReleaseMachinePort(pageView, port);
  100. }
  101.  
  102. static void drawKnob(const Rect *knobRect)
  103. {
  104.     FillRect(knobRect, (ConstPatternParam)&qd.black);
  105. }
  106.  
  107. static void invalidateKnob(const Rect *knobRect)
  108. {
  109.     InvalRect(knobRect);
  110. }
  111.     
  112. void DrawKnobs(AVPageView pageView, const AVRect *annotRect)
  113. {
  114.     DoForEachKnob(pageView, annotRect, &drawKnob);
  115. }
  116.  
  117. void EraseKnobs(AVPageView pageView, const AVRect *annotRect)
  118. {
  119.     DoForEachKnob(pageView, annotRect, &invalidateKnob);
  120. }
  121.