home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / open.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  4.2 KB  |  189 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.01
  4. // Copyright (C) 1990, 1991
  5. // Software Dimensions
  6. //
  7. // Dialog Development System
  8. //
  9. //
  10. // To use this dialog in your own program, here is all you have to do:
  11. //
  12. //   1. Include OPEN.H in your module
  13. //   2. Place the following code where you want to bring up the dialog:
  14. //         OpenDialog &Open=*new OpenDialog("*.*");
  15. //         char *File=Open.OpenFile();
  16. //         delete &Open;
  17. //   3. The computer returns a pointer to a string that refers to the
  18. //      file that should be opened.  If it is NULL then no file was
  19. //      selected.  Be sure to copy the info contained in the returned
  20. //      string or you may have problems when you destruct the Open
  21. //      dialog -- since the string is a static.
  22. //   4. That is it!!
  23. //
  24.  
  25. #include "elements.h"
  26. #include <dir.h>
  27.  
  28. #include "chgdir.h" // requires chgdir for directory movement
  29.  
  30. //-------------------------------------------------------------------------
  31. //
  32. // FileStorage class that stores file information
  33. //
  34. //-------------------------------------------------------------------------
  35.  
  36. class FileStorage
  37. {
  38. public:
  39.  
  40.   ffblk *DirEntries;
  41.   int Count;
  42.  
  43.   char Mask[80];
  44.  
  45.   FileStorage(char *_Mask);
  46.   ~FileStorage();
  47.  
  48.   void Refresh();
  49. };
  50.  
  51. //-------------------------------------------------------------------------
  52. //
  53. // ChDirDialog class that controls the entire dialog
  54. //
  55. //-------------------------------------------------------------------------
  56.  
  57. class FileList;
  58. class FilePath;
  59.  
  60. class OpenDialog : public DialogClass
  61. {
  62. public:
  63.  
  64.   PathStorage *Path;
  65.   FileStorage *File;
  66.   FilePath *FilePathed;
  67.   FileList *FileLister;
  68.  
  69.   char FileCompute[100];
  70.   char Value[100];
  71.  
  72.   OpenDialog(char *_Mask=0);
  73.   ~OpenDialog();
  74.  
  75.   char *OpenFile();
  76.  
  77.   int EventHandler(int Event);
  78. };
  79.  
  80. //-------------------------------------------------------------------------
  81. //
  82. // FileList class that lists the available files
  83. //
  84. //-------------------------------------------------------------------------
  85.  
  86. class Prompt2;
  87.  
  88. class FileList : public DiaStructPickList
  89. {
  90. public:
  91.  
  92.   FileStorage &File;
  93.   Prompt2 *Prompt;
  94.   static int CurrentItem;
  95.  
  96.   FileList(int X,int Y,FileStorage &_File);
  97.  
  98.   int EventHandler(int Event);
  99.   void Show();
  100. };
  101.  
  102. //-------------------------------------------------------------------------
  103. //
  104. // FilePath class that handles the dir path
  105. //
  106. //-------------------------------------------------------------------------
  107.  
  108. class FilePath : public DiaChar
  109. {
  110. public:
  111.  
  112.   PathStorage &Path;
  113.   FileStorage &File;
  114.   char *ComparePathStorage;
  115.   char GetMask[20];
  116.  
  117.   int Reset;
  118.  
  119.   FilePath(int X,int Y,PathStorage &_Path,FileStorage &_File,char *Merge);
  120.   ~FilePath();
  121.  
  122.   int EventHandler(int Event);
  123.   int Departure();
  124. };
  125.  
  126. //-------------------------------------------------------------------------
  127. //
  128. // ChDirList2 class that lists the available directories
  129. //
  130. //-------------------------------------------------------------------------
  131.  
  132. class ChDirList2 : public DiaStructPickList
  133. {
  134. public:
  135.  
  136.   PathStorage &Path;
  137.   FileStorage &File;
  138.   FilePath &PathEntry;
  139.   static int CurrentItem;
  140.  
  141.   ChDirList2(int X,int Y,PathStorage &_Path,FileStorage &_File,
  142.     FilePath &_PathEntry);
  143.  
  144.   int EventHandler(int Event);
  145.   void Show();
  146. };
  147.  
  148. //-------------------------------------------------------------------------
  149. //
  150. // DirList2 class that lists all of the available drives
  151. //
  152. //-------------------------------------------------------------------------
  153.  
  154. class DirList2 : public DiaStructPickList
  155. {
  156. public:
  157.  
  158.   PathStorage &Path;
  159.   FileStorage &File;
  160.   FilePath &PathEntry;
  161.  
  162.   DirList2(int X,int Y,PathStorage &_Path,FileStorage &_File,
  163.     FilePath &_PathEntry);
  164.  
  165.   int EventHandler(int Event);
  166. };
  167.  
  168. //-------------------------------------------------------------------------
  169. //
  170. // Prompt2 class indiciates current location
  171. //
  172. //-------------------------------------------------------------------------
  173.  
  174. class Prompt2 : public DialogElement
  175. {
  176. public:
  177.  
  178.   PathStorage &Path;
  179.   FileStorage &File;
  180.   FileList &List;
  181.  
  182.   Prompt2(PathStorage &_Path,FileStorage &_File,FileList &_List);
  183.  
  184.   void Show();
  185.   void HighLight();
  186.   int Available();
  187.   int EventHandler(int Event);
  188. };
  189.