]>
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 | |
4f37154e | 94 | #if wxUSE_NEW_DC |
888dde65 | 95 | virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); |
4f37154e | 96 | #else |
147bf263 | 97 | virtual wxDC* CreatePrinterDC( const wxPrintData& data ); |
4f37154e | 98 | #endif |
147bf263 | 99 | |
ff910433 RR |
100 | virtual bool HasPrintSetupDialog(); |
101 | virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); | |
102 | virtual bool HasOwnPrintToFile(); | |
103 | virtual bool HasPrinterLine(); | |
104 | virtual wxString CreatePrinterLine(); | |
105 | virtual bool HasStatusLine(); | |
106 | virtual wxString CreateStatusLine(); | |
389076f1 | 107 | |
ff910433 RR |
108 | virtual wxPrintNativeDataBase *CreatePrintNativeData(); |
109 | }; | |
110 | ||
111 | //---------------------------------------------------------------------------- | |
2934005d | 112 | // wxGnomePrintDialog |
ff910433 RR |
113 | //---------------------------------------------------------------------------- |
114 | ||
2934005d | 115 | class wxGnomePrintDialog: public wxPrintDialogBase |
ff910433 RR |
116 | { |
117 | public: | |
2934005d | 118 | wxGnomePrintDialog( wxWindow *parent, |
08680429 | 119 | wxPrintDialogData* data = NULL ); |
2934005d | 120 | wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); |
d3c7fc99 | 121 | virtual ~wxGnomePrintDialog(); |
2934005d RR |
122 | |
123 | wxPrintData& GetPrintData() | |
124 | { return m_printDialogData.GetPrintData(); } | |
125 | wxPrintDialogData& GetPrintDialogData() | |
126 | { return m_printDialogData; } | |
389076f1 | 127 | |
2934005d | 128 | wxDC *GetPrintDC(); |
ff910433 RR |
129 | |
130 | virtual int ShowModal(); | |
131 | ||
132 | virtual bool Validate(); | |
133 | virtual bool TransferDataToWindow(); | |
134 | virtual bool TransferDataFromWindow(); | |
135 | ||
3498362e | 136 | protected: |
ff910433 RR |
137 | // Implement some base class methods to do nothing to avoid asserts and |
138 | // GTK warnings, since this is not a real wxDialog. | |
139 | virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), | |
140 | int WXUNUSED(width), int WXUNUSED(height), | |
141 | int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} | |
142 | virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), | |
143 | int WXUNUSED(width), int WXUNUSED(height)) {} | |
389076f1 | 144 | |
3498362e | 145 | private: |
2934005d RR |
146 | void Init(); |
147 | wxPrintDialogData m_printDialogData; | |
389076f1 | 148 | |
2934005d | 149 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) |
ff910433 RR |
150 | }; |
151 | ||
152 | //---------------------------------------------------------------------------- | |
08680429 RR |
153 | // wxGnomePageSetupDialog |
154 | //---------------------------------------------------------------------------- | |
155 | ||
156 | class wxGnomePageSetupDialog: public wxPageSetupDialogBase | |
157 | { | |
158 | public: | |
159 | wxGnomePageSetupDialog( wxWindow *parent, | |
160 | wxPageSetupDialogData* data = NULL ); | |
d3c7fc99 | 161 | virtual ~wxGnomePageSetupDialog(); |
08680429 RR |
162 | |
163 | virtual wxPageSetupDialogData& GetPageSetupDialogData(); | |
164 | ||
165 | virtual int ShowModal(); | |
166 | ||
167 | virtual bool Validate(); | |
168 | virtual bool TransferDataToWindow(); | |
169 | virtual bool TransferDataFromWindow(); | |
170 | ||
3498362e | 171 | protected: |
08680429 RR |
172 | // Implement some base class methods to do nothing to avoid asserts and |
173 | // GTK warnings, since this is not a real wxDialog. | |
174 | virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), | |
175 | int WXUNUSED(width), int WXUNUSED(height), | |
176 | int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} | |
177 | virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), | |
178 | int WXUNUSED(width), int WXUNUSED(height)) {} | |
389076f1 | 179 | |
3498362e | 180 | private: |
08680429 | 181 | wxPageSetupDialogData m_pageDialogData; |
389076f1 | 182 | |
08680429 RR |
183 | DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) |
184 | }; | |
185 | ||
186 | //---------------------------------------------------------------------------- | |
ff910433 RR |
187 | // wxGnomePrinter |
188 | //---------------------------------------------------------------------------- | |
189 | ||
190 | class wxGnomePrinter: public wxPrinterBase | |
191 | { | |
192 | public: | |
193 | wxGnomePrinter(wxPrintDialogData *data = NULL); | |
194 | virtual ~wxGnomePrinter(); | |
195 | ||
196 | virtual bool Print(wxWindow *parent, | |
197 | wxPrintout *printout, | |
198 | bool prompt = true); | |
199 | virtual wxDC* PrintDialog(wxWindow *parent); | |
200 | virtual bool Setup(wxWindow *parent); | |
389076f1 | 201 | |
ff910433 | 202 | private: |
0be7709e | 203 | bool m_native_preview; |
ff910433 RR |
204 | |
205 | private: | |
206 | DECLARE_DYNAMIC_CLASS(wxGnomePrinter) | |
207 | DECLARE_NO_COPY_CLASS(wxGnomePrinter) | |
208 | }; | |
209 | ||
210 | //----------------------------------------------------------------------------- | |
c8ddadff | 211 | // wxGnomePrinterDC |
ff910433 RR |
212 | //----------------------------------------------------------------------------- |
213 | ||
4f37154e | 214 | #if wxUSE_NEW_DC |
888dde65 | 215 | class wxGnomePrinterDCImpl : public wxDCImpl |
4f37154e | 216 | #else |
888dde65 | 217 | #define wxGnomePrinterDCImpl wxGnomePrinterDC |
4f37154e RR |
218 | class wxGnomePrinterDC : public wxDC |
219 | #endif | |
ff910433 RR |
220 | { |
221 | public: | |
4f37154e | 222 | #if wxUSE_NEW_DC |
888dde65 | 223 | wxGnomePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); |
4f37154e | 224 | #else |
c8ddadff | 225 | wxGnomePrinterDC( const wxPrintData& data ); |
4f37154e | 226 | #endif |
888dde65 | 227 | virtual ~wxGnomePrinterDCImpl(); |
389076f1 | 228 | |
b7cacb43 VZ |
229 | bool Ok() const { return IsOk(); } |
230 | bool IsOk() const; | |
389076f1 | 231 | |
3498362e PC |
232 | bool CanDrawBitmap() const { return true; } |
233 | void Clear(); | |
234 | void SetFont( const wxFont& font ); | |
235 | void SetPen( const wxPen& pen ); | |
236 | void SetBrush( const wxBrush& brush ); | |
237 | void SetLogicalFunction( int function ); | |
238 | void SetBackground( const wxBrush& brush ); | |
239 | void DestroyClippingRegion(); | |
240 | bool StartDoc(const wxString& message); | |
241 | void EndDoc(); | |
242 | void StartPage(); | |
243 | void EndPage(); | |
244 | wxCoord GetCharHeight() const; | |
245 | wxCoord GetCharWidth() const; | |
246 | bool CanGetTextExtent() const { return true; } | |
247 | wxSize GetPPI() const; | |
3498362e PC |
248 | virtual int GetDepth() const { return 24; } |
249 | void SetBackgroundMode(int WXUNUSED(mode)) { } | |
250 | void SetPalette(const wxPalette& WXUNUSED(palette)) { } | |
3498362e PC |
251 | |
252 | protected: | |
ff910433 RR |
253 | bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE ); |
254 | bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; | |
255 | void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
256 | void DoCrossHair(wxCoord x, wxCoord y); | |
257 | void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); | |
258 | void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); | |
259 | void DoDrawPoint(wxCoord x, wxCoord y); | |
260 | void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); | |
261 | void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
262 | void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE); | |
263 | void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
264 | void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0); | |
265 | void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
389076f1 | 266 | #if wxUSE_SPLINES |
b0d7707b | 267 | void DoDrawSpline(const wxPointList *points); |
c8ddadff | 268 | #endif |
ff910433 RR |
269 | bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
270 | wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false, | |
271 | wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); | |
272 | void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ); | |
273 | void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false ); | |
ff910433 RR |
274 | void DoDrawText(const wxString& text, wxCoord x, wxCoord y ); |
275 | void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); | |
ff910433 | 276 | void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
ff910433 | 277 | void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { } |
ff910433 RR |
278 | void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, |
279 | wxCoord *descent = (wxCoord *) NULL, | |
280 | wxCoord *externalLeading = (wxCoord *) NULL, | |
c94f845b | 281 | const wxFont *theFont = (wxFont *) NULL ) const; |
ff910433 RR |
282 | void DoGetSize(int* width, int* height) const; |
283 | void DoGetSizeMM(int *width, int *height) const; | |
389076f1 | 284 | |
3b7ab6bd | 285 | void SetPrintData(const wxPrintData& data); |
ff910433 | 286 | wxPrintData& GetPrintData() { return m_printData; } |
389076f1 | 287 | |
4f37154e RR |
288 | // overriden for wxPrinterDC Impl |
289 | virtual wxRect GetPaperRect(); | |
290 | virtual int GetResolution(); | |
291 | ||
ff910433 | 292 | private: |
147bf263 | 293 | wxPrintData m_printData; |
ff910433 RR |
294 | PangoContext *m_context; |
295 | PangoLayout *m_layout; | |
296 | PangoFontDescription *m_fontdesc; | |
389076f1 | 297 | |
ff910433 RR |
298 | unsigned char m_currentRed; |
299 | unsigned char m_currentGreen; | |
300 | unsigned char m_currentBlue; | |
02255e07 RR |
301 | |
302 | double m_pageHeight; | |
389076f1 | 303 | |
ff910433 | 304 | GnomePrintContext *m_gpc; |
3b7ab6bd | 305 | GnomePrintJob* m_job; |
ff910433 | 306 | |
74ab0bfb | 307 | void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
c94f845b | 308 | |
ff910433 | 309 | private: |
888dde65 RR |
310 | DECLARE_DYNAMIC_CLASS(wxGnomePrinterDCImpl) |
311 | DECLARE_NO_COPY_CLASS(wxGnomePrinterDCImpl) | |
ff910433 RR |
312 | }; |
313 | ||
147bf263 JS |
314 | // ---------------------------------------------------------------------------- |
315 | // wxGnomePrintPreview: programmer creates an object of this class to preview a | |
316 | // wxPrintout. | |
317 | // ---------------------------------------------------------------------------- | |
318 | ||
459dbfc0 | 319 | class wxGnomePrintPreview : public wxPrintPreviewBase |
147bf263 JS |
320 | { |
321 | public: | |
322 | wxGnomePrintPreview(wxPrintout *printout, | |
323 | wxPrintout *printoutForPrinting = (wxPrintout *) NULL, | |
324 | wxPrintDialogData *data = (wxPrintDialogData *) NULL); | |
325 | wxGnomePrintPreview(wxPrintout *printout, | |
326 | wxPrintout *printoutForPrinting, | |
327 | wxPrintData *data); | |
328 | ||
329 | virtual ~wxGnomePrintPreview(); | |
330 | ||
331 | virtual bool Print(bool interactive); | |
332 | virtual void DetermineScaling(); | |
333 | ||
334 | private: | |
335 | void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); | |
336 | ||
337 | private: | |
338 | DECLARE_CLASS(wxGnomePrintPreview) | |
339 | }; | |
340 | ||
341 | ||
7c72311f RR |
342 | #endif |
343 | // wxUSE_LIBGNOMEPRINT | |
344 | ||
ff910433 | 345 | #endif |