]>
Commit | Line | Data |
---|---|---|
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 __gprint_H__ | |
12 | #define __gprint_H__ | |
13 | ||
14 | // Include wxWindows' headers | |
15 | ||
16 | #include "wx/defs.h" | |
17 | ||
18 | #if wxUSE_LIBGNOMEPRINT | |
19 | ||
20 | #include "wx/print.h" | |
21 | #include "wx/printdlg.h" | |
22 | #include "wx/dc.h" | |
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(); | |
37 | ||
38 | virtual bool TransferTo( wxPrintData &data ); | |
39 | virtual bool TransferFrom( const wxPrintData &data ); | |
40 | ||
41 | virtual bool Ok() const { return IsOk(); } | |
42 | virtual bool IsOk() const { return true; } | |
43 | ||
44 | GnomePrintConfig* GetPrintConfig() { return m_config; } | |
45 | void SetPrintJob( GnomePrintJob *job ) { m_job = job; } | |
46 | GnomePrintJob* GetPrintJob() { return m_job; } | |
47 | ||
48 | ||
49 | private: | |
50 | GnomePrintConfig *m_config; | |
51 | GnomePrintJob *m_job; | |
52 | ||
53 | private: | |
54 | DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData) | |
55 | }; | |
56 | ||
57 | //---------------------------------------------------------------------------- | |
58 | // wxGnomePrintFactory | |
59 | //---------------------------------------------------------------------------- | |
60 | ||
61 | class wxGnomePrintFactory: public wxPrintFactory | |
62 | { | |
63 | public: | |
64 | virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data ); | |
65 | ||
66 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, | |
67 | wxPrintout *printout = NULL, | |
68 | wxPrintDialogData *data = NULL ); | |
69 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, | |
70 | wxPrintout *printout, | |
71 | wxPrintData *data ); | |
72 | ||
73 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
74 | wxPrintDialogData *data = NULL ); | |
75 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
76 | wxPrintData *data ); | |
77 | ||
78 | virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, | |
79 | wxPageSetupDialogData * data = NULL ); | |
80 | ||
81 | virtual wxDC* CreatePrinterDC( const wxPrintData& data ); | |
82 | ||
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(); | |
90 | ||
91 | virtual wxPrintNativeDataBase *CreatePrintNativeData(); | |
92 | }; | |
93 | ||
94 | //---------------------------------------------------------------------------- | |
95 | // wxGnomePrintDialog | |
96 | //---------------------------------------------------------------------------- | |
97 | ||
98 | class wxGnomePrintDialog: public wxPrintDialogBase | |
99 | { | |
100 | public: | |
101 | wxGnomePrintDialog( wxWindow *parent, | |
102 | wxPrintDialogData* data = NULL ); | |
103 | wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); | |
104 | virtual ~wxGnomePrintDialog(); | |
105 | ||
106 | wxPrintData& GetPrintData() | |
107 | { return m_printDialogData.GetPrintData(); } | |
108 | wxPrintDialogData& GetPrintDialogData() | |
109 | { return m_printDialogData; } | |
110 | ||
111 | wxDC *GetPrintDC(); | |
112 | ||
113 | virtual int ShowModal(); | |
114 | ||
115 | virtual bool Validate(); | |
116 | virtual bool TransferDataToWindow(); | |
117 | virtual bool TransferDataFromWindow(); | |
118 | ||
119 | private: | |
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)) {} | |
127 | ||
128 | void Init(); | |
129 | wxPrintDialogData m_printDialogData; | |
130 | ||
131 | private: | |
132 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) | |
133 | }; | |
134 | ||
135 | //---------------------------------------------------------------------------- | |
136 | // wxGnomePageSetupDialog | |
137 | //---------------------------------------------------------------------------- | |
138 | ||
139 | class wxGnomePageSetupDialog: public wxPageSetupDialogBase | |
140 | { | |
141 | public: | |
142 | wxGnomePageSetupDialog( wxWindow *parent, | |
143 | wxPageSetupDialogData* data = NULL ); | |
144 | virtual ~wxGnomePageSetupDialog(); | |
145 | ||
146 | virtual wxPageSetupDialogData& GetPageSetupDialogData(); | |
147 | ||
148 | virtual int ShowModal(); | |
149 | ||
150 | virtual bool Validate(); | |
151 | virtual bool TransferDataToWindow(); | |
152 | virtual bool TransferDataFromWindow(); | |
153 | ||
154 | private: | |
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)) {} | |
162 | ||
163 | wxPageSetupDialogData m_pageDialogData; | |
164 | ||
165 | private: | |
166 | DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) | |
167 | }; | |
168 | ||
169 | //---------------------------------------------------------------------------- | |
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); | |
184 | ||
185 | GnomePrintContext *GetPrintContext() { return m_gpc; } | |
186 | ||
187 | private: | |
188 | GnomePrintContext *m_gpc; | |
189 | bool m_native_preview; | |
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 ); | |
204 | wxGnomePrintDC( const wxPrintData& data ); | |
205 | virtual ~wxGnomePrintDC(); | |
206 | ||
207 | bool Ok() const { return IsOk(); } | |
208 | bool IsOk() const; | |
209 | ||
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); | |
223 | #if wxUSE_SPLINES | |
224 | void DoDrawSpline(wxList *points); | |
225 | #endif // wxUSE_SPLINES | |
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 | wxPrintData m_printData; | |
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 | ||
290 | wxGnomePrinter *m_printer; | |
291 | GnomePrintContext *m_gpc; | |
292 | GnomePrintJob* m_job; // only used and destroyed when created with wxPrintData | |
293 | ||
294 | void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
295 | ||
296 | private: | |
297 | wxCoord XDEV2LOG(wxCoord x) const | |
298 | { | |
299 | return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX; | |
300 | } | |
301 | wxCoord XDEV2LOGREL(wxCoord x) const | |
302 | { | |
303 | return wxRound((double)(x) / m_scaleX); | |
304 | } | |
305 | wxCoord YDEV2LOG(wxCoord y) const | |
306 | { | |
307 | return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY; | |
308 | } | |
309 | wxCoord YDEV2LOGREL(wxCoord y) const | |
310 | { | |
311 | return wxRound((double)(y) / m_scaleY); | |
312 | } | |
313 | wxCoord XLOG2DEV(wxCoord x) const | |
314 | { | |
315 | return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX; | |
316 | } | |
317 | wxCoord XLOG2DEVREL(wxCoord x) const | |
318 | { | |
319 | return wxRound((double)(x) * m_scaleX); | |
320 | } | |
321 | wxCoord YLOG2DEV(wxCoord y) const | |
322 | { | |
323 | return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY; | |
324 | } | |
325 | wxCoord YLOG2DEVREL(wxCoord y) const | |
326 | { | |
327 | return wxRound((double)(y) * m_scaleY); | |
328 | } | |
329 | private: | |
330 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDC) | |
331 | DECLARE_NO_COPY_CLASS(wxGnomePrintDC) | |
332 | }; | |
333 | ||
334 | // ---------------------------------------------------------------------------- | |
335 | // wxGnomePrintPreview: programmer creates an object of this class to preview a | |
336 | // wxPrintout. | |
337 | // ---------------------------------------------------------------------------- | |
338 | ||
339 | class wxGnomePrintPreview : public wxPrintPreviewBase | |
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 | ||
362 | #endif | |
363 | // wxUSE_LIBGNOMEPRINT | |
364 | ||
365 | #endif |