]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/gnome/gprint.h
cache results of Motif 2 and Motif-is-Lesstif tests
[wxWidgets.git] / include / wx / gtk1 / 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
58c30cd8
RR
14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15#pragma interface
ff910433
RR
16#endif
17
18// Include wxWindows' headers
19
20#ifndef WX_PRECOMP
21 #include <wx/wx.h>
22#endif
23
7c72311f
RR
24#if wxUSE_LIBGNOMEPRINT
25
ff910433
RR
26#include "wx/print.h"
27#include "wx/prntbase.h"
28#include "wx/printdlg.h"
29
30typedef struct _GnomePrintJob GnomePrintJob;
31typedef struct _GnomePrintContext GnomePrintContext;
32typedef struct _GnomePrintConfig GnomePrintConfig;
33
34//----------------------------------------------------------------------------
35// wxGnomePrintNativeData
36//----------------------------------------------------------------------------
37
38class wxGnomePrintNativeData: public wxPrintNativeDataBase
39{
40public:
41 wxGnomePrintNativeData();
42 virtual ~wxGnomePrintNativeData();
389076f1 43
ff910433
RR
44 virtual bool TransferTo( wxPrintData &data );
45 virtual bool TransferFrom( const wxPrintData &data );
389076f1 46
ff910433 47 virtual bool Ok() const { return true; }
389076f1 48
ff910433 49 GnomePrintConfig* GetPrintConfig() { return m_config; }
cffcf831 50 void SetPrintJob( GnomePrintJob *job ) { m_job = job; }
ff910433 51 GnomePrintJob* GetPrintJob() { return m_job; }
389076f1
WS
52
53
ff910433
RR
54private:
55 GnomePrintConfig *m_config;
56 GnomePrintJob *m_job;
389076f1 57
ff910433
RR
58private:
59 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData)
60};
389076f1 61
ff910433
RR
62//----------------------------------------------------------------------------
63// wxGnomePrintFactory
64//----------------------------------------------------------------------------
65
66class wxGnomePrintFactory: public wxPrintFactory
67{
68public:
69 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
389076f1
WS
70
71 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
72 wxPrintout *printout = NULL,
ff910433 73 wxPrintDialogData *data = NULL );
389076f1 74 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
ff910433
RR
75 wxPrintout *printout,
76 wxPrintData *data );
389076f1
WS
77
78 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
ff910433 79 wxPrintDialogData *data = NULL );
389076f1 80 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
ff910433 81 wxPrintData *data );
08680429
RR
82
83 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
84 wxPageSetupDialogData * data = NULL );
389076f1 85
ff910433
RR
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();
389076f1 93
ff910433
RR
94 virtual wxPrintNativeDataBase *CreatePrintNativeData();
95};
96
97//----------------------------------------------------------------------------
2934005d 98// wxGnomePrintDialog
ff910433
RR
99//----------------------------------------------------------------------------
100
2934005d 101class wxGnomePrintDialog: public wxPrintDialogBase
ff910433
RR
102{
103public:
2934005d 104 wxGnomePrintDialog( wxWindow *parent,
08680429 105 wxPrintDialogData* data = NULL );
2934005d
RR
106 wxGnomePrintDialog( wxWindow *parent, wxPrintData* data);
107 ~wxGnomePrintDialog();
108
109 wxPrintData& GetPrintData()
110 { return m_printDialogData.GetPrintData(); }
111 wxPrintDialogData& GetPrintDialogData()
112 { return m_printDialogData; }
389076f1 113
2934005d 114 wxDC *GetPrintDC();
ff910433
RR
115
116 virtual int ShowModal();
117
118 virtual bool Validate();
119 virtual bool TransferDataToWindow();
120 virtual bool TransferDataFromWindow();
121
389076f1 122private:
ff910433
RR
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)) {}
389076f1 130
2934005d
RR
131 void Init();
132 wxPrintDialogData m_printDialogData;
389076f1 133
ff910433 134private:
2934005d 135 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog)
ff910433
RR
136};
137
138//----------------------------------------------------------------------------
08680429
RR
139// wxGnomePageSetupDialog
140//----------------------------------------------------------------------------
141
142class wxGnomePageSetupDialog: public wxPageSetupDialogBase
143{
144public:
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
389076f1 157private:
08680429
RR
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)) {}
389076f1 165
08680429 166 wxPageSetupDialogData m_pageDialogData;
389076f1 167
08680429
RR
168private:
169 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog)
170};
171
172//----------------------------------------------------------------------------
ff910433
RR
173// wxGnomePrinter
174//----------------------------------------------------------------------------
175
176class wxGnomePrinter: public wxPrinterBase
177{
178public:
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);
389076f1 187
ff910433 188 GnomePrintContext *GetPrintContext() { return m_gpc; }
389076f1 189
ff910433
RR
190private:
191 GnomePrintContext *m_gpc;
0be7709e 192 bool m_native_preview;
ff910433
RR
193
194private:
195 DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
196 DECLARE_NO_COPY_CLASS(wxGnomePrinter)
197};
198
199//-----------------------------------------------------------------------------
200// wxGnomePrintDC
201//-----------------------------------------------------------------------------
202
203class wxGnomePrintDC: public wxDC
204{
205public:
206 wxGnomePrintDC( wxGnomePrinter *printer );
207 ~wxGnomePrintDC();
389076f1 208
ff910433 209 bool Ok() const;
389076f1 210
ff910433
RR
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);
389076f1 227#if wxUSE_SPLINES
ff910433 228 void DoDrawSpline(wxList *points);
389076f1
WS
229#endif // wxUSE_SPLINES
230
ff910433
RR
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; }
389076f1 237
ff910433
RR
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 );
389076f1 246
ff910433
RR
247 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
248 void DestroyClippingRegion();
249 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
389076f1 250
ff910433
RR
251 bool StartDoc(const wxString& message);
252 void EndDoc();
253 void StartPage();
254 void EndPage();
389076f1 255
ff910433
RR
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;
389076f1 263
ff910433
RR
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 );
389076f1 269
ff910433 270 virtual int GetDepth() const { return 24; }
389076f1 271
ff910433
RR
272 void SetBackgroundMode(int WXUNUSED(mode)) { }
273 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
389076f1 274
ff910433
RR
275 wxPrintData& GetPrintData() { return m_printData; }
276 void SetPrintData(const wxPrintData& data) { m_printData = data; }
389076f1 277
ff910433
RR
278 static void SetResolution(int ppi);
279 static int GetResolution();
280
281private:
282 static float ms_PSScaleFactor;
389076f1 283
ff910433
RR
284private:
285 PangoContext *m_context;
286 PangoLayout *m_layout;
287 PangoFontDescription *m_fontdesc;
389076f1 288
ff910433
RR
289 unsigned char m_currentRed;
290 unsigned char m_currentGreen;
291 unsigned char m_currentBlue;
292 wxPrintData m_printData;
389076f1 293
ff910433
RR
294 wxGnomePrinter *m_printer;
295 GnomePrintContext *m_gpc;
296
297private:
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 }
358private:
359 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC)
360 DECLARE_NO_COPY_CLASS(wxGnomePrintDC)
361};
362
7c72311f
RR
363#endif
364 // wxUSE_LIBGNOMEPRINT
365
ff910433 366#endif