home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 488.lha / modengine_v1.0 / mod_funcs.c < prev    next >
C/C++ Source or Header  |  1991-03-07  |  4KB  |  195 lines

  1. /* mod_funcs.c
  2.  * Copyright (C) 1990 Commodore-Amiga, Inc.
  3.  * written by David N. Junod
  4.  *
  5.  * application specific functions
  6.  *
  7.  */
  8.  
  9. #include "mod.h"
  10.  
  11. /*--- check to see if the project has been changed ---*/
  12. BOOL CheckForChanges (struct AppInfo * ai)
  13. {
  14.     BOOL cancel = FALSE;
  15.     UBYTE pname[255];
  16.  
  17.     /* See if there is a name for our project */
  18.     strcpy (pname, ai->ProjName);
  19.     if (strlen (pname) < 1)
  20.     strcpy (pname, "<untitled>");
  21.  
  22.     /* Check to see if any changes have been made to our project */
  23.     if (ai->Changed)
  24.     {
  25.  
  26.     /*
  27.      * project (pname) has been changed, do you want to save first?
  28.      * prompt for Yes | No | Cancel
  29.      * 
  30.      * Yes:        call the SaveFunc(NULL, win, NULL) function.
  31.      * No:        fall through.
  32.      * Cancel:    set cancel=TRUE.
  33.      */
  34.  
  35.     /*
  36.      * also set ai->pri_ret so that scripts can act accordingly
  37.      * 
  38.      * Yes:        0
  39.      * No:        0
  40.      * Cancel:    5
  41.      */
  42.     }
  43.     return (cancel);
  44. }
  45.  
  46. VOID NewFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  47. {
  48.     BOOL cancel;
  49.  
  50.     printf ("`New' function\n");
  51.  
  52.     cancel = CheckForChanges (ai);
  53.     if (!cancel)
  54.     {
  55.     /* Free up the previous project here... */
  56.  
  57.     /* Prepare for a New project here... */
  58.     strcpy (ai->ProjName, "");
  59.     ai->Changed = FALSE;
  60.     }
  61. }
  62.  
  63. VOID OpenFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  64. {
  65.     BOOL cancel;
  66.  
  67.     printf ("`Open' function\n");
  68.  
  69.     cancel = CheckForChanges (ai);
  70.     if (!cancel)
  71.     {
  72.     /* see if an argument was passed */
  73.     if (strlen (args) > 0)
  74.     {
  75.         printf ("%s was passed\n", args);
  76.         strcpy (ai->ProjName, args);
  77.     }
  78.     else
  79.     {
  80.  
  81.         /*
  82.          * Bring up your file requester here. Remember to check for cancel
  83.          * being pressed...
  84.          */
  85.         strcpy (ai->ProjName, "Named");
  86.     }
  87.  
  88.     /* Open a new project here... */
  89.     ai->Changed = FALSE;
  90.     }
  91. }
  92.  
  93. VOID SaveFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  94. {
  95.     printf ("`Save' function\n");
  96.  
  97.     if (strlen (ai->ProjName) == 0)
  98.     {
  99.     /* Not named yet, so let's get a name */
  100.     SaveAsFunc (ai, msg, args);
  101.     }
  102.     else if (ai->Changed)
  103.     {
  104.     /* Save your project here ... */
  105.     ai->Changed = FALSE;
  106.     }
  107. }
  108.  
  109. VOID SaveAsFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  110. {
  111.     printf ("`Save As' function\n");
  112.  
  113.     /* see if an argument was passed */
  114.     if (strlen (args) > 0)
  115.     {
  116.     /* they passed a file name to save as */
  117.     printf ("%s was passed\n", args);
  118.     strcpy (ai->ProjName, args);
  119.     }
  120.     else
  121.     {
  122.     /*
  123.      * Bring up your file requester here so that user can name the project.
  124.      * Only set the Changed flag to FALSE if the user successfully returns
  125.      * a file name (doesn't hit CANCEL).
  126.      */
  127.     strcpy (ai->ProjName, "Named");
  128.     }
  129.  
  130.     /* Save your project here ... */
  131.     ai->Changed = FALSE;
  132. }
  133.  
  134. VOID AboutFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  135. {
  136.     printf ("`About' function\n");
  137.  
  138.     /* return a text value */
  139.     ai->textrtn = "ModEngine 1.00 23-Feb-90";
  140. }
  141.  
  142. VOID QuitFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  143. {
  144.     printf ("`Quit' function\n");
  145.  
  146.     /* Inform the main loop that we are done */
  147.     ai->Done = TRUE;
  148. }
  149.  
  150. VOID ChooseFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  151. {
  152.     printf ("`Choose a Tool' function\n");
  153. }
  154.  
  155. VOID DefineFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  156. {
  157.     printf ("`Change Tool Settings' function\n");
  158. }
  159.  
  160. VOID UndoFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  161. {
  162.     printf ("`Undo' function\n");
  163. }
  164.  
  165. VOID HelpFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  166. {
  167.     printf ("`Help' function\n");
  168. }
  169.  
  170. VOID ArrowFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  171. {
  172.     printf ("`Arrow' function\n");
  173. }
  174.  
  175. VOID ShellFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  176. {
  177.     printf ("`Shell' function\n");
  178.     HandlerFunc (ai, "DOS", MH_OPEN);
  179. }
  180.  
  181. VOID WindowFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  182. {
  183.     printf ("`Window' function\n");
  184.     if (strcmpi (args, "CLOSE") == 0)
  185.     HandlerFunc (ai, "IDCMP", MH_CLOSE);
  186.     else
  187.     HandlerFunc (ai, "IDCMP", MH_OPEN);
  188. }
  189.  
  190. /* Abort current operation */
  191. VOID AbortFunc (struct AppInfo *ai, struct Message *msg, UBYTE * args)
  192. {
  193.     printf ("`Abort' function\n");
  194. }
  195.