dcpsg.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/dcpsg.h
  3. // Purpose: wxPostScriptDC class
  4. // Author: Julian Smart and others
  5. // Modified by:
  6. // Copyright: (c) Julian Smart and Robert Roebling
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_DCPSG_H_
  10. #define _WX_DCPSG_H_
  11. #include "wx/defs.h"
  12. #if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT
  13. #include "wx/dc.h"
  14. #include "wx/dcprint.h"
  15. #include "wx/dialog.h"
  16. #include "wx/module.h"
  17. #include "wx/cmndata.h"
  18. #include "wx/strvararg.h"
  19. //-----------------------------------------------------------------------------
  20. // wxPostScriptDC
  21. //-----------------------------------------------------------------------------
  22. class WXDLLIMPEXP_CORE wxPostScriptDC : public wxDC
  23. {
  24. public:
  25. wxPostScriptDC();
  26. // Recommended constructor
  27. wxPostScriptDC(const wxPrintData& printData);
  28. private:
  29. DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
  30. };
  31. class WXDLLIMPEXP_CORE wxPostScriptDCImpl : public wxDCImpl
  32. {
  33. public:
  34. wxPostScriptDCImpl( wxPrinterDC *owner );
  35. wxPostScriptDCImpl( wxPrinterDC *owner, const wxPrintData& data );
  36. wxPostScriptDCImpl( wxPostScriptDC *owner );
  37. wxPostScriptDCImpl( wxPostScriptDC *owner, const wxPrintData& data );
  38. void Init();
  39. virtual ~wxPostScriptDCImpl();
  40. virtual bool Ok() const { return IsOk(); }
  41. virtual bool IsOk() const;
  42. bool CanDrawBitmap() const { return true; }
  43. void Clear();
  44. void SetFont( const wxFont& font );
  45. void SetPen( const wxPen& pen );
  46. void SetBrush( const wxBrush& brush );
  47. void SetLogicalFunction( wxRasterOperationMode function );
  48. void SetBackground( const wxBrush& brush );
  49. void DestroyClippingRegion();
  50. bool StartDoc(const wxString& message);
  51. void EndDoc();
  52. void StartPage();
  53. void EndPage();
  54. wxCoord GetCharHeight() const;
  55. wxCoord GetCharWidth() const;
  56. bool CanGetTextExtent() const { return true; }
  57. // Resolution in pixels per logical inch
  58. wxSize GetPPI() const;
  59. virtual void ComputeScaleAndOrigin();
  60. void SetBackgroundMode(int WXUNUSED(mode)) { }
  61. void SetPalette(const wxPalette& WXUNUSED(palette)) { }
  62. void SetPrintData(const wxPrintData& data);
  63. wxPrintData& GetPrintData() { return m_printData; }
  64. virtual int GetDepth() const { return 24; }
  65. void PsPrint( const wxString& psdata );
  66. // Overrridden for wxPrinterDC Impl
  67. virtual int GetResolution() const;
  68. virtual wxRect GetPaperRect() const;
  69. virtual void* GetHandle() const { return NULL; }
  70. protected:
  71. bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col,
  72. wxFloodFillStyle style = wxFLOOD_SURFACE);
  73. bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
  74. void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
  75. void DoCrossHair(wxCoord x, wxCoord y) ;
  76. void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
  77. void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
  78. void DoDrawPoint(wxCoord x, wxCoord y);
  79. void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
  80. void DoDrawPolygon(int n, const wxPoint points[],
  81. wxCoord xoffset = 0, wxCoord yoffset = 0,
  82. wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
  83. void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
  84. wxCoord xoffset = 0, wxCoord yoffset = 0,
  85. wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
  86. void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  87. void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20);
  88. void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  89. #if wxUSE_SPLINES
  90. void DoDrawSpline(const wxPointList *points);
  91. #endif
  92. bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
  93. wxDC *source, wxCoord xsrc, wxCoord ysrc,
  94. wxRasterOperationMode rop = wxCOPY, bool useMask = false,
  95. wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
  96. void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
  97. void DoDrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false);
  98. void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
  99. void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
  100. void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  101. void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip))
  102. {
  103. wxFAIL_MSG( "not implemented" );
  104. }
  105. void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
  106. wxCoord *descent = NULL,
  107. wxCoord *externalLeading = NULL,
  108. const wxFont *theFont = NULL) const;
  109. void DoGetSize(int* width, int* height) const;
  110. void DoGetSizeMM(int *width, int *height) const;
  111. FILE* m_pstream; // PostScript output stream
  112. unsigned char m_currentRed;
  113. unsigned char m_currentGreen;
  114. unsigned char m_currentBlue;
  115. int m_pageNumber;
  116. bool m_clipping;
  117. double m_underlinePosition;
  118. double m_underlineThickness;
  119. wxPrintData m_printData;
  120. double m_pageHeight;
  121. private:
  122. DECLARE_DYNAMIC_CLASS(wxPostScriptDCImpl)
  123. };
  124. #endif
  125. // wxUSE_POSTSCRIPT && wxUSE_PRINTING_ARCHITECTURE
  126. #endif
  127. // _WX_DCPSG_H_