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