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