SapGraphic.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef _SAPGRAPHIC_H_
  2. #define _SAPGRAPHIC_H_
  3. // SapGraphic.h : header file
  4. //
  5. #include "SapClassBasicDef.h"
  6. //
  7. // SapGraphic class declaration
  8. //
  9. class SAPCLASSBASIC_CLASS SapGraphic : public SapManager
  10. {
  11. public:
  12. // Drawing modes
  13. typedef int DrawMode;
  14. enum _DrawMode
  15. {
  16. ModeReplace = CORGRAPHIC_VAL_OPM_REP,
  17. ModeAnd = CORGRAPHIC_VAL_OPM_AND,
  18. ModeOr = CORGRAPHIC_VAL_OPM_OR,
  19. ModeXor = CORGRAPHIC_VAL_OPM_XOR
  20. };
  21. // Text alignment
  22. typedef int TextAlign;
  23. enum _TextAlign
  24. {
  25. TextLeft = CORGRAPHIC_VAL_TEXTALIGN_L,
  26. TextCenter = CORGRAPHIC_VAL_TEXTALIGN_C,
  27. TextRight = CORGRAPHIC_VAL_TEXTALIGN_R
  28. };
  29. public:
  30. // Constructor/Destructor
  31. SapGraphic(SapLocation loc = SapLocation::ServerSystem);
  32. SapGraphic(const SapGraphic &graph);
  33. virtual ~SapGraphic();
  34. SapGraphic &operator=(const SapGraphic &graph);
  35. // Module create/destroy
  36. virtual BOOL Create();
  37. virtual BOOL Destroy();
  38. // Access to implementation
  39. CORHANDLE GetHandle() const { return m_hGraphic; }
  40. SapLocation GetLocation() const { return m_Location; }
  41. DrawMode GetDrawMode() const { return m_DrawMode; }
  42. BOOL GetTransparency() const { return m_IsTransparent; }
  43. SapData GetColor() const { return m_Color; }
  44. SapData GetBackColor() const { return m_BackColor; }
  45. TextAlign GetTextAlign() const { return m_TextAlign; }
  46. BOOL SetLocation(SapLocation location);
  47. virtual BOOL SetDrawMode(DrawMode drawMode);
  48. virtual BOOL SetTransparency(BOOL isTransparent);
  49. virtual BOOL SetColor(SapData color);
  50. virtual BOOL SetBackColor(SapData backColor);
  51. virtual BOOL SetTextAlign(TextAlign textAlign);
  52. virtual BOOL SetBatchMode(BOOL batchMode, SapView *pView);
  53. virtual BOOL IsCapabilityValid(int cap);
  54. virtual BOOL GetCapability(int cap, void *pValue);
  55. virtual BOOL IsParameterValid(int param);
  56. virtual BOOL GetParameter(int param, void *pValue);
  57. virtual BOOL SetParameter(int param, int value);
  58. virtual BOOL SetParameter(int param, void *pValue);
  59. // Drawing methods
  60. BOOL Circle(SapBuffer *pBuffer, int x, int y, int radius, BOOL fill = FALSE);
  61. BOOL Circle(SapView *pView, int x, int y, int radius, BOOL fill = FALSE);
  62. BOOL Clear(SapBuffer *pBuffer);
  63. BOOL Clear(SapView *pView);
  64. BOOL Dot(SapBuffer *pBuffer, int x, int y);
  65. BOOL Dot(SapView *pView, int x, int y);
  66. BOOL Ellipse(SapBuffer *pBuffer, int x, int y, int xRadius, int yRadius, BOOL fill = FALSE);
  67. BOOL Ellipse(SapView *pView, int x, int y, int xRadius, int yRadius, BOOL fill = FALSE);
  68. BOOL Line(SapBuffer *pBuffer, int x1, int y1, int x2, int y2);
  69. BOOL Line(SapView *pView, int x1, int y1, int x2, int y2);
  70. BOOL Rectangle(SapBuffer *pBuffer, int x1, int y1, int x2, int y2, BOOL fill = FALSE);
  71. BOOL Rectangle(SapView *pView, int x1, int y1, int x2, int y2, BOOL fill = FALSE);
  72. BOOL Text(SapBuffer *pBuffer, int x, int y, const char *text);
  73. BOOL Text(SapView *pView, int x, int y, const char *text);
  74. BOOL Flush(SapView *pView, int x1 = 0, int y1 = 0, int x2 = -1, int y2 = -1);
  75. protected:
  76. // Utility methods
  77. void Construct(SapLocation loc, DrawMode drawMode, SapData color, SapData backColor, TextAlign textAlign);
  78. BOOL EnableBatchMode(SapView *pView);
  79. BOOL DisableBatchMode();
  80. BOOL InitSapDrawing(SapView *pView);
  81. BOOL InitGDIDrawing(SapView *pView, BOOL fill);
  82. BOOL InitGDITextDrawing(SapView *pView);
  83. BOOL EndGDIDrawing(SapView *pView);
  84. HDC GetDrawingDC() { return m_BatchMode ? m_hBatchDC : m_hDC; }
  85. protected:
  86. SapLocation m_Location;
  87. CORGRAPHIC m_hGraphic;
  88. // Parameters
  89. DrawMode m_DrawMode; // Drawing mode between foreground color and destination
  90. BOOL m_IsTransparent; // TRUE if transparent drawing (background remains unchanged)
  91. SapData m_Color; // Foreground drawing color
  92. SapData m_BackColor; // Background drawing color
  93. TextAlign m_TextAlign; // Text alignment
  94. BOOL m_IsNewColor; // TRUE when foreground color value has changed
  95. // Windows GDI objects used for drawing on the image overlay
  96. HFONT m_hFont;
  97. HGDIOBJ m_hOldFont; // Initial font for device context
  98. HBRUSH m_hBrush;
  99. HGDIOBJ m_hOldBrush; // Initial brush for device context
  100. HPEN m_hPen;
  101. HGDIOBJ m_hOldPen; // Initial pen for device context
  102. HDC m_hDC;
  103. // Management of batch (buffered) drawing in the image overlay
  104. BOOL m_BatchMode; // TRUE if batch drawing is active
  105. SapView *m_pBatchView; // View object to which batch drawing applies
  106. HDC m_hBatchDC; // Memory device context for drawing
  107. HBITMAP m_hBatchBitmap; // Bitmap to draw into
  108. HGDIOBJ m_hOldBatchBitmap; // Initial bitmap for batch device context
  109. // Buffer used for non-primary VGA overlay drawing
  110. CORBUFFER m_hBuffer;
  111. };
  112. #endif // _SAPGRAPHIC_H_