home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / vrac / thandl.zip / THANDLER.HPP < prev    next >
C/C++ Source or Header  |  1993-12-05  |  7KB  |  211 lines

  1. /*-----------------------------------------------------------------------*/
  2. /* filename -       thandler.hpp                                         */
  3. /*                                                                       */
  4. /* function(s)                                                           */
  5. /*                  declarations for the following classes...            */
  6. /*                                                                       */
  7. /*                     TErrorText                                        */
  8. /*                     TTitleFrame                                       */
  9. /*                     TErrorDialog                                      */
  10. /*                     THandler                                          */
  11. /*                                                                       */
  12. /*                  this shareware version contains a "nag screen"       */
  13. /*                  dialog which is not present in the registered        */
  14. /*                  version                                              */
  15. /*                                                                       */
  16. /* author -         Michael "Mick" Newton                                */
  17. /*                                                                       */
  18. /*-----------------------------------------------------------------------*/
  19.  
  20. /*-----------------------------------------------------------------------*/
  21. /*                                                                       */
  22. /*    THANDLER.HPP                                                       */
  23. /*                                                                       */
  24. /*    THandler shareware version 2.0                                     */
  25. /*    Copyright (C) 1992,1993 Comsoft Software                           */
  26. /*    All Rights Reserved.                                               */
  27. /*                                                                       */
  28. /*                                                                       */
  29. /*-----------------------------------------------------------------------*/
  30.  
  31.  
  32. #if !defined __THANDLER_HPP
  33. #define __THANDLER_HPP
  34.  
  35.  
  36. // Forward references to Turbo Vision classes *****************************
  37.  
  38. class far TDialog;
  39. class far TEvent;
  40. class far TFrame;
  41. class far TPalette;
  42. class far TRect;
  43. class far TStaticText;
  44.  
  45.  
  46.  
  47.  
  48.  
  49. // Defined types **********************************************************
  50.  
  51. typedef void interrupt (far *fptr)(...);
  52.  
  53.  
  54.  
  55.  
  56.  
  57. // Defines ****************************************************************
  58.  
  59. #define handlerVerStr "2.0"       // Thandler version string
  60. #define ERROR_TEXT_SIZE 55        // TErrorText text buffer size
  61. #define DEVNAME_SIZE 9            // Device name string buffer size
  62. #define INT24 0x24                // Interrupt 24H
  63.  
  64.  
  65.  
  66.  
  67.  
  68. // Constants **************************************************************
  69.  
  70. /*
  71.    AX on entry to ISR
  72.  
  73.  ┌──────── AH ────────┐   ┌──────── AL ────────┬── Drive number
  74.  │                    │   │                    │   (if AH bit 7 = 0)
  75.  7  6  5  4  3  2  1  0   7  6  5  4  3  2  1  0
  76. ╔╧═╤╧═╤╧═╤╧═╤╧═╤╧═╤╧═╤╧═╦═╧╤═╧╤═╧╤═╧╤═╧╤═╧╤═╧╤═╧╗
  77. ║  │  │  │  │  │  │  │  ║  │  │  │  │  │  │  │  ║
  78. ╚╤═╧╤═╧╤═╧╤═╧╤═╧╤═╧╤═╧╤═╩══╧══╧══╧══╧══╧══╧══╧══╝
  79.  │  │  │  │  │  │  │  │
  80.  │  │  │  │  │  │  │  └─── 1 if write error, 0 if read error ──── = 0x0001
  81.  │  │  │  │  │  │  │
  82.  │  │  │  │  │  └──┴────── Disk area of error ─────────────────── = 0x0006
  83.  │  │  │  │  └──────────── Fail allowed ───────────────────────── = 0x0008
  84.  │  │  │  └─────────────── Retry allowed ──────────────────────── = 0x0010
  85.  │  │  └────────────────── Ignore allowed ─────────────────────── = 0x0020
  86.  │  └───────────────────── Undefined ──────────────────────────── = 0x0040
  87.  └──────────────────────── 0 = Disk I/O error 1 = char device ─── = 0x0080
  88. */
  89.  
  90. // Bitmasks for ah
  91. const ignoreOK   = 0x0020;        // Ignore
  92. const retryOK    = 0x0010;        // Retry
  93. const failOK     = 0x0008;        // Fail
  94. const charDevice = 0x0080;        // Disk/char device
  95.  
  96. // Error dialog button commands
  97. const cmAbort    = 200,
  98.       cmRetry    = 201,
  99.       cmIgnore   = 202,
  100.       cmFail     = 203;
  101.  
  102.  
  103.  
  104.  
  105.  
  106. // Data structures ********************************************************
  107.  
  108. // For setData/getData in error dialogs
  109. struct TErrDataRec
  110. {
  111.    char deviceMsg[ERROR_TEXT_SIZE];    // Failing device message
  112.    char errorMsg[ERROR_TEXT_SIZE];     // Error message
  113. };
  114.  
  115.  
  116.  
  117.  
  118.  
  119. // TErrorText *************************************************************
  120.  
  121. class TErrorText : public TStaticText
  122. {
  123.    public:
  124.       TErrorText(const TRect& bounds);
  125.       virtual ushort dataSize();
  126.       virtual void setData(void *rec);
  127.       virtual void getData(void *rec);
  128.       virtual void draw();
  129.    protected:
  130.    private:
  131.       static const char * const near buffstr;
  132. };
  133.  
  134.  
  135.  
  136.  
  137.  
  138. // TTitleFrame ************************************************************
  139.  
  140. class TTitleFrame : public TFrame
  141. {
  142.    public:
  143.       TTitleFrame(const TRect& bounds);
  144.       virtual TPalette& getPalette() const;
  145.       virtual void draw();
  146.    protected:
  147.    private:
  148. };
  149.  
  150.  
  151.  
  152.  
  153.  
  154. // TErrorDialog ***********************************************************
  155.  
  156. class TErrorDialog : public TDialog
  157. {
  158.    public:
  159.       TErrorDialog(const char *aTitle);
  160.       virtual void shutDown();
  161.       virtual TPalette& getPalette() const;
  162.       static TFrame *initFrame(TRect r);
  163.       virtual void handleEvent(TEvent& event);
  164.    protected:
  165.    private:
  166. };
  167.  
  168.  
  169.  
  170.  
  171.  
  172. // THandler ***************************************************************
  173.  
  174. class THandler
  175. {
  176.    public:
  177.       THandler(const char *aTitle,
  178.                Boolean aExtPalette = False,
  179.                Boolean aUseSounds = False,
  180.                Boolean aDOSHandler = False);
  181.       ~THandler();
  182.       void suspend();
  183.       void resume();
  184.       void setSounds(Boolean aUseSounds);
  185.       Boolean getSounds();
  186.       void setExtPalette(Boolean aExtPalette);
  187.       Boolean getExtPalette();
  188.       void setDOSHandler(Boolean aDOSHandler);
  189.       Boolean DOSHandlerSet();
  190.       Boolean status;
  191.    private:
  192.       Boolean DOSHandler;
  193.       // Pointer to original ISR
  194.       static void interrupt (far *oldInt24)(...);
  195.       // ISR for Turbo Vision
  196.       static void far newTvHandler(unsigned ax_,
  197.                                    unsigned di_,
  198.                                    unsigned far *bpsi_);
  199.       // ISR for DOS
  200.       static void far newDosHandler(unsigned ax_,
  201.                                     unsigned di_,
  202.                                     unsigned far *bpsi_);
  203. };
  204.  
  205.  
  206. #endif
  207.  
  208. //                                End of THANDLER.HPP
  209.  
  210.  
  211.