]>
Commit | Line | Data |
---|---|---|
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 | |
24 | typedef struct _GnomePrintJob GnomePrintJob; | |
25 | typedef struct _GnomePrintContext GnomePrintContext; | |
26 | typedef struct _GnomePrintConfig GnomePrintConfig; | |
27 | ||
28 | //---------------------------------------------------------------------------- | |
29 | // wxGnomePrintNativeData | |
30 | //---------------------------------------------------------------------------- | |
31 | ||
32 | class wxGnomePrintNativeData: public wxPrintNativeDataBase | |
33 | { | |
34 | public: | |
35 | wxGnomePrintNativeData(); | |
36 | virtual ~wxGnomePrintNativeData(); | |
389076f1 | 37 | |
ff910433 RR |
38 | virtual bool TransferTo( wxPrintData &data ); |
39 | virtual bool TransferFrom( const wxPrintData &data ); | |
389076f1 | 40 | |
b7cacb43 VZ |
41 | virtual bool Ok() const { return IsOk(); } |
42 | virtual bool IsOk() const { return true; } | |
389076f1 | 43 | |
ff910433 | 44 | GnomePrintConfig* GetPrintConfig() { return m_config; } |
cffcf831 | 45 | void SetPrintJob( GnomePrintJob *job ) { m_job = job; } |
ff910433 | 46 | GnomePrintJob* GetPrintJob() { return m_job; } |
389076f1 WS |
47 | |
48 | ||
ff910433 RR |
49 | private: |
50 | GnomePrintConfig *m_config; | |
51 | GnomePrintJob *m_job; | |
389076f1 | 52 | |
ff910433 RR |
53 | private: |
54 | DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData) | |
55 | }; | |
389076f1 | 56 | |
ff910433 RR |
57 | //---------------------------------------------------------------------------- |
58 | // wxGnomePrintFactory | |
59 | //---------------------------------------------------------------------------- | |
60 | ||
61 | class wxGnomePrintFactory: public wxPrintFactory | |
62 | { | |
63 | public: | |
64 | virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data ); | |
389076f1 WS |
65 | |
66 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, | |
67 | wxPrintout *printout = NULL, | |
ff910433 | 68 | wxPrintDialogData *data = NULL ); |
389076f1 | 69 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, |
ff910433 RR |
70 | wxPrintout *printout, |
71 | wxPrintData *data ); | |
389076f1 WS |
72 | |
73 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
ff910433 | 74 | wxPrintDialogData *data = NULL ); |
389076f1 | 75 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, |
ff910433 | 76 | wxPrintData *data ); |
08680429 RR |
77 | |
78 | virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, | |
79 | wxPageSetupDialogData * data = NULL ); | |
389076f1 | 80 | |
147bf263 JS |
81 | virtual wxDC* CreatePrinterDC( const wxPrintData& data ); |
82 | ||
ff910433 RR |
83 | virtual bool HasPrintSetupDialog(); |
84 | virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); | |
85 | virtual bool HasOwnPrintToFile(); | |
86 | virtual bool HasPrinterLine(); | |
87 | virtual wxString CreatePrinterLine(); | |
88 | virtual bool HasStatusLine(); | |
89 | virtual wxString CreateStatusLine(); | |
389076f1 | 90 | |
ff910433 RR |
91 | virtual wxPrintNativeDataBase *CreatePrintNativeData(); |
92 | }; | |
93 | ||
94 | //---------------------------------------------------------------------------- | |
2934005d | 95 | // wxGnomePrintDialog |
ff910433 RR |
96 | //---------------------------------------------------------------------------- |
97 | ||
2934005d | 98 | class wxGnomePrintDialog: public wxPrintDialogBase |
ff910433 RR |
99 | { |
100 | public: | |
2934005d | 101 | wxGnomePrintDialog( wxWindow *parent, |
08680429 | 102 | wxPrintDialogData* data = NULL ); |
2934005d | 103 | wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); |
d3c7fc99 | 104 | virtual ~wxGnomePrintDialog(); |
2934005d RR |
105 | |
106 | wxPrintData& GetPrintData() | |
107 | { return m_printDialogData.GetPrintData(); } | |
108 | wxPrintDialogData& GetPrintDialogData() | |
109 | { return m_printDialogData; } | |
389076f1 | 110 | |
2934005d | 111 | wxDC *GetPrintDC(); |
ff910433 RR |
112 | |
113 | virtual int ShowModal(); | |
114 | ||
115 | virtual bool Validate(); | |
116 | virtual bool TransferDataToWindow(); | |
117 | virtual bool TransferDataFromWindow(); | |
118 | ||
389076f1 | 119 | private: |
ff910433 RR |
120 | // Implement some base class methods to do nothing to avoid asserts and |
121 | // GTK warnings, since this is not a real wxDialog. | |
122 | virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), | |
123 | int WXUNUSED(width), int WXUNUSED(height), | |
124 | int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} | |
125 | virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), | |
126 | int WXUNUSED(width), int WXUNUSED(height)) {} | |
389076f1 | 127 | |
2934005d RR |
128 | void Init(); |
129 | wxPrintDialogData m_printDialogData; | |
389076f1 | 130 | |
ff910433 | 131 | private: |
2934005d | 132 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) |
ff910433 RR |
133 | }; |
134 | ||
135 | //---------------------------------------------------------------------------- | |
08680429 RR |
136 | // wxGnomePageSetupDialog |
137 | //---------------------------------------------------------------------------- | |
138 | ||
139 | class wxGnomePageSetupDialog: public wxPageSetupDialogBase | |
140 | { | |
141 | public: | |
142 | wxGnomePageSetupDialog( wxWindow *parent, | |
143 | wxPageSetupDialogData* data = NULL ); | |
d3c7fc99 | 144 | virtual ~wxGnomePageSetupDialog(); |
08680429 RR |
145 | |
146 | virtual wxPageSetupDialogData& GetPageSetupDialogData(); | |
147 | ||
148 | virtual int ShowModal(); | |
149 | ||
150 | virtual bool Validate(); | |
151 | virtual bool TransferDataToWindow(); | |
152 | virtual bool TransferDataFromWindow(); | |
153 | ||
389076f1 | 154 | private: |
08680429 RR |
155 | // Implement some base class methods to do nothing to avoid asserts and |
156 | // GTK warnings, since this is not a real wxDialog. | |
157 | virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), | |
158 | int WXUNUSED(width), int WXUNUSED(height), | |
159 | int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} | |
160 | virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), | |
161 | int WXUNUSED(width), int WXUNUSED(height)) {} | |
389076f1 | 162 | |
08680429 | 163 | wxPageSetupDialogData m_pageDialogData; |
389076f1 | 164 | |
08680429 RR |
165 | private: |
166 | DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) | |
167 | }; | |
168 | ||
169 | //---------------------------------------------------------------------------- | |
ff910433 RR |
170 | // wxGnomePrinter |
171 | //---------------------------------------------------------------------------- | |
172 | ||
173 | class wxGnomePrinter: public wxPrinterBase | |
174 | { | |
175 | public: | |
176 | wxGnomePrinter(wxPrintDialogData *data = NULL); | |
177 | virtual ~wxGnomePrinter(); | |
178 | ||
179 | virtual bool Print(wxWindow *parent, | |
180 | wxPrintout *printout, | |
181 | bool prompt = true); | |
182 | virtual wxDC* PrintDialog(wxWindow *parent); | |
183 | virtual bool Setup(wxWindow *parent); | |
389076f1 | 184 | |
ff910433 | 185 | GnomePrintContext *GetPrintContext() { return m_gpc; } |
389076f1 | 186 | |
ff910433 RR |
187 | private: |
188 | GnomePrintContext *m_gpc; | |
0be7709e | 189 | bool m_native_preview; |
ff910433 RR |
190 | |
191 | private: | |
192 | DECLARE_DYNAMIC_CLASS(wxGnomePrinter) | |
193 | DECLARE_NO_COPY_CLASS(wxGnomePrinter) | |
194 | }; | |
195 | ||
196 | //----------------------------------------------------------------------------- | |
197 | // wxGnomePrintDC | |
198 | //----------------------------------------------------------------------------- | |
199 | ||
200 | class wxGnomePrintDC: public wxDC | |
201 | { | |
202 | public: | |
203 | wxGnomePrintDC( wxGnomePrinter *printer ); | |
147bf263 | 204 | wxGnomePrintDC( const wxPrintData& data ); |
d3c7fc99 | 205 | virtual ~wxGnomePrintDC(); |
389076f1 | 206 | |
b7cacb43 VZ |
207 | bool Ok() const { return IsOk(); } |
208 | bool IsOk() const; | |
389076f1 | 209 | |
ff910433 RR |
210 | bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE ); |
211 | bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; | |
212 | void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
213 | void DoCrossHair(wxCoord x, wxCoord y); | |
214 | void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); | |
215 | void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); | |
216 | void DoDrawPoint(wxCoord x, wxCoord y); | |
217 | void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); | |
218 | void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
219 | void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
220 | void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
221 | void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0); | |
222 | void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
389076f1 | 223 | #if wxUSE_SPLINES |
ff910433 | 224 | void DoDrawSpline(wxList *points); |
389076f1 WS |
225 | #endif // wxUSE_SPLINES |
226 | ||
ff910433 RR |
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; } | |
389076f1 | 233 | |
ff910433 RR |
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 ); | |
389076f1 | 242 | |
ff910433 RR |
243 | void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
244 | void DestroyClippingRegion(); | |
245 | void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { } | |
389076f1 | 246 | |
ff910433 RR |
247 | bool StartDoc(const wxString& message); |
248 | void EndDoc(); | |
249 | void StartPage(); | |
250 | void EndPage(); | |
389076f1 | 251 | |
ff910433 RR |
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; | |
389076f1 | 259 | |
ff910433 RR |
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 ); | |
389076f1 | 265 | |
ff910433 | 266 | virtual int GetDepth() const { return 24; } |
389076f1 | 267 | |
ff910433 RR |
268 | void SetBackgroundMode(int WXUNUSED(mode)) { } |
269 | void SetPalette(const wxPalette& WXUNUSED(palette)) { } | |
389076f1 | 270 | |
ff910433 RR |
271 | wxPrintData& GetPrintData() { return m_printData; } |
272 | void SetPrintData(const wxPrintData& data) { m_printData = data; } | |
389076f1 | 273 | |
ff910433 RR |
274 | static void SetResolution(int ppi); |
275 | static int GetResolution(); | |
276 | ||
277 | private: | |
278 | static float ms_PSScaleFactor; | |
389076f1 | 279 | |
ff910433 | 280 | private: |
147bf263 | 281 | wxPrintData m_printData; |
ff910433 RR |
282 | PangoContext *m_context; |
283 | PangoLayout *m_layout; | |
284 | PangoFontDescription *m_fontdesc; | |
389076f1 | 285 | |
ff910433 RR |
286 | unsigned char m_currentRed; |
287 | unsigned char m_currentGreen; | |
288 | unsigned char m_currentBlue; | |
389076f1 | 289 | |
ff910433 RR |
290 | wxGnomePrinter *m_printer; |
291 | GnomePrintContext *m_gpc; | |
147bf263 | 292 | GnomePrintJob* m_job; // only used and destroyed when created with wxPrintData |
ff910433 | 293 | |
74ab0bfb RR |
294 | void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
295 | ||
ff910433 RR |
296 | private: |
297 | wxCoord XDEV2LOG(wxCoord x) const | |
298 | { | |
2ac9bfa9 | 299 | return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX; |
ff910433 RR |
300 | } |
301 | wxCoord XDEV2LOGREL(wxCoord x) const | |
302 | { | |
2ac9bfa9 | 303 | return wxRound((double)(x) / m_scaleX); |
ff910433 RR |
304 | } |
305 | wxCoord YDEV2LOG(wxCoord y) const | |
306 | { | |
2ac9bfa9 | 307 | return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY; |
ff910433 RR |
308 | } |
309 | wxCoord YDEV2LOGREL(wxCoord y) const | |
310 | { | |
2ac9bfa9 | 311 | return wxRound((double)(y) / m_scaleY); |
ff910433 RR |
312 | } |
313 | wxCoord XLOG2DEV(wxCoord x) const | |
314 | { | |
2ac9bfa9 | 315 | return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX; |
ff910433 RR |
316 | } |
317 | wxCoord XLOG2DEVREL(wxCoord x) const | |
318 | { | |
2ac9bfa9 | 319 | return wxRound((double)(x) * m_scaleX); |
ff910433 RR |
320 | } |
321 | wxCoord YLOG2DEV(wxCoord y) const | |
322 | { | |
2ac9bfa9 | 323 | return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY; |
ff910433 RR |
324 | } |
325 | wxCoord YLOG2DEVREL(wxCoord y) const | |
326 | { | |
2ac9bfa9 | 327 | return wxRound((double)(y) * m_scaleY); |
ff910433 RR |
328 | } |
329 | private: | |
330 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDC) | |
331 | DECLARE_NO_COPY_CLASS(wxGnomePrintDC) | |
332 | }; | |
333 | ||
147bf263 JS |
334 | // ---------------------------------------------------------------------------- |
335 | // wxGnomePrintPreview: programmer creates an object of this class to preview a | |
336 | // wxPrintout. | |
337 | // ---------------------------------------------------------------------------- | |
338 | ||
459dbfc0 | 339 | class wxGnomePrintPreview : public wxPrintPreviewBase |
147bf263 JS |
340 | { |
341 | public: | |
342 | wxGnomePrintPreview(wxPrintout *printout, | |
343 | wxPrintout *printoutForPrinting = (wxPrintout *) NULL, | |
344 | wxPrintDialogData *data = (wxPrintDialogData *) NULL); | |
345 | wxGnomePrintPreview(wxPrintout *printout, | |
346 | wxPrintout *printoutForPrinting, | |
347 | wxPrintData *data); | |
348 | ||
349 | virtual ~wxGnomePrintPreview(); | |
350 | ||
351 | virtual bool Print(bool interactive); | |
352 | virtual void DetermineScaling(); | |
353 | ||
354 | private: | |
355 | void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); | |
356 | ||
357 | private: | |
358 | DECLARE_CLASS(wxGnomePrintPreview) | |
359 | }; | |
360 | ||
361 | ||
7c72311f RR |
362 | #endif |
363 | // wxUSE_LIBGNOMEPRINT | |
364 | ||
ff910433 | 365 | #endif |