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