home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Programming / MR_Classes / Dev / Source / palette / LibInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-11  |  2.1 KB  |  94 lines

  1. //#define DEBUG
  2. #include <debug.h>
  3. #include <exec/types.h>
  4. #include <intuition/classes.h>
  5. #include <dos.h>
  6.  
  7. #include <proto/exec.h>
  8. #include <proto/intuition.h>
  9. #include <proto/utility.h>
  10. #include <proto/locale.h>
  11. #include <clib/alib_protos.h>
  12.  
  13.  
  14. #include "edata.h"
  15. #include "ui.h"
  16.  
  17. BOOL i_OpenLibs(void);
  18. void i_CloseLibs(void);
  19.  
  20. struct Catalog *Catalog;
  21.  
  22. /**************************************************************************************/
  23.  
  24. //UBYTE version[]="$VER: " m_CLASS_ID " 1.0 "__AMIGADATE__;
  25.  
  26. Class   *EditorClassPtr;
  27.  
  28. struct Library *PaletteRequesterBase;
  29.  
  30. #define INIT_CLASS(class,entry)\
  31.   class->cl_Dispatcher.h_Data=LibBase;\
  32.   class->cl_Dispatcher.h_Entry=DispatcherStub;\
  33.   class->cl_Dispatcher.h_SubEntry=(HOOKFUNC)entry;
  34.  
  35.  
  36. int __saveds __asm __UserLibInit(register __a6 struct Library *LibBase)
  37. {
  38.   if(i_OpenLibs())
  39.   {
  40.     PaletteRequesterBase=LibBase;
  41.     
  42.     if(EditorClassPtr=MyMakeClass(0,"rootclass",0,sizeof(struct EData),0,EditorDispatcher))
  43.     {
  44.       Catalog=0;
  45.       return(0);
  46.     }
  47.     i_CloseLibs();
  48.   }
  49.   /* Fail */
  50.   return(-1);
  51. }
  52.  
  53. void __saveds __asm __UserLibCleanup(register __a6 struct Library *LibBase)
  54. {
  55.   CloseCatalog(Catalog);
  56.   FreeClass(EditorClassPtr);
  57.   i_CloseLibs();
  58. }
  59.  
  60. void __saveds __asm LIB_Dummy(void)
  61. {
  62. }
  63.  
  64. Class *MyMakeClass(STRPTR ClassID, STRPTR SuperClassID, APTR SuperClassPtr, ULONG ISize, ULONG Nil, ULONG(*Entry)() )
  65. {
  66.   Class *c;
  67.   // Hook
  68.   
  69.   if(c=MakeClass(ClassID,SuperClassID,SuperClassPtr,ISize,Nil)) 
  70.   {
  71.     c->cl_Dispatcher.h_Data     =PaletteRequesterBase;
  72.     c->cl_Dispatcher.h_Entry    =(HOOKFUNC)DispatcherStub;
  73.     c->cl_Dispatcher.h_SubEntry =Entry;
  74.   }
  75.   return(c);  
  76. }
  77.  
  78. ULONG __asm DispatcherStub(register __a0 Class *Cl, register __a2 Object *Obj, register __a1 Msg M)
  79. {
  80.   ULONG __asm (*entry)(register __a0 Class *Cl, register __a2 Object *Obj, register __a1 Msg M, register __a6 APTR Lib);
  81.   
  82.   entry=Cl->cl_Dispatcher.h_SubEntry;
  83.   
  84.   return(entry(Cl,Obj,M,(struct Library *)Cl->cl_Dispatcher.h_Data));
  85. }
  86.  
  87.  
  88. /*
  89. ULONG __asm DispatcherStub(register __a0 Class *Cl, register __a2 Object *Obj, register __a1 Msg M)
  90. {
  91.   return(EditorDispatcher(Cl,Obj,M,(struct Library *)Cl->cl_Dispatcher.h_Data));
  92. }
  93. */
  94.