home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / misc / imagefx_sdk / sas / examples / render / skeleton.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-02  |  10.5 KB  |  411 lines

  1. #include <exec/types.h>
  2. #include <scan/modall.h>
  3. #include <scan/loadsave.h>
  4.  
  5.  
  6. /**********************************************************************\
  7.  
  8.                            Language Indexes
  9.  
  10. \**********************************************************************/
  11.  
  12. #define TXT(i)             GetStr((i), Default_Strings[(i)])
  13.  
  14. enum {
  15.    TXT_Msg1 = 0,           /* This example doesn't render */
  16.    TXT_ModuleName,         /* Skeleton */
  17.    TXT_RenderLabel,        /* Render */
  18.    TXT_ModuleLabel,        /* Module: */
  19.    TXT_COUNT
  20. };
  21.  
  22. char *Default_Strings[] = {
  23.    "This example doesn't render.",
  24.    "Skeleton",
  25.    "Render",
  26.    "Module:"
  27. };
  28.  
  29. /**********************************************************************\
  30.  
  31.                          GED Gadget Functions
  32.  
  33. \**********************************************************************/
  34.  
  35. /*
  36.  * This function will be called when the user clicks on the Render
  37.  * button.  Normally one would find the current image buffer and
  38.  * then do whatever it takes to render a display.
  39.  *
  40.  */
  41. int __saveds RenderCode (GedButtonProto)
  42. {
  43.    InfoRequest(TXT(TXT_Msg1));
  44.    return(0);
  45. }
  46.  
  47. /**********************************************************************\
  48.  
  49.                          GED GUI Description
  50.  
  51. \**********************************************************************/
  52.  
  53. enum {
  54.    ID_Module = 1,
  55.    ID_Render
  56. };
  57.  
  58. struct NewGad newGads[] = {
  59.       /* button to change the render module */
  60.     { Button_ID, ID_Module, 16,24,102,12, TXT_ModuleName, ChangeRender,0, NULL, 0,'\0',NULL,0  },
  61.        /* button to initiate rendering */
  62.     { Button_ID,ID_Render, 16,62,102,12, TXT_RenderLabel, RenderCode,0, NULL, 0,'\0',NULL,0 },
  63.        /* text labelling the change-module gadget above */
  64.     { Text_ID, 0, 67,15,0,0, TXT_ModuleLabel, NULL,0,NULL, 2,0,2,0  },
  65.     { End_ID }
  66. };
  67.  
  68. /**********************************************************************\
  69.  
  70.                              Housekeeping
  71.  
  72. \**********************************************************************/
  73.  
  74. BOOL clear_text = FALSE;
  75.  
  76. /*
  77.  * RM_Init()
  78.  *
  79.  * Module initialization function.  ImageFX will call this function
  80.  * when the module is first loaded into memory (once).  Return TRUE
  81.  * if all goes well or FALSE on failure.
  82.  *
  83.  * We need to do a little bit of voodoo magic with the text strings
  84.  * to make the Ged stuff work right.
  85.  *
  86.  */
  87. int __saveds RM_Init (void)
  88. {
  89.    if (ModuleBase->Text == NULL) {
  90.       clear_text = TRUE;
  91.       ModuleBase->Text = Default_Strings;
  92.    }
  93.    return(TRUE);
  94. }
  95.  
  96. /*
  97.  * RM_Cleanup()
  98.  *
  99.  * Cleanup any and all resources, memory, or whatever allocated
  100.  * in the RM_Init() function above.  ImageFX will call this function
  101.  * just before unloading the module.
  102.  *
  103.  */
  104. void __saveds RM_Cleanup (void)
  105. {
  106.    if (clear_text) ModuleBase->Text = NULL;
  107. }
  108.  
  109. /*
  110.  * RM_Show()
  111.  *
  112.  * This function is called when ImageFX displays this module's
  113.  * GUI onscreen.  This can be used as an indicator of when the
  114.  * user "enters" this module (to bring up additional screens or
  115.  * whatever).
  116.  *
  117.  * The window argument is a pointer to ImageFX's main window
  118.  * (where all of this module's gadgets have been added).
  119.  *
  120.  * Return TRUE on success or FALSE on failure.
  121.  *
  122.  */
  123. int __saveds __asm RM_Show (register __a0 struct Window *window)
  124. {
  125.    return(TRUE);
  126. }
  127.  
  128. /*
  129.  * RM_Clear()
  130.  *
  131.  * This function is called when ImageFX is removing this module's
  132.  * GUI from the display.  This can be used as an indicator of when
  133.  * the user "leaves" this module.  Generally you should 'undo' whatever
  134.  * it is you did in the RM_Show() function above.
  135.  *
  136.  * The window argument is a pointer to ImageFX's main window
  137.  * (where all of this module's gadgets have been added).
  138.  *
  139.  */
  140. void __saveds __asm RM_Clear (register __a0 struct Window *window)
  141. {
  142. }
  143.  
  144. /**********************************************************************\
  145.  
  146.                        Rendered Screen Handling
  147.  
  148. \**********************************************************************/
  149.  
  150. BOOL image_is_rendered = FALSE;
  151.  
  152. /*
  153.  * RM_GetRendered()
  154.  *
  155.  * Fill in the supplied MappedImage structure (see scan/loadsave.h)
  156.  * with information describing the current rendered image.  If
  157.  * no image is rendered, return 0.  Otherwise, return non-zero.
  158.  *
  159.  * Note that it is legal for ImageFX to pass a NULL MappedImage
  160.  * pointer; in this case, ImageFX is just trying to find out if
  161.  * there is a rendered image or not and you should just return
  162.  * zero or non-zero.
  163.  *
  164.  */
  165. int __saveds __asm RM_GetRendered (register __a0 struct MappedImage *img)
  166. {
  167.    if (image_is_rendered) {
  168.       if (img) {
  169.          /*
  170.           * fill in MappedImage structure here.
  171.           */
  172.       }
  173.       return(TRUE);
  174.    }
  175.    return(FALSE);
  176. }
  177.  
  178. /**********************************************************************\
  179.  
  180.                           Preferences Handling
  181.  
  182. \**********************************************************************/
  183.  
  184. /*
  185.  * This structure defines the format for your preferences.  ImageFX
  186.  * will store this structure in the user's prefs files.
  187.  */
  188. struct MyPrefs {
  189.    short Stuff[4];
  190.    LONG  Reserved[8];   /* Always a good idea to reserve some space */
  191. };
  192.  
  193. /*
  194.  * RM_LoadPrefs()
  195.  *
  196.  * Configure your module based on the settings in the supplied
  197.  * preferences structure.  Note that your module does not necessarily
  198.  * have to be displayed for this function to be called, so make sure
  199.  * that your gadgets exist before fiddling with them.  Return TRUE
  200.  * on success, or FALSE on failure.
  201.  *
  202.  */
  203. BOOL __saveds __asm RM_LoadPrefs (register __a0 struct MyPrefs *prefs)
  204. {
  205.    return(TRUE);
  206. }
  207.  
  208. /*
  209.  * RM_SavePrefs()
  210.  *
  211.  * Store your current module configuration into the supplied
  212.  * preferences structure.  ImageFX will then save it to disk.
  213.  *
  214.  */
  215. BOOL __saveds __asm RM_SavePrefs (register __a0 struct MyPrefs *prefs)
  216. {
  217.    return(TRUE);
  218. }
  219.  
  220. /**********************************************************************\
  221.  
  222.                               Miscellaneous
  223.  
  224. \**********************************************************************/
  225.  
  226. /*
  227.  * RM_HandleMMove()
  228.  *
  229.  * Called whenever a MOUSEMOVE event is received by ImageFX that it
  230.  * does not understand.  You can use this to process events for your
  231.  * own windows that you open.
  232.  *
  233.  * The message passed to you is a copy, DO NOT REPLY TO IT!
  234.  *
  235.  * You should return 1 if you knew how to deal with the event, or
  236.  * 0 if you ignored it.
  237.  *
  238.  * You must set the XF_MOUSETRAP flag in your ModuleBase's ExtFlags
  239.  * field (in the UserOpen function below) to use this feature.
  240.  *
  241.  */
  242. int __saveds __asm RM_HandleMMove (register __a0 struct IntuiMessage *msg)
  243. {
  244.    return(0);
  245. }
  246.  
  247. /*
  248.  * RM_HandleMButton()
  249.  *
  250.  * Called whenever a MOUSEBUTTON event is received by ImageFX that it
  251.  * does not understand.  You can use this to process events for your
  252.  * own windows that you open.
  253.  *
  254.  * The message passed to you is a copy, DO NOT REPLY TO IT!
  255.  *
  256.  * You should return 1 if you knew how to deal with the event, or
  257.  * 0 if you ignored it.
  258.  *
  259.  * You must set the XF_MOUSETRAP flag in your ModuleBase's ExtFlags
  260.  * field (in the UserOpen function below) to use this feature.
  261.  *
  262.  */
  263. int __saveds __asm RM_HandleMButton (register __a0 struct IntuiMessage *msg)
  264. {
  265.    return(0);
  266. }
  267.  
  268. /*
  269.  * RM_ChangeNotify()
  270.  *
  271.  * Called whenever the main buffer in ImageFX changes (eg. when the
  272.  * user loads or creates a new image).  This can be used to update
  273.  * display fields that depend on the image in some way.
  274.  *
  275.  * You must set the XF_LOADNOTIFY flag in your ModuleBase's ExtFlags
  276.  * field (in the UserOpen function below) to use this feature.
  277.  *
  278.  * (Requires ImageFX 1.50 or later.)
  279.  *
  280.  */
  281. void __saveds RM_ChangeNotify (void)
  282. {
  283. }
  284.  
  285. /**********************************************************************\
  286.  
  287.                              Arexx Functions
  288.  
  289. \**********************************************************************/
  290.  
  291. /*
  292.  * Sample Arexx command handler.  All render modules should have a
  293.  * command that starts rendering.  This one simply calls the Render
  294.  * gadget's code handler to do the render.
  295.  */
  296. static int __saveds __stdargs Arexx_Go (ArexxProto)
  297. {
  298.    RenderCode(NULL, NULL, 0);
  299.    return(0);
  300. }
  301.  
  302. /*
  303.  * This table defines all the Arexx commands we understand.  The
  304.  * user sends us Arexx commands via. the ImageFX "RENDER" command.
  305.  * We must supply a pointer to this table in the UserOpen()
  306.  * function below.
  307.  */
  308. static RXCMD MyRexxCommands[] = {
  309.    { "GO",        Arexx_Go,      "" },
  310.    { NULL }
  311. };
  312.  
  313.  
  314. /**********************************************************************\
  315.  
  316.                          Standard Module Stuff
  317.  
  318. \**********************************************************************/
  319.  
  320.  
  321. /*
  322.  * Function table.  Referenced in "lib.o".
  323.  *
  324.  * The first four entries are the standard library vectors, defined
  325.  * in "lib.o", the remaining entries define functions specific to
  326.  * this module.
  327.  *
  328.  * The table ends with -1.
  329.  *
  330.  */
  331. ULONG FuncTable[] = {
  332.    (ULONG) LibOpen,
  333.    (ULONG) LibClose,
  334.    (ULONG) LibExpunge,
  335.    (ULONG) LibNull,
  336.  
  337.    (ULONG) RM_Init,
  338.    (ULONG) RM_Cleanup,
  339.    (ULONG) RM_Show,
  340.    (ULONG) RM_Clear,
  341.    (ULONG) 0,              /* unused */
  342.    (ULONG) RM_GetRendered,
  343.    (ULONG) 0,              /* unused */
  344.    (ULONG) RM_LoadPrefs,
  345.    (ULONG) RM_SavePrefs,
  346.    (ULONG) 0,              /* unused */
  347.    (ULONG) 0,              /* unused */
  348.  
  349.    (ULONG) RM_HandleMMove,
  350.    (ULONG) RM_HandleMButton,
  351.  
  352.    (ULONG) RM_ChangeNotify,
  353.  
  354.    (ULONG) 0,              /* reserved */
  355.    (ULONG) 0,              /* reserved */
  356.    (ULONG) 0,              /* reserved */
  357.  
  358.    (ULONG) -1L
  359. };
  360.  
  361. /*
  362.  * ID string for this module.  References in "lib.o".
  363.  *
  364.  * Should be given in the standard 2.0 version string style.
  365.  */
  366. UBYTE LibraryID[] = "$VER: Untitled 1.00.00 (19.6.92)";
  367.  
  368. /*
  369.  * Type of module.  Referenced in "lib.o".
  370.  *
  371.  * Should be one of the NT_* defines in <scan/mod.h>
  372.  *
  373.  */
  374. UBYTE LibraryType = NT_RENDER;
  375.  
  376. /*
  377.  * Module initialization code.  Referenced by "lib.o".
  378.  *
  379.  * This is where you would initialize the ModuleBase structure that
  380.  * is passed to you.
  381.  *
  382.  * Returns TRUE if all went well, or FALSE if something went wrong and
  383.  * the module open should fail.
  384.  *
  385.  */
  386. LONG __saveds __stdargs UserOpen (struct ModuleBase *modbase)
  387. {
  388.    modbase->NewGad = newGads;                   /* GUI */
  389.    modbase->Language = "Render_Skeleton";       /* Language tag */
  390.    modbase->LangCount = TXT_COUNT;              /* Number of texts */
  391.    modbase->CmdTable = MyRexxCommands;          /* Arexx cmd table */
  392.    modbase->PrefID = 'RSKL';                    /* Preferences tag */
  393.    modbase->PrefLen = sizeof(struct MyPrefs);   /* Size of prefs data */
  394.    return(TRUE);
  395. }
  396.  
  397. /*
  398.  * Module cleanup code.  Referenced by "lib.o".
  399.  *
  400.  * This should cleanup anything you allocated or opened in UserOpen()
  401.  * above.
  402.  *
  403.  * Always return TRUE.
  404.  *
  405.  */
  406. LONG __saveds __stdargs UserClose (struct ModuleBase *modbase)
  407. {
  408.    return(TRUE);
  409. }
  410.  
  411.