You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
4.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. Modified by Robert H�hne to be used for RHIDE.
  8. Modified by Salvador E. Tropea (setScreenMode and other things)
  9. *
  10. *
  11. */
  12. #if defined( Uses_TProgram ) && !defined( __TProgram )
  13. #define __TProgram
  14. #define cpColor \
  15. "\x71\x70\x78\x74\x20\x28\x24\x17\x1F\x1A\x31\x31\x1E\x71\x00" \
  16. "\x37\x3F\x3A\x13\x13\x3E\x21\x00\x70\x7F\x7A\x13\x13\x70\x7F\x00" \
  17. "\x70\x7F\x7A\x13\x13\x70\x70\x7F\x7E\x20\x2B\x2F\x78\x2E\x70\x30" \
  18. "\x3F\x3E\x1F\x2F\x1A\x20\x72\x31\x31\x30\x2F\x3E\x31\x13\x38\x00"
  19. #define cpBlackWhite \
  20. "\x70\x70\x78\x7F\x07\x07\x0F\x07\x0F\x07\x70\x70\x07\x70\x00" \
  21. "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x7F\x7F\x70\x07\x70\x07\x00" \
  22. "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  23. "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x07\x00"
  24. #define cpMonochrome \
  25. "\x70\x07\x07\x0F\x70\x70\x70\x07\x0F\x07\x70\x70\x07\x70\x00" \
  26. "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x70\x70\x07\x07\x70\x07\x00" \
  27. "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  28. "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x07\x00"
  29. class TStatusLine;
  30. class TMenuBar;
  31. class TDeskTop;
  32. struct TEvent;
  33. class TView;
  34. class TScreen;
  35. class TVMainConfigFile;
  36. class TProgInit
  37. {
  38. public:
  39. TProgInit( TStatusLine *(*cStatusLine)( TRect ),
  40. TMenuBar *(*cMenuBar)( TRect ),
  41. TDeskTop *(*cDeskTop )( TRect )
  42. );
  43. virtual ~TProgInit();
  44. static TVMainConfigFile *config;
  45. protected:
  46. TStatusLine *(*createStatusLine)( TRect );
  47. TMenuBar *(*createMenuBar)( TRect );
  48. TDeskTop *(*createDeskTop)( TRect );
  49. static TScreen *tsc;
  50. };
  51. /* ---------------------------------------------------------------------- */
  52. /* class TProgram */
  53. /* */
  54. /* Palette layout */
  55. /* 1 = TBackground */
  56. /* 2- 7 = TMenuView and TStatusLine */
  57. /* 8-15 = TWindow(Blue) */
  58. /* 16-23 = TWindow(Cyan) */
  59. /* 24-31 = TWindow(Gray) */
  60. /* 32-63 = TDialog */
  61. /* ---------------------------------------------------------------------- */
  62. const int
  63. // TApplication palette entries
  64. apColor = 0,
  65. apBlackWhite = 1,
  66. apMonochrome = 2;
  67. class TProgram : public TGroup, public virtual TProgInit
  68. {
  69. public:
  70. TProgram();
  71. virtual ~TProgram();
  72. virtual void getEvent(TEvent& event);
  73. virtual TPalette& getPalette() const;
  74. virtual void handleEvent(TEvent& event);
  75. virtual void idle();
  76. virtual void initScreen();
  77. virtual void outOfMemory();
  78. virtual void putEvent( TEvent& event );
  79. virtual void run();
  80. void setScreenMode( ushort mode, char *comm=0 );
  81. void setScreenMode( unsigned w, unsigned h, int fW=-1, int fH=-1 );
  82. TView *validView( TView *p );
  83. virtual void shutDown();
  84. virtual void suspend() {}
  85. virtual void resume() {}
  86. // This is a very nasty function only needed if you call
  87. // TScreen::resume bypassing TProgram::resume. In this case
  88. // the buffers could get unsychronized. This is done by
  89. // RHIDE.
  90. void syncScreenBuffer();
  91. // { buffer = TScreen::screenBuffer; }
  92. static TStatusLine *initStatusLine( TRect );
  93. static TMenuBar *initMenuBar( TRect );
  94. static TDeskTop *initDeskTop( TRect );
  95. static TProgram * application;
  96. static TStatusLine * statusLine;
  97. static TMenuBar * menuBar;
  98. static TDeskTop * deskTop;
  99. static int appPalette;
  100. // Added by SET
  101. static clock_t lastIdleClock; // That's the value of clock in the moment
  102. // when idle is called. Used to accumulate
  103. // in the inIdleTime var
  104. static clock_t inIdleTime; // That keeps track of the number of clocks
  105. // elapsed since we entered in idle
  106. static Boolean inIdle; // Indicates that we are in idle, a mouse or
  107. // keyboard event resets it
  108. // I think that sometimes we can have a long elapsed time without events
  109. // so I provide a way to reset it
  110. static void resetIdleTime() { inIdle=False; };
  111. // SET: By default that's 0 and the idle member releases the CPU to the
  112. // OS. If for some reason you really need to avoid it and want to use
  113. // 100% of the CPU just assign 1 to this variable.
  114. static char doNotReleaseCPU;
  115. protected:
  116. static TEvent pending;
  117. private:
  118. // static const char * exitText;
  119. };
  120. #endif