home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / File Dropper 1.1b1 / FD Starter / FD Interface.h next >
Encoding:
C/C++ Source or Header  |  1993-04-17  |  4.8 KB  |  191 lines  |  [TEXT/KAHL]

  1. /*****
  2.  * FD Interface.h
  3.  *
  4.  * Copyright © 1993 Troy Anderson; All rights reserved.
  5.  *
  6.  * Written by Troy Anderson
  7.  *
  8.  * Header file for File Dropper, with all of the prototypes and definitions you need to interface
  9.  * with the File Dropper π library.  See the comments before the function prototypes below for
  10.  * explanations of their use.  See the read me accompanying this file for general information
  11.  * about what this is and how to use it.
  12.  *
  13.  * Version 1.1ß1
  14.  *****/
  15.  
  16.  
  17. #pragma once
  18.  
  19. /**
  20.  ** message values
  21.  **
  22.  ** These are the values that will be passed to you via the message parameter in
  23.  ** ModuleMain.
  24.  **/ 
  25.  
  26. enum { 
  27.     eStartup, 
  28.     eAEInitialize, 
  29.     eSFInitialize, 
  30.     eValidateFile, 
  31.     eProcessFile, 
  32.     eDispose, 
  33.     eDoAboutBox, 
  34.     eQuitting
  35. };
  36.  
  37.  
  38. /**
  39.  ** ModuleDataRec
  40.  **
  41.  ** A pointer to this structure is passed to you in ModuleMain
  42.  **/ 
  43.  
  44. typedef struct {
  45.     FSSpec    *theFile;
  46.     long    refcon;
  47.     } ModuleDataRec;
  48.  
  49.  
  50. /**
  51.  ** Customization function types
  52.  **
  53.  ** These three function types are needed only if you want to override the standard
  54.  ** get file stuff.
  55.  **/
  56.  
  57. /*
  58.  * For this function, return TRUE if theFile points to the file the user selected,
  59.  * return FALSE if the user cancelled.
  60.  */
  61. typedef Boolean         (*CustomGetFSSpecFunc)( FSSpec *theFile, long *refcon);
  62.  
  63. /* 
  64.  * The next two functions are identical to the ones described in Inside Macintosh
  65.  * when using a custom file filter or a custom dialog hook function with SFGetFile.
  66.  * See Volume I, page 523.
  67.  */
  68. typedef pascal Boolean    (*CustomFileFilterFunc)( fileParam *pbp);
  69. typedef pascal short    (*CustomDialogHookFunc)( short item, DialogPtr theDialog);
  70.  
  71.  
  72.  
  73. /**
  74.  ** Customization function installation routines
  75.  **
  76.  ** Call these functions to install custom handlers for the GetFile, FileFilter, and DialogHook
  77.  ** when using the GetFile interface.
  78.  **/
  79.  
  80. void InstallCustomGetFSSpecFunc( CustomGetFSSpecFunc *theFunction);
  81. void InstallCustomFileFilterFunc( CustomFileFilterFunc *theFunction);
  82. void InstallCustomDialogHookFunc( CustomDialogHookFunc *theFunction);
  83.  
  84.  
  85.  
  86. /**
  87.  ** Setting up status dialog parameters
  88.  **
  89.  ** Call this function to tell File Dropper if you want the status dialog to be shown and
  90.  ** what info you want in it.  If showStatusDialog is TRUE, the dialog will show up while
  91.  ** files are being processed.  If showProgressBar is TRUE, a progress bar (like the Finder's
  92.  ** file copying progress bar) will be in the status window for you to use (see SetStatusPercentage
  93.  **    below).  If customMessage is not NULL, the pascal string in it will be written in the
  94.  ** status dialog.  CustomMessage would be something like "\pNow processing your files..."
  95.  **
  96.  ** Defaults:
  97.  **     showStatusDialog is TRUE
  98.  **        showProgressBar is FALSE
  99.  **        customMessage is NULL
  100.  **
  101.  ** If you call this function, call it in response to eStartup, eAEInitialize, or eSFInitialize only.
  102.  **/
  103.  
  104. void SetStatusParams( Boolean showStatusDialog, Boolean showProgressBar, StringPtr customMessage);
  105.  
  106.  
  107. /**
  108.  ** Status bar percentage change routine
  109.  **
  110.  ** Call this function to show the user how far along you are on your file.  Pass
  111.  ** in ther percentage (a number from 0 to 100).  This only does anything if you have
  112.  ** previously called SetStatusParams and set showProgressBar to TRUE.
  113.  **/
  114.  
  115. void SetStatusPercentage( short percentage);
  116.  
  117.  
  118. /**
  119.  ** ModuleMain
  120.  **
  121.  ** This is the entrypoint into your part of the code.
  122.  **/
  123.  
  124. Boolean ModuleMain( short message, ModuleDataRec *moduleData);
  125.  
  126.  
  127.  
  128.  
  129. /**
  130.  ** Useful Utilities
  131.  **
  132.  ** You may find the following functions useful, and are free to use them.
  133.  **/
  134.  
  135. /*
  136.  * These values can be passed to ErrorAlert, but are meaningless to FailOSErr
  137.  */
  138. typedef enum {
  139.     eWrongMachine    = 1,
  140.     eSmallSize,
  141.     eNoMemory,
  142.     eBadResourceFile,
  143.     eAppleEventError,
  144.     eOSError,
  145.     eCantReadFile,
  146.     eModuleError
  147. }ErrorType;
  148.  
  149.  
  150.     /* 
  151.      * Puts up an alert for the user with a message corresponding to error, followed by 
  152.      * aPString.  When the user clicks OK, it returns, the application does not quit.
  153.      * aPString can be NULL.
  154.      */
  155. void ErrorAlert( ErrorType error, StringPtr aPString);
  156.  
  157.  
  158.     /* 
  159.      * Puts up an alert for the user with aPString as the message.  When the user clicks OK,
  160.      * it returns, the application does not quit.
  161.      */
  162. void ShowError( StringPtr aPString);
  163.  
  164.  
  165.     /*
  166.      * If error is 0, this function simply returns, otherwise it puts up an
  167.      * alert for the user that says that an OS Error occurred, followed by the 
  168.      * value of error.  When the user clicks OK, the application quits.  The 
  169.      * eQuitting message does NOT get sent.
  170.      */
  171. void FailOSErr( OSErr error);
  172.  
  173.  
  174.     /* 
  175.      * Returns TRUE if the key corresponding to theKeyCode is being pressed
  176.      * at the time of the call
  177.      */
  178. Boolean KeyIsDown( short theKeyCode);
  179.  
  180.  
  181.     /*
  182.      * Constants that can be used in calls to KeyIsDown
  183.      */
  184. #define    TAB_KEY            (0x30)
  185. #define    SPACE_KEY        (0x31)
  186. #define COMMAND_KEY        (0x37)
  187. #define    SHIFT_KEY        (0x38)
  188. #define    CAPS_LOCK_KEY    (0x39)
  189. #define OPTION_KEY        (0x3A)
  190. #define    CONTROL_KEY        (0x3B)
  191.