home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / CursorCtl.p < prev    next >
Encoding:
Text File  |  1994-07-27  |  5.4 KB  |  138 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        CursorCtl.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1  ETO #15, MPW prerelease. July 22, 1994
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.     UNIT CursorCtl;
  23.     INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __USINGCURSORCTL__}
  27. {$SETC __USINGCURSORCTL__ := 1}
  28.  
  29. {$PUSH}
  30. {$ALIGN MAC68K}
  31.  
  32. TYPE
  33.  
  34. { Kinds of cursor supported by CursorCtl }
  35. Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  36.     ARROW_CURSOR);
  37.  
  38. acurPtr = ^Acur;
  39. acurHandle = ^acurPtr;
  40. Acur = RECORD
  41.     n: INTEGER;         {Number of cursors ("frames of film")}
  42.     index: INTEGER;     { Next frame to show <for internal use>}
  43.     frame1: INTEGER;    {'CURS' resource id for frame #1}
  44.     fill1: INTEGER;     {<for internal use>}
  45.     frame2: INTEGER;    {'CURS' resource id for frame #2}
  46.     fill2: INTEGER;     {<for internal use>}
  47.     frameN: INTEGER;    {'CURS' resource id for frame #N}
  48.     fillN: INTEGER;     {<for internal use>}
  49.     END;
  50.  
  51.  
  52.  
  53. PROCEDURE InitCursorCtl(newCursors: UNIV acurHandle);
  54. { Initialize the CursorCtl unit. This should be called once prior to calling
  55. RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  56. Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  57. 'acur' resource and the 'CURS' resources specified by the 'acur' resource
  58. ids.  If any of the resources cannot be loaded, the cursor will not be
  59. changed.
  60.  
  61. The 'acur' resource is assumed to either be in the currently running tool or
  62. application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  63. resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  64. the System file.
  65.  
  66. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  67. resource designated by the caller and it will be used instead of doing a
  68. GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  69. calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  70. the user the first time it is called.  However, the possible disadvantage of
  71. using this technique is that the resource memory allocated may have
  72. undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  73. has the advantage of causing the allocation at a specific time determined by
  74. the user.
  75.  
  76. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically,
  77. it changes each FrameN/fillN integer pair to a handle to the corresponding
  78. 'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  79. InitCursorCtl is called, the caller must guarantee NewCursors always points to
  80. a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  81. caller who wants to repeatly use multiple 'acur' resources during execution of
  82. their programs.
  83.  }
  84.  
  85. PROCEDURE RotateCursor(counter: LONGINT);
  86. { RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  87. animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  88. ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  89. or decrementing index maintained by the caller). A positive counter sequences
  90. forward through the cursors (e.g., it rotates the "beach ball" cursor
  91. clockwise), and a negative cursor sequences through the cursors backwards
  92. (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  93. RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  94.   It is assumed the cursor is visible from a prior Show_Cursor call.
  95.  }
  96.  
  97. PROCEDURE SpinCursor(increment: INTEGER);
  98. { SpinCursor is similar in function to RotateCursor, except that instead of
  99. passing a counter, an Increment is passed an added to a counter maintained
  100. here.  SpinCursor is provided for those users who do not happen to have a
  101. convenient counter handy but still want to use the spinning "beach ball"
  102. cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  103. increment sequences forward through the curos (rotating the "beach ball"
  104. cursor clockwise), and a negative increment sequences backward through the
  105. cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  106. for the increment resets the counter to zero.  Note, it is the increment, and
  107. not the value of the counter that determines the sequencing direction of the
  108. cursor (and hence the spin direction of the "beach ball" cursor).
  109.  }
  110.  
  111. PROCEDURE Hide_Cursor;
  112. { Hide the cursor if it is showing.This is this unit's call to the Mac
  113. HideCursor routine.Thus the Mac cursor level is decremented by one when this
  114. routine is called.
  115.  }
  116.  
  117. PROCEDURE Show_Cursor(cursorKind: Cursors);
  118. { Increment the cursor level, which may have been decremented by Hide_Cursor,
  119. and display the specified cursor if the level becomes 0 (it is never
  120. incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  121. one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  122. WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is
  123. done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just
  124. causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  125. there is already a grafPort set up pointed to by 0(A5).
  126.  }
  127.  
  128.  
  129. {$ALIGN RESET}
  130. {$POP}
  131.  
  132. {$ENDC}    { __USINGCURSORCTL__ }
  133.  
  134. {$IFC NOT UsingIncludes}
  135.     END.
  136. {$ENDC}
  137.  
  138.