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