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