]>
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 | ||
3498362e PC |
11 | #ifndef _WX_GTK_GPRINT_H_ |
12 | #define _WX_GTK_GPRINT_H_ | |
ff910433 | 13 | |
20ceebaa | 14 | #include "wx/defs.h" |
ff910433 | 15 | |
7c72311f RR |
16 | #if wxUSE_LIBGNOMEPRINT |
17 | ||
ff910433 | 18 | #include "wx/print.h" |
ff910433 | 19 | #include "wx/printdlg.h" |
20ceebaa | 20 | #include "wx/dc.h" |
1ff62f51 | 21 | #include "wx/module.h" |
ff910433 RR |
22 | |
23 | typedef struct _GnomePrintJob GnomePrintJob; | |
24 | typedef struct _GnomePrintContext GnomePrintContext; | |
25 | typedef struct _GnomePrintConfig GnomePrintConfig; | |
26 | ||
1ff62f51 RR |
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 | ||
ff910433 RR |
42 | //---------------------------------------------------------------------------- |
43 | // wxGnomePrintNativeData | |
44 | //---------------------------------------------------------------------------- | |
45 | ||
46 | class wxGnomePrintNativeData: public wxPrintNativeDataBase | |
47 | { | |
48 | public: | |
49 | wxGnomePrintNativeData(); | |
50 | virtual ~wxGnomePrintNativeData(); | |
389076f1 | 51 | |
ff910433 RR |
52 | virtual bool TransferTo( wxPrintData &data ); |
53 | virtual bool TransferFrom( const wxPrintData &data ); | |
389076f1 | 54 | |
b7cacb43 VZ |
55 | virtual bool Ok() const { return IsOk(); } |
56 | virtual bool IsOk() const { return true; } | |
389076f1 | 57 | |
ff910433 | 58 | GnomePrintConfig* GetPrintConfig() { return m_config; } |
cffcf831 | 59 | void SetPrintJob( GnomePrintJob *job ) { m_job = job; } |
ff910433 | 60 | GnomePrintJob* GetPrintJob() { return m_job; } |
389076f1 WS |
61 | |
62 | ||
ff910433 RR |
63 | private: |
64 | GnomePrintConfig *m_config; | |
65 | GnomePrintJob *m_job; | |
389076f1 | 66 | |
ff910433 RR |
67 | DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData) |
68 | }; | |
389076f1 | 69 | |
ff910433 RR |
70 | //---------------------------------------------------------------------------- |
71 | // wxGnomePrintFactory | |
72 | //---------------------------------------------------------------------------- | |
73 | ||
74 | class wxGnomePrintFactory: public wxPrintFactory | |
75 | { | |
76 | public: | |
77 | virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data ); | |
389076f1 WS |
78 | |
79 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, | |
80 | wxPrintout *printout = NULL, | |
ff910433 | 81 | wxPrintDialogData *data = NULL ); |
389076f1 | 82 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, |
ff910433 RR |
83 | wxPrintout *printout, |
84 | wxPrintData *data ); | |
389076f1 WS |
85 | |
86 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
ff910433 | 87 | wxPrintDialogData *data = NULL ); |
389076f1 | 88 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, |
ff910433 | 89 | wxPrintData *data ); |
08680429 RR |
90 | |
91 | virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, | |
92 | wxPageSetupDialogData * data = NULL ); | |
389076f1 | 93 | |
147bf263 JS |
94 | virtual wxDC* CreatePrinterDC( const wxPrintData& data ); |
95 | ||
ff910433 RR |
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(); | |
389076f1 | 103 | |
ff910433 RR |
104 | virtual wxPrintNativeDataBase *CreatePrintNativeData(); |
105 | }; | |
106 | ||
107 | //---------------------------------------------------------------------------- | |
2934005d | 108 | // wxGnomePrintDialog |
ff910433 RR |
109 | //---------------------------------------------------------------------------- |
110 | ||
2934005d | 111 | class wxGnomePrintDialog: public wxPrintDialogBase |
ff910433 RR |
112 | { |
113 | public: | |
2934005d | 114 | wxGnomePrintDialog( wxWindow *parent, |
08680429 | 115 | wxPrintDialogData* data = NULL ); |
2934005d | 116 | wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); |
d3c7fc99 | 117 | virtual ~wxGnomePrintDialog(); |
2934005d RR |
118 | |
119 | wxPrintData& GetPrintData() | |
120 | { return m_printDialogData.GetPrintData(); } | |
121 | wxPrintDialogData& GetPrintDialogData() | |
122 | { return m_printDialogData; } | |
389076f1 | 123 | |
2934005d | 124 | wxDC *GetPrintDC(); |
ff910433 RR |
125 | |
126 | virtual int ShowModal(); | |
127 | ||
128 | virtual bool Validate(); | |
129 | virtual bool TransferDataToWindow(); | |
130 | virtual bool TransferDataFromWindow(); | |
131 | ||
3498362e | 132 | protected: |
ff910433 RR |
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)) {} | |
389076f1 | 140 | |
3498362e | 141 | private: |
2934005d RR |
142 | void Init(); |
143 | wxPrintDialogData m_printDialogData; | |
389076f1 | 144 | |
2934005d | 145 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) |
ff910433 RR |
146 | }; |
147 | ||
148 | //---------------------------------------------------------------------------- | |
08680429 RR |
149 | // wxGnomePageSetupDialog |
150 | //---------------------------------------------------------------------------- | |
151 | ||
152 | class wxGnomePageSetupDialog: public wxPageSetupDialogBase | |
153 | { | |
154 | public: | |
155 | wxGnomePageSetupDialog( wxWindow *parent, | |
156 | wxPageSetupDialogData* data = NULL ); | |
d3c7fc99 | 157 | virtual ~wxGnomePageSetupDialog(); |
08680429 RR |
158 | |
159 | virtual wxPageSetupDialogData& GetPageSetupDialogData(); | |
160 | ||
161 | virtual int ShowModal(); | |
162 | ||
163 | virtual bool Validate(); | |
164 | virtual bool TransferDataToWindow(); | |
165 | virtual bool TransferDataFromWindow(); | |
166 | ||
3498362e | 167 | protected: |
08680429 RR |
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)) {} | |
389076f1 | 175 | |
3498362e | 176 | private: |
08680429 | 177 | wxPageSetupDialogData m_pageDialogData; |
389076f1 | 178 | |
08680429 RR |
179 | DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) |
180 | }; | |
181 | ||
182 | //---------------------------------------------------------------------------- | |
ff910433 RR |
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); | |
389076f1 | 197 | |
ff910433 | 198 | private: |
0be7709e | 199 | bool m_native_preview; |
ff910433 RR |
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: | |
147bf263 | 213 | wxGnomePrintDC( const wxPrintData& data ); |
d3c7fc99 | 214 | virtual ~wxGnomePrintDC(); |
389076f1 | 215 | |
b7cacb43 VZ |
216 | bool Ok() const { return IsOk(); } |
217 | bool IsOk() const; | |
389076f1 | 218 | |
3498362e PC |
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; | |
3498362e PC |
235 | virtual int GetDepth() const { return 24; } |
236 | void SetBackgroundMode(int WXUNUSED(mode)) { } | |
237 | void SetPalette(const wxPalette& WXUNUSED(palette)) { } | |
238 | static void SetResolution(int ppi); | |
239 | static int GetResolution(); | |
240 | ||
241 | protected: | |
ff910433 RR |
242 | bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE ); |
243 | bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; | |
244 | void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
245 | void DoCrossHair(wxCoord x, wxCoord y); | |
246 | void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); | |
247 | void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); | |
248 | void DoDrawPoint(wxCoord x, wxCoord y); | |
249 | void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); | |
250 | void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
251 | void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
252 | void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
253 | void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0); | |
254 | void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
389076f1 | 255 | #if wxUSE_SPLINES |
b0d7707b | 256 | void DoDrawSpline(const wxPointList *points); |
389076f1 | 257 | #endif // wxUSE_SPLINES |
ff910433 RR |
258 | bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
259 | wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false, | |
260 | wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); | |
261 | void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ); | |
262 | void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false ); | |
ff910433 RR |
263 | void DoDrawText(const wxString& text, wxCoord x, wxCoord y ); |
264 | void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); | |
ff910433 | 265 | void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
ff910433 | 266 | void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { } |
ff910433 RR |
267 | void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, |
268 | wxCoord *descent = (wxCoord *) NULL, | |
269 | wxCoord *externalLeading = (wxCoord *) NULL, | |
c94f845b | 270 | const wxFont *theFont = (wxFont *) NULL ) const; |
ff910433 RR |
271 | void DoGetSize(int* width, int* height) const; |
272 | void DoGetSizeMM(int *width, int *height) const; | |
389076f1 | 273 | |
3b7ab6bd | 274 | void SetPrintData(const wxPrintData& data); |
ff910433 | 275 | wxPrintData& GetPrintData() { return m_printData; } |
389076f1 | 276 | |
ff910433 | 277 | private: |
147bf263 | 278 | wxPrintData m_printData; |
ff910433 RR |
279 | PangoContext *m_context; |
280 | PangoLayout *m_layout; | |
281 | PangoFontDescription *m_fontdesc; | |
389076f1 | 282 | |
ff910433 RR |
283 | unsigned char m_currentRed; |
284 | unsigned char m_currentGreen; | |
285 | unsigned char m_currentBlue; | |
02255e07 RR |
286 | |
287 | double m_pageHeight; | |
389076f1 | 288 | |
ff910433 | 289 | GnomePrintContext *m_gpc; |
3b7ab6bd | 290 | GnomePrintJob* m_job; |
ff910433 | 291 | |
74ab0bfb | 292 | void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
c94f845b | 293 | |
ff910433 RR |
294 | private: |
295 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDC) | |
296 | DECLARE_NO_COPY_CLASS(wxGnomePrintDC) | |
297 | }; | |
298 | ||
147bf263 JS |
299 | // ---------------------------------------------------------------------------- |
300 | // wxGnomePrintPreview: programmer creates an object of this class to preview a | |
301 | // wxPrintout. | |
302 | // ---------------------------------------------------------------------------- | |
303 | ||
459dbfc0 | 304 | class wxGnomePrintPreview : public wxPrintPreviewBase |
147bf263 JS |
305 | { |
306 | public: | |
307 | wxGnomePrintPreview(wxPrintout *printout, | |
308 | wxPrintout *printoutForPrinting = (wxPrintout *) NULL, | |
309 | wxPrintDialogData *data = (wxPrintDialogData *) NULL); | |
310 | wxGnomePrintPreview(wxPrintout *printout, | |
311 | wxPrintout *printoutForPrinting, | |
312 | wxPrintData *data); | |
313 | ||
314 | virtual ~wxGnomePrintPreview(); | |
315 | ||
316 | virtual bool Print(bool interactive); | |
317 | virtual void DetermineScaling(); | |
318 | ||
319 | private: | |
320 | void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); | |
321 | ||
322 | private: | |
323 | DECLARE_CLASS(wxGnomePrintPreview) | |
324 | }; | |
325 | ||
326 | ||
7c72311f RR |
327 | #endif |
328 | // wxUSE_LIBGNOMEPRINT | |
329 | ||
ff910433 | 330 | #endif |