home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / CSFinalHack Module / ESDemo.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-23  |  5.4 KB  |  183 lines

  1. /* -----------------------------------------------------------------------------
  2. ESDemo.h
  3.     
  4. ©1995-2000 Ammon Skidmore, Skidperfect Software Inc. http://www.skidperfect.com/
  5. ----------------------------------------------------------------------------- */
  6.  
  7. #ifndef __ESDemo__
  8. #define __ESDemo__
  9.  
  10.  
  11. #define toolOrOSTrap(trap) (trap & 0x0800) ? ToolTrap : OSTrap
  12. enum {
  13.     uppPopupMenuSelectProcInfo = kPascalStackBased
  14.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  15.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MenuHandle)))
  16.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  17.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  18.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  19. };
  20. typedef UniversalProcPtr PopupMenuSelectUPP;
  21. #define NewPopupMenuSelectProc(proc) (PopupMenuSelectUPP) \
  22.         NewRoutineDescriptor((ProcPtr)(proc), uppPopupMenuSelectProcInfo, GetCurrentISA())
  23.  
  24. #define CallPopupMenuSelectProc(proc, p1, p2, p3, p4) \
  25.         (long) CallUniversalProc((UniversalProcPtr)(proc), \
  26.         uppPopupMenuSelectProcInfo, p1, p2, p3, p4)
  27.  
  28. typedef UniversalProcPtr ButtonUPP;
  29. enum {
  30.     uppButtonProcInfo = kPascalStackBased
  31.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  32. };
  33. #define NewButtonProc(proc) (ButtonUPP) \
  34.         NewRoutineDescriptor((ProcPtr)(proc), uppButtonProcInfo, GetCurrentISA())
  35. #define CallButtonProc(proc) \
  36.         (Boolean) CallUniversalProc((UniversalProcPtr)(proc), \
  37.         uppButtonProcInfo)
  38.  
  39. typedef UniversalProcPtr DrawPictureUPP;
  40. enum {
  41.     uppDrawPictureProcInfo = kPascalStackBased
  42.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(PicHandle)))
  43.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Rect *)))
  44. };
  45. #define NewDrawPictureProc(proc) (DrawPictureUPP) \
  46.         NewRoutineDescriptor((ProcPtr)(proc), uppDrawPictureProcInfo, GetCurrentISA())
  47. #define CallDrawPictureProc(proc, p1, p2)    \
  48.         CallUniversalProc((UniversalProcPtr)(proc), \
  49.         uppDrawPictureProcInfo, p1, p2)
  50.  
  51. PopupMenuSelectUPP    gOldPopupMenuSelect, gPopupPatch=0L;
  52. ButtonUPP        gSaveButton, gButtonPatch=0L;
  53. DrawPictureUPP    gSaveDrawPicture, gDrawPicturePatch=0L;
  54. PicHandle        gDownArrow;
  55. Handle    gOldMDEF;
  56.  
  57.  
  58. #ifndef    FALSE
  59.     #define    FALSE    false
  60. #endif
  61. #ifndef    TRUE
  62.     #define    TRUE    true
  63. #endif
  64.  
  65. // NB: normally, control strip module resources have ids >= 256
  66. #define rIconSuiteId        (257)
  67. #define rPopupMenuID        (256)
  68. #define rHierMenuID            (255)    // (ammon 000730) hierarchial menus must have id <= 255
  69. #define rArrowPictID        (256)
  70. #define rMyStringsID        (256)
  71. #define    kTriangleWidth        (9)    // == width((*(**globH).myArrowPict)->picFrame);
  72. #define    kSmallIconWidth        (16)
  73. #define    kLargeIconWidth        (32)
  74.  
  75. enum
  76. {
  77.     kHelpStringIndex    = 1
  78. };
  79.  
  80. enum
  81. {
  82.     kBeepIfPPC            = 1,
  83.     kBeepOnSubmenu,
  84.     kMenuSep______________1,
  85.     kHiliteClicks,
  86.     kCustomBalloons,
  87.     kCheckKeyDowns,
  88.     kUseLargeIcon,
  89.     kMenuSep______________2,
  90.     kUseDragNDrop,
  91.     kDragFiles,
  92.     kDragTextClippings,
  93.     kMenuSep______________3,
  94.     kSafeFinderQuit1,
  95.     kSafeFinderQuit2,
  96.     kMenuSep______________4,
  97.     kCloseDown
  98. };
  99.  
  100. #define    kFinderType            'FNDR'
  101. #define    kSysCreator            'MACS'
  102.  
  103. // useful macros:
  104. #define width(rect)            ((rect).right - (rect).left)    // macro for rect width
  105. #define height(rect)        ((rect).bottom - (rect).top)    // macro for rect height
  106. #define PicFrame(what)        ((**MyGlobals.what).picFrame)    // macro for picture frame rect
  107. #define pstrcpy(dst, src)    (BlockMove((src), (dst), (src)[0] + 1))
  108.  
  109. #ifdef DEBUG_ON
  110.     #define    DebugErr(num)\
  111.         if (num)\
  112.         {\
  113.             Str255 s;\
  114.             \
  115.             NumToString(num, s);\
  116.             DebugStr(s);\
  117.         }
  118. #else
  119.     #define    DebugErr(num)
  120. #endif
  121.  
  122. #ifdef DEBUG_ON
  123.     #define    DebugErrStr(str)\
  124.         {\
  125.             DebugStr(str);\
  126.         }
  127. #else
  128.     #define    DebugErrStr(num)
  129. #endif
  130.  
  131. // our structures:
  132. #if PRAGMA_ALIGN_SUPPORTED
  133. #pragma options align=mac68k
  134. #endif
  135.  
  136. typedef struct
  137. {
  138.     Handle                    iconSuite;
  139.     MenuRef                    myMenuH;
  140.     MenuRef                    myHierMenuH;        // (ammon 000730) added hierarchial menus example
  141.     Handle                    myStrings;
  142.     PicHandle                myArrowPict;
  143.     Boolean                    hasExtensionsStrip;
  144.     Boolean                    useLargeIcon;
  145.     long                    currentFeatures;
  146.     // Drag globals:
  147.     DragTrackingHandlerUPP    myTrackingUPP;
  148.     DragReceiveHandlerUPP    myReceiveUPP;
  149.     Boolean                    canAcceptDrag, hasEntered;
  150.     Boolean                    acceptFiles, acceptText;
  151.     ModuleReference            myReferenceNum;    // required only for Extensions Strip
  152.     Rect                    myBox;            // required only for Control/Desktop Strip
  153. } MyGlobals, *MyGlobalPtr, **MyGlobalHandle;
  154.  
  155. #if PRAGMA_ALIGN_SUPPORTED
  156. #pragma options align=reset
  157. #endif
  158.  
  159. // our prototypes: //
  160. long sdevInit(WindowRef statusPort);
  161. void sdevClose(MyGlobalHandle myGlobals, WindowRef statusPort);
  162. long sdevClick(MyGlobalHandle myGlobals, const Rect    *statusRect, WindowRef statusPort);
  163. void sdevDraw(MyGlobalHandle myGlobals, Rect *statusRect, GrafPtr statusPort);
  164. void DrawMyIcon(MyGlobalHandle myGlobals, Boolean selected);
  165. /* The gestalt code: */
  166. Boolean    HasDragMgr(void);
  167. Boolean    HasExtensionsStrip(void);
  168. /* The apple event code: */
  169. OSErr FindAProcess(OSType typeToFind, OSType creatorToFind,
  170.                              ProcessSerialNumberPtr processSN,
  171.                              ProcessInfoRecPtr infoRecToFill);
  172. void QuitProcess (ProcessSerialNumber PSN, Boolean hasExtensionsStrip);
  173. /* The drag manager code */
  174. void InstallDragHandlers(WindowRef statusPort, MyGlobalHandle myH);
  175. void RemoveDragHandlers(WindowRef statusPort, MyGlobalHandle myH);
  176. Boolean IsMouseInMyBounds(MyGlobalHandle globH, WindowRef win, DragReference theDrag);
  177. pascal OSErr DragTrackingHandler(short message, WindowRef theWindow,
  178.                                     void *handlerRefCon, DragReference theDrag);
  179. pascal OSErr DragReceiveDropHandler(WindowRef theWindow, void *handlerRefCon,
  180.                                     DragReference theDrag);
  181.  
  182. #endif    //__ESDemo__
  183.