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