home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / TVINC.ZIP / SYSTEM.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  7.9 KB  |  395 lines

  1. /* ------------------------------------------------------------------------*/
  2. /*                                                                         */
  3. /*   SYSTEM.H                                                              */
  4. /*                                                                         */
  5. /*   Copyright (c) Borland International 1991                              */
  6. /*   All Rights Reserved.                                                  */
  7. /*                                                                         */
  8. /*   defines the classes THWMouse, TMouse, TEventQueue, TDisplay,          */
  9. /*   TScreen, and TSystemError                                             */
  10. /*                                                                         */
  11. /* ------------------------------------------------------------------------*/
  12.  
  13. #pragma option -Vo-
  14. #if defined( __BCOPT__ )
  15. #pragma option -po-
  16. #endif
  17.  
  18. #if !defined( __EVENT_CODES )
  19. #define __EVENT_CODES
  20.  
  21. /* Event codes */
  22.  
  23. const evMouseDown = 0x0001;
  24. const evMouseUp   = 0x0002;
  25. const evMouseMove = 0x0004;
  26. const evMouseAuto = 0x0008;
  27. const evKeyDown   = 0x0010;
  28. const evCommand   = 0x0100;
  29. const evBroadcast = 0x0200;
  30.  
  31. /* Event masks */
  32.  
  33. const evNothing   = 0x0000;
  34. const evMouse     = 0x000f;
  35. const evKeyboard  = 0x0010;
  36. const evMessage   = 0xFF00;
  37.  
  38. /* Mouse button state masks */
  39.  
  40. const mbLeftButton  = 0x01;
  41. const mbRightButton = 0x02;
  42.  
  43. #endif  // __EVENT_CODES
  44.  
  45.  
  46. #if defined( Uses_TEvent ) && !defined( __TEvent )
  47. #define __TEvent
  48.  
  49. struct MouseEventType
  50. {
  51.     uchar buttons;
  52.     Boolean doubleClick;
  53.     TPoint where;
  54. };
  55.  
  56. class THWMouse
  57. {
  58.  
  59. protected:
  60.  
  61.     THWMouse();
  62.     THWMouse( const THWMouse& ) {};
  63.     ~THWMouse();
  64.  
  65.     static void show();
  66.     static void hide();
  67.  
  68.     static void setRange( ushort, ushort );
  69.     static void getEvent( MouseEventType& );
  70.     static void registerHandler( unsigned, void (far *)() );
  71.     static Boolean present();
  72.  
  73.     static void suspend();
  74.     static void resume();
  75.     static void inhibit();
  76.  
  77. protected:
  78.  
  79.     static uchar near buttonCount;
  80.  
  81. private:
  82.  
  83.     static Boolean near handlerInstalled;
  84.     static Boolean near noMouse;
  85.  
  86. };
  87.  
  88. inline Boolean THWMouse::present()
  89. {
  90.     return Boolean( buttonCount != 0 );
  91. }
  92.  
  93. inline void THWMouse::inhibit()
  94. {
  95.     noMouse = True;
  96. }
  97.  
  98. class TMouse : public THWMouse
  99. {
  100.  
  101. public:
  102.  
  103.     TMouse();
  104.     ~TMouse();
  105.  
  106.     static void show();
  107.     static void hide();
  108.  
  109.     static void setRange( ushort, ushort );
  110.  
  111.     static void getEvent( MouseEventType& );
  112.     static void registerHandler( unsigned, void (far *)() );
  113.     static Boolean present();
  114.  
  115.     static void suspend() { THWMouse::suspend(); }
  116.     static void resume() { THWMouse::resume(); show(); }
  117.  
  118. };
  119.  
  120. inline void TMouse::show()
  121. {
  122.     THWMouse::show();
  123. }
  124.  
  125. inline void TMouse::hide()
  126. {
  127.     THWMouse::hide();
  128. }
  129.  
  130. inline void TMouse::setRange( ushort rx, ushort ry )
  131. {
  132.     THWMouse::setRange( rx, ry );
  133. }
  134.  
  135. inline void TMouse::getEvent( MouseEventType& me )
  136. {
  137.     THWMouse::getEvent( me );
  138. }
  139.  
  140. inline void TMouse::registerHandler( unsigned mask, void (far *func)() )
  141. {
  142.     THWMouse::registerHandler( mask, func );
  143. }
  144.  
  145. inline Boolean TMouse::present()
  146. {
  147.     return THWMouse::present();
  148. }
  149.  
  150. struct CharScanType
  151. {
  152.     uchar charCode;
  153.     uchar scanCode;
  154. };
  155.  
  156. struct KeyDownEvent
  157. {
  158.     union
  159.         {
  160.         ushort keyCode;
  161.         CharScanType charScan;
  162.         };
  163. };
  164.  
  165. struct MessageEvent
  166. {
  167.     ushort command;
  168.     union
  169.         {
  170.         void *infoPtr;
  171.         long infoLong;
  172.         ushort infoWord;
  173.         short infoInt;
  174.         uchar infoByte;
  175.         char infoChar;
  176.         };
  177. };
  178.  
  179. struct TEvent
  180. {
  181.     ushort what;
  182.     union
  183.     {
  184.         MouseEventType mouse;
  185.         KeyDownEvent keyDown;
  186.         MessageEvent message;
  187.     };
  188.     void getMouseEvent();
  189.     void getKeyEvent();
  190. };
  191.  
  192. #endif  // Uses_TEvent
  193.  
  194. #if defined( Uses_TEventQueue ) && !defined( __TEventQueue )
  195. #define __TEventQueue
  196.  
  197. class TEventQueue
  198. {
  199. public:
  200.     TEventQueue();
  201.     ~TEventQueue();
  202.  
  203.     static void getMouseEvent( TEvent& );
  204.     static void suspend();
  205.     static void resume();
  206.  
  207.     friend class TView;
  208.     friend void genRefs();
  209.     friend class TProgram;
  210.     static ushort near doubleDelay;
  211.     static Boolean near mouseReverse;
  212.  
  213. private:
  214.  
  215.     static TMouse near mouse;
  216.     static void getMouseState( TEvent& );
  217.     static void huge mouseInt();
  218.  
  219.     static void setLast( TEvent& );
  220.  
  221.     static MouseEventType near lastMouse;
  222.     static MouseEventType near curMouse;
  223.  
  224.     static MouseEventType near downMouse;
  225.     static ushort near downTicks;
  226.  
  227.     static ushort far * near Ticks;
  228.     static TEvent near eventQueue[ eventQSize ];
  229.     static TEvent * near eventQHead;
  230.     static TEvent * near eventQTail;
  231.     static Boolean near mouseIntFlag;
  232.     static ushort near eventCount;
  233.  
  234.     static Boolean near mouseEvents;
  235.  
  236.     static ushort near repeatDelay;
  237.     static ushort near autoTicks;
  238.     static ushort near autoDelay;
  239.  
  240. };
  241.  
  242. inline void TEvent::getMouseEvent()
  243. {
  244.     TEventQueue::getMouseEvent( *this );
  245. }
  246.  
  247. #endif  // Uses_TEventQueue
  248.  
  249. #if defined( Uses_TScreen ) && !defined( __TScreen )
  250. #define __TScreen
  251.  
  252. #ifdef PROTECT
  253.  
  254. extern ushort monoSeg;
  255. extern ushort colrSeg;
  256. extern ushort biosSeg;
  257.  
  258. #endif
  259.  
  260. class TDisplay
  261. {
  262.  
  263. public:
  264.  
  265.     friend class TView;
  266.  
  267.     enum videoModes
  268.         {
  269.         smBW80      = 0x0002,
  270.         smCO80      = 0x0003,
  271.         smMono      = 0x0007,
  272.         smFont8x8   = 0x0100
  273.         };
  274.  
  275.     static void clearScreen( uchar, uchar );
  276.  
  277.     static void setCursorType( ushort );
  278.     static ushort getCursorType();
  279.  
  280.     static ushort getRows();
  281.     static ushort getCols();
  282.  
  283.     static void setCrtMode( ushort );
  284.     static ushort getCrtMode();
  285.  
  286. protected:
  287.  
  288.     TDisplay() { updateIntlChars(); };
  289.     TDisplay( const TDisplay& ) { updateIntlChars(); };
  290.     ~TDisplay() {};
  291.  
  292. private:
  293.  
  294.     static void videoInt();
  295.     static void updateIntlChars();
  296.  
  297.     static ushort far * near equipment;
  298.     static uchar far * near crtInfo;
  299.     static uchar far * near crtRows;
  300.  
  301. };
  302.  
  303. class TScreen : public TDisplay
  304. {
  305.  
  306. public:
  307.  
  308.     TScreen();
  309.     ~TScreen();
  310.  
  311.     static void setVideoMode( ushort mode );
  312.     static void clearScreen();
  313.  
  314.     static ushort near startupMode;
  315.     static ushort near startupCursor;
  316.     static ushort near screenMode;
  317.     static uchar near screenWidth;
  318.     static uchar near screenHeight;
  319.     static Boolean near hiResScreen;
  320.     static Boolean near checkSnow;
  321.     static uchar far * near screenBuffer;
  322.     static ushort near cursorLines;
  323.  
  324.     static void setCrtData();
  325.     static ushort fixCrtMode( ushort );
  326.  
  327.     static void suspend();
  328.     static void resume();
  329.  
  330. };
  331.  
  332. #endif  // Uses_TScreen
  333.  
  334. #if defined( Uses_TSystemError ) && !defined( __TSystemError )
  335. #define __TSystemError
  336.  
  337. class far TDrawBuffer;
  338.  
  339. class TSystemError
  340. {
  341.  
  342. public:
  343.  
  344.     TSystemError();
  345.     ~TSystemError();
  346.  
  347.     static Boolean near ctrlBreakHit;
  348.  
  349.     static void suspend();
  350.     static void resume();
  351.     static short ( far *sysErrorFunc )( short, uchar );
  352.  
  353. private:
  354.  
  355.     static ushort near sysColorAttr;
  356.     static ushort near sysMonoAttr;
  357.     static Boolean near saveCtrlBreak;
  358.     static Boolean near sysErrActive;
  359.  
  360.     static void swapStatusLine( TDrawBuffer far & );
  361.     static ushort selectKey();
  362.     static short sysErr( short, uchar );
  363.  
  364.     static Boolean near inIDE;
  365.  
  366.     static const char *const near errorString[14];
  367.     static const char * near sRetryOrCancel;
  368.  
  369.     friend class Int11trap;
  370.  
  371. };
  372.  
  373. class Int11trap
  374. {
  375.  
  376. public:
  377.  
  378.     Int11trap();
  379.     ~Int11trap();
  380.  
  381. private:
  382.  
  383.     static void interrupt handler(...);
  384.     static void interrupt (far * near oldHandler)(...);
  385.  
  386. };
  387.  
  388.  
  389. #endif  // Uses_TSystemError
  390.  
  391. #pragma option -Vo.
  392. #if defined( __BCOPT__ )
  393. #pragma option -po.
  394. #endif
  395.