]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/print.h
Remove wxDialogNameStr definition which should have been removed in r49873.
[wxWidgets.git] / include / wx / gtk / print.h
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
11 #ifndef _WX_GTK_PRINT_H_
12 #define _WX_GTK_PRINT_H_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_GTKPRINT
17
18 #include "wx/print.h"
19 #include "wx/printdlg.h"
20 #include "wx/prntbase.h"
21 #include "wx/dc.h"
22 #include "wx/cairo.h"
23
24
25 typedef struct _GtkPrintOperation GtkPrintOperation;
26 typedef struct _GtkPrintContext GtkPrintContext;
27 typedef struct _GtkPrintSettings GtkPrintSettings;
28 typedef struct _GtkPageSetup GtkPageSetup;
29
30 typedef struct _cairo cairo_t;
31
32 //----------------------------------------------------------------------------
33 // wxGtkPrintFactory
34 //----------------------------------------------------------------------------
35
36 class wxGtkPrintFactory: public wxPrintFactory
37 {
38 public:
39 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
40
41 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
42 wxPrintout *printout = NULL,
43 wxPrintDialogData *data = NULL );
44 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
45 wxPrintout *printout,
46 wxPrintData *data );
47
48 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
49 wxPrintDialogData *data = NULL );
50 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
51 wxPrintData *data );
52
53 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
54 wxPageSetupDialogData * data = NULL );
55
56 #if wxUSE_NEW_DC
57 virtual wxImplDC* CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data );
58 #else
59 virtual wxDC* CreatePrinterDC( const wxPrintData& data );
60 #endif
61
62 virtual bool HasPrintSetupDialog();
63 virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data );
64 virtual bool HasOwnPrintToFile();
65 virtual bool HasPrinterLine();
66 virtual wxString CreatePrinterLine();
67 virtual bool HasStatusLine();
68 virtual wxString CreateStatusLine();
69
70 virtual wxPrintNativeDataBase *CreatePrintNativeData();
71 };
72
73 //----------------------------------------------------------------------------
74 // wxGtkPrintDialog
75 //----------------------------------------------------------------------------
76
77 class WXDLLIMPEXP_CORE wxGtkPrintDialog: public wxPrintDialogBase
78 {
79 public:
80 wxGtkPrintDialog( wxWindow *parent,
81 wxPrintDialogData* data = NULL );
82 wxGtkPrintDialog( wxWindow *parent, wxPrintData* data);
83 virtual ~wxGtkPrintDialog();
84
85 wxPrintData& GetPrintData()
86 { return m_printDialogData.GetPrintData(); }
87 wxPrintDialogData& GetPrintDialogData()
88 { return m_printDialogData; }
89
90 wxDC *GetPrintDC() { return m_dc; }
91 void SetPrintDC(wxDC * printDC) { m_dc = printDC; }
92
93 virtual int ShowModal();
94
95 virtual bool Validate() { return true; }
96 virtual bool TransferDataToWindow() { return true; }
97 virtual bool TransferDataFromWindow() { return true; }
98
99 void SetShowDialog(bool show) { m_showDialog = show; }
100 bool GetShowDialog() { return m_showDialog; }
101
102 protected:
103 // Implement some base class methods to do nothing to avoid asserts and
104 // GTK warnings, since this is not a real wxDialog.
105 virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
106 int WXUNUSED(width), int WXUNUSED(height),
107 int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
108 virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
109 int WXUNUSED(width), int WXUNUSED(height)) {}
110
111 private:
112 wxPrintDialogData m_printDialogData;
113 wxWindow *m_parent;
114 bool m_showDialog;
115 wxDC *m_dc;
116
117 DECLARE_DYNAMIC_CLASS(wxGtkPrintDialog)
118 };
119
120 //----------------------------------------------------------------------------
121 // wxGtkPageSetupDialog
122 //----------------------------------------------------------------------------
123
124 class WXDLLIMPEXP_CORE wxGtkPageSetupDialog: public wxPageSetupDialogBase
125 {
126 public:
127 wxGtkPageSetupDialog( wxWindow *parent,
128 wxPageSetupDialogData* data = NULL );
129 virtual ~wxGtkPageSetupDialog();
130
131 virtual wxPageSetupDialogData& GetPageSetupDialogData() { return m_pageDialogData; }
132
133 virtual int ShowModal();
134
135 virtual bool Validate() { return true; }
136 virtual bool TransferDataToWindow() { return true; }
137 virtual bool TransferDataFromWindow() { return true; }
138
139 protected:
140 // Implement some base class methods to do nothing to avoid asserts and
141 // GTK warnings, since this is not a real wxDialog.
142 virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
143 int WXUNUSED(width), int WXUNUSED(height),
144 int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
145 virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
146 int WXUNUSED(width), int WXUNUSED(height)) {}
147
148 private:
149 wxPageSetupDialogData m_pageDialogData;
150 wxWindow *m_parent;
151
152 DECLARE_DYNAMIC_CLASS(wxGtkPageSetupDialog)
153 };
154
155 //----------------------------------------------------------------------------
156 // wxGtkPrinter
157 //----------------------------------------------------------------------------
158
159 class WXDLLIMPEXP_CORE wxGtkPrinter : public wxPrinterBase
160 {
161 public:
162 wxGtkPrinter(wxPrintDialogData *data = NULL);
163 virtual ~wxGtkPrinter();
164
165 virtual bool Print(wxWindow *parent,
166 wxPrintout *printout,
167 bool prompt = true);
168 virtual wxDC* PrintDialog(wxWindow *parent);
169 virtual bool Setup(wxWindow *parent);
170
171 GtkPrintContext *GetPrintContext() { return m_gpc; }
172 void SetPrintContext(GtkPrintContext *context) {m_gpc = context;}
173 void BeginPrint(wxPrintout *printout, GtkPrintOperation *operation, GtkPrintContext *context);
174 void DrawPage(wxPrintout *printout, GtkPrintOperation *operation, GtkPrintContext *context, int page_nr);
175
176 private:
177 GtkPrintContext *m_gpc;
178 wxDC *m_dc;
179
180 DECLARE_DYNAMIC_CLASS(wxGtkPrinter)
181 DECLARE_NO_COPY_CLASS(wxGtkPrinter)
182 };
183
184 //----------------------------------------------------------------------------
185 // wxGtkPrintNativeData
186 //----------------------------------------------------------------------------
187
188 class WXDLLIMPEXP_CORE wxGtkPrintNativeData : public wxPrintNativeDataBase
189 {
190 public:
191 wxGtkPrintNativeData();
192 virtual ~wxGtkPrintNativeData();
193
194 virtual bool TransferTo( wxPrintData &data );
195 virtual bool TransferFrom( const wxPrintData &data );
196
197 virtual bool Ok() const { return IsOk(); }
198 virtual bool IsOk() const { return true; }
199
200 GtkPrintSettings* GetPrintConfig() { return m_config; }
201 void SetPrintConfig( GtkPrintSettings * config );
202
203 void SetPrintJob( GtkPrintOperation *job ) { m_job = job; }
204 GtkPrintOperation* GetPrintJob() { return m_job; }
205
206 GtkPrintContext *GetPrintContext() { return m_context; }
207 void SetPrintContext(GtkPrintContext *context) {m_context = context; }
208
209
210 GtkPageSetup* GetPageSetupFromSettings(GtkPrintSettings* settings);
211 void SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup);
212
213 private:
214 GtkPrintSettings *m_config;
215 GtkPrintOperation *m_job;
216 GtkPrintContext *m_context;
217
218 DECLARE_DYNAMIC_CLASS(wxGtkPrintNativeData)
219 };
220
221 //-----------------------------------------------------------------------------
222 // wxGtkPrinterDC
223 //-----------------------------------------------------------------------------
224
225 #if wxUSE_NEW_DC
226 class WXDLLIMPEXP_CORE wxGtkPrinterImplDC : public wxImplDC
227 #else
228 #define wxGtkPrinterImplDC wxGtkPrinterDC
229 class WXDLLIMPEXP_CORE wxGtkPrinterDC : public wxDC
230 #endif
231 {
232 public:
233 #if wxUSE_NEW_DC
234 wxGtkPrinterImplDC( wxPrinterDC *owner, const wxPrintData& data );
235 #else
236 wxGtkPrinterDC( const wxPrintData& data );
237 #endif
238 virtual ~wxGtkPrinterImplDC();
239
240 bool Ok() const { return IsOk(); }
241 bool IsOk() const;
242
243 bool CanDrawBitmap() const { return true; }
244 void Clear();
245 void SetFont( const wxFont& font );
246 void SetPen( const wxPen& pen );
247 void SetBrush( const wxBrush& brush );
248 void SetLogicalFunction( int function );
249 void SetBackground( const wxBrush& brush );
250 void DestroyClippingRegion();
251 bool StartDoc(const wxString& message);
252 void EndDoc();
253 void StartPage();
254 void EndPage();
255 wxCoord GetCharHeight() const;
256 wxCoord GetCharWidth() const;
257 bool CanGetTextExtent() const { return true; }
258 wxSize GetPPI() const;
259 virtual int GetDepth() const { return 24; }
260 void SetBackgroundMode(int mode);
261 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
262 void SetResolution(int ppi);
263
264 // overriden for wxPrinterDC Impl
265 virtual int GetResolution();
266 virtual wxRect GetPaperRect();
267
268 protected:
269 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE );
270 void DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter);
271 void DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection = wxEAST);
272 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
273 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
274 void DoCrossHair(wxCoord x, wxCoord y);
275 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
276 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
277 void DoDrawPoint(wxCoord x, wxCoord y);
278 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
279 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
280 void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
281 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
282 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0);
283 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
284 #if wxUSE_SPLINES
285 void DoDrawSpline(const wxPointList *points);
286 #endif
287 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
288 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false,
289 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
290 void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y );
291 void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false );
292 void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
293 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
294 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
295 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
296 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
297 wxCoord *descent = (wxCoord *) NULL,
298 wxCoord *externalLeading = (wxCoord *) NULL,
299 const wxFont *theFont = (wxFont *) NULL ) const;
300 void DoGetSize(int* width, int* height) const;
301 void DoGetSizeMM(int *width, int *height) const;
302
303 wxPrintData& GetPrintData() { return m_printData; }
304 void SetPrintData(const wxPrintData& data);
305
306 private:
307 wxPrintData m_printData;
308 PangoContext *m_context;
309 PangoLayout *m_layout;
310 PangoFontDescription *m_fontdesc;
311 cairo_t *m_cairo;
312
313 unsigned char m_currentRed;
314 unsigned char m_currentGreen;
315 unsigned char m_currentBlue;
316 unsigned char m_currentAlpha;
317
318 GtkPrintContext *m_gpc;
319 int m_resolution;
320 double m_PS2DEV;
321 double m_DEV2PS;
322
323 DECLARE_DYNAMIC_CLASS(wxGtkPrinterImplDC)
324 DECLARE_NO_COPY_CLASS(wxGtkPrinterImplDC)
325 };
326
327 // ----------------------------------------------------------------------------
328 // wxGtkPrintPreview: programmer creates an object of this class to preview a
329 // wxPrintout.
330 // ----------------------------------------------------------------------------
331
332 class WXDLLIMPEXP_CORE wxGtkPrintPreview : public wxPrintPreviewBase
333 {
334 public:
335 wxGtkPrintPreview(wxPrintout *printout,
336 wxPrintout *printoutForPrinting = (wxPrintout *) NULL,
337 wxPrintDialogData *data = (wxPrintDialogData *) NULL);
338 wxGtkPrintPreview(wxPrintout *printout,
339 wxPrintout *printoutForPrinting,
340 wxPrintData *data);
341
342 virtual ~wxGtkPrintPreview();
343
344 virtual bool Print(bool interactive);
345 virtual void DetermineScaling();
346
347 private:
348 void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
349
350 DECLARE_CLASS(wxGtkPrintPreview)
351 };
352
353 #endif
354
355 #endif