home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / wfimage / src / waveforms_lib.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-13  |  6.2 KB  |  186 lines

  1. /*
  2. **  waveforms_lib.c
  3. **
  4. **  Contains the raiseClass() and dropClass() routines for
  5. **  the waveforms.image
  6. **
  7. **  Since this image class will be made into a shared library later,
  8. **  these routines will be renamed to UserLibInit() and UserLibCleanup().
  9. **
  10. **  © Copyright 2000 stranded UFO productions. All Rights Reserved.
  11. **  Written by Paul Juhasz.
  12. **
  13. */
  14.  
  15. #include "waveforms.h"
  16. #include "waveforms_rev.h"
  17. #include "waveforms_protos.h"
  18.  
  19. #undef  SysBase
  20. #undef  GfxBase
  21. #undef  IntuitionBase
  22. #undef  UtilityBase
  23.  
  24. #define SysBase                  cb->cb_SysBase
  25. #define GfxBase                  cb->cb_GfxBase
  26. #define IntuitionBase            cb->cb_IntuitionBase
  27. #define UtilityBase              cb->cb_UtilityBase
  28.  
  29. #ifdef DOUBLEMATH
  30. #define MathIeeeDoubBasBase      cb->cb_MathIeeeDoubBasBase
  31. #define MathIeeeDoubTransBase    cb->cb_MathIeeeDoubTransBase
  32. #endif /* DOUBLEMATH */
  33.  
  34.  
  35. /****** waveforms.image/--datasheet-- ***********************************************
  36. *
  37. *    NAME
  38. *       waveforms.image--Audio Waveforms display images.                 (V0)
  39. *
  40. *    SUPERCLASS
  41. *       imageclass
  42. *
  43. *    DESCRIPTION
  44. *       The waveforms.image class provides a selectable waveform image display.
  45. *
  46. *    METHODS
  47. *       OM_NEW--Create the waveforms.  Passed to superclass, then OM_SET.
  48. *
  49. *       OM_SET--Set object attributes.  Passed to superclass first.
  50. *
  51. *       OM_GET--Get object attributes.  Passed to superclass first.
  52. *
  53. *       OM_UPDATE--Set object notification attributes.  Passed to superclass
  54. *           first.
  55. *
  56. *       IM_DRAW--Renders the images.  Overrides the superclass.
  57. *
  58. *       All other methods are passed to the superclass, including OM_DISPOSE.
  59. *
  60. *    ATTRIBUTES
  61. *
  62. *       SYSIA_DrawInfo (struct DrawInfo *) -- Contains important pen                 IS
  63. *           information.  This is required if IA_BGPen and IA_FGPen are
  64. *           not specified.
  65. *
  66. *       IA_Pens -- pointer to UWORD pens[]                                           IS
  67. *
  68. *       IA_FGPen (LONG) -- Pen to use to draw the hilite box outline or BLOCKPEN.    IS
  69. *
  70. *       IA_BGPen (LONG) -- Pen to use to draw the shadow box outline or DETAILPEN.   IS
  71. *
  72. *       IA_Width (WORD) -- Width of the image - def 64 pixels.                       IS
  73. *
  74. *       IA_Height (WORD) -- Height of the image - def 64 pixels.                     IS
  75. *
  76. *
  77. *    Private Tags:
  78. *
  79. *       WFI_WaveType (LONG) -- Which of the 5 types of waveforms is used.            ISG
  80. *
  81. *              WF_SINE_WAVE         0
  82. *              WF_TRIANGULAR_WAVE   1
  83. *              WF_RAMPUP_WAVE       2
  84. *              WF_RAMPDOWN_WAVE     3
  85. *              WF_SQUARE_WAVE       4
  86. *
  87. *       WFI_WaveShape (LONG) -- Pulse width for square wave only. Values can be      ISG
  88. *                                             from -98 to +98.
  89. *
  90. *       WFI_Outline (LONG) -- Draw the wave either as WF_SOLID_DISPLAY               ISG
  91. *                                                  or as WF_DOTTED_DISPLAY
  92. *
  93. *       WFI_BoxFrame (LONG) -- Draw a box frame around the graphic or none           IS
  94. *                                   the graphic will be adjusted to fit inside
  95. *
  96. *       WFI_OsciPen (WORD) -- Pen to use to draw the 'oscilloscope screen'           ISG
  97. *                                   background.  If -1 is specified then
  98. *                                   BARBLOCKPEN is used.
  99. *
  100. *       WFI_WavePen (WORD) -- Pen to use to draw the wave.  If -1 is                 IS
  101. *                                   specified then BARDETAILPEN is used.
  102. *
  103. *       WFI_ZeroPen (WORD) -- Draw the zero line using this colour.  The             ISG
  104. *                                   zero line is only drawn when the option
  105. *                                   WF_DOTTED_DISPLAY is selected.  Defaults
  106. *                                   to WF_OsciPen for 'invisible' line or to
  107. *                                   BARTRIMPEN if -1 is specified.
  108. *
  109. *
  110. *******************************************************************************
  111. *
  112. *  P. Juhasz
  113. *
  114. */
  115.  
  116.  
  117. UBYTE *verstring=VERSTRING;
  118.  
  119.  
  120.  
  121. /*______________________________________________________________________________________
  122.  |                                                                                      |
  123.  |    Create a new waveform.image public class                                          |
  124.  |______________________________________________________________________________________*/
  125.  
  126. BOOL __saveds __asm raiseClass( REGISTER __a0 struct WFIBase *cb )
  127. {
  128.    Class            *cl = NULL;
  129.  
  130.    SysBase = (*((VOID **)4));
  131.    if (( SysBase )->lib_Version >= LIBRARY_VER ) {
  132.       if ( IntuitionBase = OpenLibrary( "intuition.library", LIBRARY_VER )) {
  133.          if ( GfxBase = OpenLibrary( "graphics.library", LIBRARY_VER )) {
  134.             if ( UtilityBase = OpenLibrary( "utility.library", LIBRARY_VER )) {
  135.  
  136. #ifdef DOUBLEMATH
  137.                if ( MathIeeeDoubBasBase = OpenLibrary( "mathieeedoubbas.library", LIBRARY_VER )) {
  138.                   if ( MathIeeeDoubTransBase = OpenLibrary( "mathieeedoubtrans.library", LIBRARY_VER )) {
  139. #endif /* DOUBLEMATH */
  140.  
  141.                      if ( cl = MakeClass( "waveformiclass", IMAGECLASS, NULL,
  142.                                           sizeof( struct waveformData ), 0 )) {
  143.                         cl->cl_Dispatcher.h_SubEntry  = NULL;
  144.                         cl->cl_Dispatcher.h_Entry     = ( HOOKFUNC )dispatchWFI;
  145.                         cl->cl_Dispatcher.h_Data      = (VOID *)cb;
  146.                         cl->cl_UserData               = getreg( REG_A4 );
  147.                         AddClass((struct IClass *)cl );
  148.                      }
  149. #ifdef DOUBLEMATH
  150.                   }
  151.                }
  152. #endif /* DOUBLEMATH */
  153.             }
  154.          }
  155.       }
  156.    }
  157.    cb->cb_Lib.cl_Class = cl;
  158.    return((BOOL)( cl != NULL ));
  159. }
  160.  
  161.  
  162. VOID __saveds __asm dropClass( REGISTER __a0 struct WFIBase *cb )
  163. {
  164.    Class            *cl = cb->cb_Lib.cl_Class;
  165.  
  166.    if ( cl ) {
  167.       RemoveClass((struct IClass *)cl );
  168.       if ( FreeClass( cl ))         cb->cb_Lib.cl_Class = NULL;
  169.    }
  170.    if ( SysBase ) {
  171.  
  172. #ifdef DOUBLEMATH
  173.       CloseLibrary((struct Library *)MathIeeeDoubTransBase );
  174.       CloseLibrary((struct Library *)MathIeeeDoubBasBase );
  175. #endif /* DOUBLEMATH */
  176.  
  177.       CloseLibrary((struct Library *)UtilityBase );
  178.       CloseLibrary((struct Library *)GfxBase );
  179.       CloseLibrary((struct Library *)IntuitionBase );
  180.       SysBase = NULL;
  181.    }
  182. }
  183.  
  184.  
  185.  
  186.