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