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.

186 lines
4.6 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Windows GUI screen routines header.
  3. *
  4. * Copyright (c) 2002 by Jos� Angel S�nchez Caso (JASC)
  5. * Copyright (c) 2002 by Salvador E. Tropea (SET)
  6. *
  7. * From SET code fragment win 32 driver.
  8. *
  9. * Covered by the GPL license.
  10. */
  11. #if defined(TVOS_Win32) && !defined(WINGRSCR_HEADER_INCLUDED)
  12. #define WINGRSCR_HEADER_INCLUDED
  13. #if defined( TV_BIG_ENDIAN ) /* Intel machines */
  14. #define attrChar(a) ((a) >> 0x08)
  15. #define attrColor(a) ((a) & 0xFF)
  16. #else
  17. #define attrChar(a) ((a) & 0xFF)
  18. #define attrColor(a) ((a) >> 0x08)
  19. #endif
  20. typedef struct
  21. { short font;
  22. short mode;
  23. } dialogModeRec;
  24. struct TDisplayWinGr : public virtual TDisplay // virtual to avoid problems with multiple inheritance
  25. { static bool processEvent( );
  26. static void testCreate( HWND hw
  27. , LPARAM lParam );
  28. static int testEvents( UINT message
  29. , WPARAM wParam
  30. , LPARAM lParam );
  31. static unsigned xPos; /* Cursor pos */
  32. static unsigned yPos; /* Cursor pos */
  33. static unsigned zPos; /* Cursor size */
  34. static HDC hdc; /* A device context used for drawing */
  35. static LOGFONTA * fonts; // To hold available fonts
  36. static void Init(); // This sets the pointers of TDisplay to point to this class
  37. static void lowSetCursor( int x
  38. , int y
  39. , bool dir );
  40. protected:
  41. TDisplayWinGr() {};
  42. virtual ~TDisplayWinGr(); // We will use casts to base classes, destructors must be pointers
  43. // Behaviors to replace TDisplay
  44. static void SetCursorPos ( unsigned x , unsigned y );
  45. static void GetCursorPos ( unsigned &x , unsigned &y );
  46. static void GetCursorShape( unsigned &start, unsigned &end);
  47. static void SetCursorShape( unsigned start , unsigned end );
  48. static ushort GetRows();
  49. static ushort GetCols();
  50. static ushort GetCrtMode();
  51. static void SetCrtMode(ushort);
  52. static void SetCrtModeExt(char *);
  53. static const char *GetWindowTitle(void);
  54. static int SetWindowTitle(const char *name);
  55. static int CheckForWindowSize(void);
  56. static void SetFontMode( int fontIdx );
  57. static void Beep();
  58. // Support functions
  59. static void winRecalc( int w
  60. , int h );
  61. static void SetCrtMode( const char * );
  62. // Support variables
  63. static int sizeChanged; /* Resizing counter */
  64. static int forceRedraw; /* Used to force setCharacters to unconditionally draw */
  65. static TEvent storedEvent; /* Correctly processes message queue */
  66. static HFONT hFont;
  67. public:
  68. static HWND hwnd;
  69. static COLORREF colorMap[ 16 ];
  70. static TEXTMETRIC tm;
  71. static HCURSOR normCursor;
  72. static HCURSOR sizeCursor;
  73. static HCURSOR handCursor;
  74. static RECT mSize; /* Windows resizing calculations */
  75. static char cShapeFr;
  76. static char cShapeTo;
  77. static dialogModeRec mode;
  78. };
  79. // With this order the destructor will be called first for TScreenWin32,
  80. // TScreen, TDisplayWin32 and finally TDisplay.
  81. struct TScreenWinGr: public virtual TDisplayWinGr
  82. , public TScreen
  83. { TScreenWinGr(); // We will use casts to base classes, destructors must be pointers
  84. static void Init();
  85. virtual ~TScreenWinGr();
  86. protected:
  87. // Default: ushort fixCrtMode( ushort mode )
  88. // Default: static void setCrtData();
  89. // Default: static void setVideoModeExt(char *mode);
  90. // Default: static void getCharacters(unsigned offset,ushort *buf,unsigned count);
  91. // Default: static ushort getCharacter(unsigned dst);
  92. static void setVideoMode(ushort mode);
  93. static void Resume();
  94. static void Suspend();
  95. static void clearScreen();
  96. static void setCharacter( unsigned offset
  97. , ushort value );
  98. static void setCharacters( unsigned dst
  99. , ushort *src
  100. , unsigned len );
  101. static int System(const char *command
  102. , pid_t *pidChild
  103. , int in
  104. , int out
  105. , int err);
  106. // Support functions
  107. static void SaveScreen();
  108. static void SaveScreenReleaseMemory();
  109. static void RestoreScreen();
  110. static void Done();
  111. public:
  112. static void writeLine( unsigned x
  113. , unsigned y
  114. , int w
  115. , char * str
  116. , uchar color );
  117. // Support variables
  118. };
  119. LRESULT CALLBACK WindowProcedure( HWND hwnd /* This function is called by the Windowsfunction DispatchMessage( ) */
  120. , UINT message
  121. , WPARAM wParam
  122. , LPARAM lParam );
  123. #endif // WINDOWSSCR_HEADER_INCLUDED