home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / FACETV.ZIP / FILEDLG.H < prev    next >
C/C++ Source or Header  |  1993-12-09  |  4KB  |  155 lines

  1. /************************************************************************
  2. **
  3. ** @(#)filedlg.h    12/09/93    Chris Ahlstrom
  4. **
  5. **    C++ version
  6. **
  7. **    This code was shamelessly abstracted from the FVIEWER demo
  8. ** of Borland's Turbo Vision, but has some minor innovations from the
  9. ** author.
  10. **
  11. *************************************************************************/
  12.  
  13.  
  14. #if !defined(FILEDLG_h)                // { FILEDLG_h
  15. #define FILEDLG_h
  16.  
  17. #if defined(__BORLANDC__)
  18. #pragma warn -amp        // ignore superfluous "&" warning
  19. #endif
  20.  
  21. #define Uses_TChDirDialog
  22. #define Uses_TDeskTop
  23. #define Uses_TFileDialog
  24. #include <tv.h>
  25.  
  26. #if defined(__BORLANDC__)
  27. #pragma warn .amp        // reset initial status of "&" warning
  28. #endif
  29.  
  30.  
  31. /************************************************************************
  32. ** FilePicker class typedefs and variables
  33. **
  34. ** FileAction type:
  35. **
  36. **    actionCode    0 = User cancelled or supplied a null filename;
  37. **                do not perform the action
  38. **
  39. **            1 = Perform the action
  40. **
  41. ** FileActivity type:
  42. **
  43. **    nameActive    0 = User cleared out the filename (if it was
  44. **                active), or never specified one before.
  45. **                This should be accompanied by actionCode = 0.
  46. **
  47. **            1 = The user supplied a name, and opted to
  48. **                perform the option.  If actionCode = 0,
  49. **                a name was active, but the user pressed the
  50. **                Cancel button.
  51. **
  52. ** FileOperation type:
  53. **
  54. **    See the typedef below; the meaning is obvious.
  55. **
  56. **
  57. *************************************************************************/
  58.  
  59.  
  60. typedef enum
  61. {
  62.     FILE_CANCELLED    = 0,
  63.     FILE_PERFORM_ACTION
  64.  
  65. } FileAction;
  66.  
  67. typedef enum
  68. {
  69.     FILE_INACTIVE    = 0,
  70.     FILE_ACTIVE,
  71.     FILE_SAME_STATUS
  72.  
  73. } FileActivity;
  74.  
  75. typedef enum            // not all these are supported yet
  76. {
  77.     FILE_READ        = 0,
  78.     FILE_WRITE,
  79.     FILE_CREATE,
  80.     FILE_OPEN,
  81.     FILE_DELETE
  82.  
  83. } FileOperation;
  84.  
  85.  
  86. /************************************************************************
  87. ** FilePicker class
  88. **
  89. **    We have made a great effort to make all data private.
  90. ** Functions are used to access private data.
  91. **
  92. *************************************************************************/
  93.  
  94.  
  95. class FilePicker
  96. {
  97.  
  98. public:
  99.  
  100.     FilePicker                // constructor
  101.     (
  102.     TDeskTop *desk,
  103.     char *wildcard            // the starting wild-card
  104.     );
  105.  
  106.     void fileDialog            // requests filename from user
  107.     (
  108.     FileOperation mode
  109.     );
  110.     void chDir();            // for changing DOS current directory
  111.     void makeFileName            // assembles full file specs from cwd
  112.     (
  113.     char *basename,
  114.     char *extension
  115.     );
  116.  
  117.     // Other functions need to have indirect access to the following
  118.  
  119.     FileActivity fileActive ( void );    // returns value of nameActive
  120.     FileAction fileAction( void );    // returns value of actionCode
  121.     char *fileSpec( void );        // returns pointer to fpFileSpec[]
  122.     int fileBase( char *destination );    // copies fpFileBase[] to destination
  123.     void inactivateFile( void );    // force request for new filename
  124.  
  125. private:
  126.  
  127.     TDeskTop *desktop;            // not sure if should be private
  128.  
  129.     void pickFile
  130.     (
  131.     char *wildcard,
  132.     char *boxtitle,
  133.     char *fieldtitle,
  134.     ushort options
  135.     );
  136.  
  137.     FileActivity nameActive;
  138.     FileAction actionCode;
  139.  
  140.     char fpFileSpec[MAXPATH];
  141.     char fpDrive[MAXDRIVE];
  142.     char fpDirName[MAXDIR];
  143.     char fpFileBase[MAXFILE];
  144.     char fpFileExt[MAXEXT];
  145.     char fpFileName[MAXFILE+MAXEXT+1];
  146.  
  147.     char wildCard[MAXFILE];        // store the original wild-card
  148.  
  149.     struct ffblk fileInfo;
  150.  
  151. };
  152.  
  153.  
  154. #endif                            // } FILEDLG_h
  155.