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