PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/Extras/wxWidgets-2.9.0/include/wx/gtk/print.h

https://bitbucket.org/erwincoumans/dynamicaopencl
C Header | 354 lines | 246 code | 71 blank | 37 comment | 0 complexity | 976fc1db60f3aa90a45def774774103c MD5 | raw file
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/print.h
  3. // Author: Anthony Bretaudeau
  4. // Purpose: GTK printing support
  5. // Created: 2007-08-25
  6. // RCS-ID: $Id: print.h,v 1 2007-08-25 05:44:44 PC Exp $
  7. // Copyright: (c) Anthony Bretaudeau
  8. // Licence: wxWindows Licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GTK_PRINT_H_
  11. #define _WX_GTK_PRINT_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_GTKPRINT
  14. #include "wx/print.h"
  15. #include "wx/printdlg.h"
  16. #include "wx/prntbase.h"
  17. #include "wx/dc.h"
  18. #include "wx/cairo.h"
  19. typedef struct _GtkPrintOperation GtkPrintOperation;
  20. typedef struct _GtkPrintContext GtkPrintContext;
  21. typedef struct _GtkPrintSettings GtkPrintSettings;
  22. typedef struct _GtkPageSetup GtkPageSetup;
  23. typedef struct _cairo cairo_t;
  24. //----------------------------------------------------------------------------
  25. // wxGtkPrintFactory
  26. //----------------------------------------------------------------------------
  27. class wxGtkPrintFactory: public wxPrintFactory
  28. {
  29. public:
  30. virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
  31. virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
  32. wxPrintout *printout = NULL,
  33. wxPrintDialogData *data = NULL );
  34. virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
  35. wxPrintout *printout,
  36. wxPrintData *data );
  37. virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
  38. wxPrintDialogData *data = NULL );
  39. virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
  40. wxPrintData *data );
  41. virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
  42. wxPageSetupDialogData * data = NULL );
  43. virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data );
  44. virtual bool HasPrintSetupDialog();
  45. virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data );
  46. virtual bool HasOwnPrintToFile();
  47. virtual bool HasPrinterLine();
  48. virtual wxString CreatePrinterLine();
  49. virtual bool HasStatusLine();
  50. virtual wxString CreateStatusLine();
  51. virtual wxPrintNativeDataBase *CreatePrintNativeData();
  52. };
  53. //----------------------------------------------------------------------------
  54. // wxGtkPrintDialog
  55. //----------------------------------------------------------------------------
  56. class WXDLLIMPEXP_CORE wxGtkPrintDialog: public wxPrintDialogBase
  57. {
  58. public:
  59. wxGtkPrintDialog( wxWindow *parent,
  60. wxPrintDialogData* data = NULL );
  61. wxGtkPrintDialog( wxWindow *parent, wxPrintData* data);
  62. virtual ~wxGtkPrintDialog();
  63. wxPrintData& GetPrintData()
  64. { return m_printDialogData.GetPrintData(); }
  65. wxPrintDialogData& GetPrintDialogData()
  66. { return m_printDialogData; }
  67. wxDC *GetPrintDC() { return m_dc; }
  68. void SetPrintDC(wxDC * printDC) { m_dc = printDC; }
  69. virtual int ShowModal();
  70. virtual bool Validate() { return true; }
  71. virtual bool TransferDataToWindow() { return true; }
  72. virtual bool TransferDataFromWindow() { return true; }
  73. void SetShowDialog(bool show) { m_showDialog = show; }
  74. bool GetShowDialog() { return m_showDialog; }
  75. protected:
  76. // Implement some base class methods to do nothing to avoid asserts and
  77. // GTK warnings, since this is not a real wxDialog.
  78. virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
  79. int WXUNUSED(width), int WXUNUSED(height),
  80. int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
  81. virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
  82. int WXUNUSED(width), int WXUNUSED(height)) {}
  83. private:
  84. wxPrintDialogData m_printDialogData;
  85. wxWindow *m_parent;
  86. bool m_showDialog;
  87. wxDC *m_dc;
  88. DECLARE_DYNAMIC_CLASS(wxGtkPrintDialog)
  89. };
  90. //----------------------------------------------------------------------------
  91. // wxGtkPageSetupDialog
  92. //----------------------------------------------------------------------------
  93. class WXDLLIMPEXP_CORE wxGtkPageSetupDialog: public wxPageSetupDialogBase
  94. {
  95. public:
  96. wxGtkPageSetupDialog( wxWindow *parent,
  97. wxPageSetupDialogData* data = NULL );
  98. virtual ~wxGtkPageSetupDialog();
  99. virtual wxPageSetupDialogData& GetPageSetupDialogData() { return m_pageDialogData; }
  100. virtual int ShowModal();
  101. virtual bool Validate() { return true; }
  102. virtual bool TransferDataToWindow() { return true; }
  103. virtual bool TransferDataFromWindow() { return true; }
  104. protected:
  105. // Implement some base class methods to do nothing to avoid asserts and
  106. // GTK warnings, since this is not a real wxDialog.
  107. virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
  108. int WXUNUSED(width), int WXUNUSED(height),
  109. int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
  110. virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
  111. int WXUNUSED(width), int WXUNUSED(height)) {}
  112. private:
  113. wxPageSetupDialogData m_pageDialogData;
  114. wxWindow *m_parent;
  115. DECLARE_DYNAMIC_CLASS(wxGtkPageSetupDialog)
  116. };
  117. //----------------------------------------------------------------------------
  118. // wxGtkPrinter
  119. //----------------------------------------------------------------------------
  120. class WXDLLIMPEXP_CORE wxGtkPrinter : public wxPrinterBase
  121. {
  122. public:
  123. wxGtkPrinter(wxPrintDialogData *data = NULL);
  124. virtual ~wxGtkPrinter();
  125. virtual bool Print(wxWindow *parent,
  126. wxPrintout *printout,
  127. bool prompt = true);
  128. virtual wxDC* PrintDialog(wxWindow *parent);
  129. virtual bool Setup(wxWindow *parent);
  130. GtkPrintContext *GetPrintContext() { return m_gpc; }
  131. void SetPrintContext(GtkPrintContext *context) {m_gpc = context;}
  132. void BeginPrint(wxPrintout *printout, GtkPrintOperation *operation, GtkPrintContext *context);
  133. void DrawPage(wxPrintout *printout, GtkPrintOperation *operation, GtkPrintContext *context, int page_nr);
  134. private:
  135. GtkPrintContext *m_gpc;
  136. wxDC *m_dc;
  137. DECLARE_DYNAMIC_CLASS(wxGtkPrinter)
  138. wxDECLARE_NO_COPY_CLASS(wxGtkPrinter);
  139. };
  140. //----------------------------------------------------------------------------
  141. // wxGtkPrintNativeData
  142. //----------------------------------------------------------------------------
  143. class WXDLLIMPEXP_CORE wxGtkPrintNativeData : public wxPrintNativeDataBase
  144. {
  145. public:
  146. wxGtkPrintNativeData();
  147. virtual ~wxGtkPrintNativeData();
  148. virtual bool TransferTo( wxPrintData &data );
  149. virtual bool TransferFrom( const wxPrintData &data );
  150. virtual bool Ok() const { return IsOk(); }
  151. virtual bool IsOk() const { return true; }
  152. GtkPrintSettings* GetPrintConfig() { return m_config; }
  153. void SetPrintConfig( GtkPrintSettings * config );
  154. void SetPrintJob( GtkPrintOperation *job ) { m_job = job; }
  155. GtkPrintOperation* GetPrintJob() { return m_job; }
  156. GtkPrintContext *GetPrintContext() { return m_context; }
  157. void SetPrintContext(GtkPrintContext *context) {m_context = context; }
  158. GtkPageSetup* GetPageSetupFromSettings(GtkPrintSettings* settings);
  159. void SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup);
  160. private:
  161. GtkPrintSettings *m_config;
  162. GtkPrintOperation *m_job;
  163. GtkPrintContext *m_context;
  164. DECLARE_DYNAMIC_CLASS(wxGtkPrintNativeData)
  165. };
  166. //-----------------------------------------------------------------------------
  167. // wxGtkPrinterDC
  168. //-----------------------------------------------------------------------------
  169. class WXDLLIMPEXP_CORE wxGtkPrinterDCImpl : public wxDCImpl
  170. {
  171. public:
  172. wxGtkPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data );
  173. virtual ~wxGtkPrinterDCImpl();
  174. bool Ok() const { return IsOk(); }
  175. bool IsOk() const;
  176. virtual void* GetCairoContext() const;
  177. bool CanDrawBitmap() const { return true; }
  178. void Clear();
  179. void SetFont( const wxFont& font );
  180. void SetPen( const wxPen& pen );
  181. void SetBrush( const wxBrush& brush );
  182. void SetLogicalFunction( wxRasterOperationMode function );
  183. void SetBackground( const wxBrush& brush );
  184. void DestroyClippingRegion();
  185. bool StartDoc(const wxString& message);
  186. void EndDoc();
  187. void StartPage();
  188. void EndPage();
  189. wxCoord GetCharHeight() const;
  190. wxCoord GetCharWidth() const;
  191. bool CanGetTextExtent() const { return true; }
  192. wxSize GetPPI() const;
  193. virtual int GetDepth() const { return 24; }
  194. void SetBackgroundMode(int mode);
  195. void SetPalette(const wxPalette& WXUNUSED(palette)) { }
  196. void SetResolution(int ppi);
  197. // overriden for wxPrinterDC Impl
  198. virtual int GetResolution() const;
  199. virtual wxRect GetPaperRect() const;
  200. protected:
  201. bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col,
  202. wxFloodFillStyle style=wxFLOOD_SURFACE );
  203. void DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter);
  204. void DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection = wxEAST);
  205. bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
  206. void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
  207. void DoCrossHair(wxCoord x, wxCoord y);
  208. void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
  209. void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
  210. void DoDrawPoint(wxCoord x, wxCoord y);
  211. void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
  212. void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE);
  213. void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE);
  214. void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  215. void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0);
  216. void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  217. #if wxUSE_SPLINES
  218. void DoDrawSpline(const wxPointList *points);
  219. #endif
  220. bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
  221. wxDC *source, wxCoord xsrc, wxCoord ysrc,
  222. wxRasterOperationMode rop = wxCOPY, bool useMask = false,
  223. wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
  224. void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y );
  225. void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false );
  226. void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
  227. void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
  228. void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
  229. void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip) )
  230. {
  231. wxFAIL_MSG( "not implemented" );
  232. }
  233. void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
  234. wxCoord *descent = NULL,
  235. wxCoord *externalLeading = NULL,
  236. const wxFont *theFont = NULL ) const;
  237. void DoGetSize(int* width, int* height) const;
  238. void DoGetSizeMM(int *width, int *height) const;
  239. wxPrintData& GetPrintData() { return m_printData; }
  240. void SetPrintData(const wxPrintData& data);
  241. private:
  242. wxPrintData m_printData;
  243. PangoContext *m_context;
  244. PangoLayout *m_layout;
  245. PangoFontDescription *m_fontdesc;
  246. cairo_t *m_cairo;
  247. unsigned char m_currentRed;
  248. unsigned char m_currentGreen;
  249. unsigned char m_currentBlue;
  250. unsigned char m_currentAlpha;
  251. GtkPrintContext *m_gpc;
  252. int m_resolution;
  253. double m_PS2DEV;
  254. double m_DEV2PS;
  255. DECLARE_DYNAMIC_CLASS(wxGtkPrinterDCImpl)
  256. wxDECLARE_NO_COPY_CLASS(wxGtkPrinterDCImpl);
  257. };
  258. // ----------------------------------------------------------------------------
  259. // wxGtkPrintPreview: programmer creates an object of this class to preview a
  260. // wxPrintout.
  261. // ----------------------------------------------------------------------------
  262. class WXDLLIMPEXP_CORE wxGtkPrintPreview : public wxPrintPreviewBase
  263. {
  264. public:
  265. wxGtkPrintPreview(wxPrintout *printout,
  266. wxPrintout *printoutForPrinting = NULL,
  267. wxPrintDialogData *data = NULL);
  268. wxGtkPrintPreview(wxPrintout *printout,
  269. wxPrintout *printoutForPrinting,
  270. wxPrintData *data);
  271. virtual ~wxGtkPrintPreview();
  272. virtual bool Print(bool interactive);
  273. virtual void DetermineScaling();
  274. private:
  275. void Init(wxPrintout *printout,
  276. wxPrintout *printoutForPrinting,
  277. wxPrintData *data);
  278. // resolution to use in DPI
  279. int m_resolution;
  280. DECLARE_CLASS(wxGtkPrintPreview)
  281. };
  282. #endif // wxUSE_GTKPRINT
  283. #endif // _WX_GTK_PRINT_H_