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