]>
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 | |
6 | // Copyright: Robert Roebling | |
7c72311f | 7 | // Licence: wxWindows Licence |
ff910433 RR |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
3498362e PC |
10 | #ifndef _WX_GTK_GPRINT_H_ |
11 | #define _WX_GTK_GPRINT_H_ | |
ff910433 | 12 | |
20ceebaa | 13 | #include "wx/defs.h" |
ff910433 | 14 | |
7c72311f RR |
15 | #if wxUSE_LIBGNOMEPRINT |
16 | ||
ff910433 | 17 | #include "wx/print.h" |
ff910433 | 18 | #include "wx/printdlg.h" |
20ceebaa | 19 | #include "wx/dc.h" |
1ff62f51 | 20 | #include "wx/module.h" |
ff910433 RR |
21 | |
22 | typedef struct _GnomePrintJob GnomePrintJob; | |
23 | typedef struct _GnomePrintContext GnomePrintContext; | |
24 | typedef struct _GnomePrintConfig GnomePrintConfig; | |
25 | ||
1ff62f51 RR |
26 | // ---------------------------------------------------------------------------- |
27 | // wxGnomePrintModule | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
30 | class wxGnomePrintModule: public wxModule | |
31 | { | |
32 | public: | |
33 | wxGnomePrintModule() {} | |
34 | bool OnInit(); | |
35 | void OnExit(); | |
36 | ||
37 | private: | |
38 | DECLARE_DYNAMIC_CLASS(wxGnomePrintModule) | |
39 | }; | |
40 | ||
ff910433 RR |
41 | //---------------------------------------------------------------------------- |
42 | // wxGnomePrintNativeData | |
43 | //---------------------------------------------------------------------------- | |
44 | ||
45 | class wxGnomePrintNativeData: public wxPrintNativeDataBase | |
46 | { | |
47 | public: | |
48 | wxGnomePrintNativeData(); | |
49 | virtual ~wxGnomePrintNativeData(); | |
389076f1 | 50 | |
ff910433 RR |
51 | virtual bool TransferTo( wxPrintData &data ); |
52 | virtual bool TransferFrom( const wxPrintData &data ); | |
389076f1 | 53 | |
b7cacb43 VZ |
54 | virtual bool Ok() const { return IsOk(); } |
55 | virtual bool IsOk() const { return true; } | |
389076f1 | 56 | |
ff910433 | 57 | GnomePrintConfig* GetPrintConfig() { return m_config; } |
cffcf831 | 58 | void SetPrintJob( GnomePrintJob *job ) { m_job = job; } |
ff910433 | 59 | GnomePrintJob* GetPrintJob() { return m_job; } |
389076f1 WS |
60 | |
61 | ||
ff910433 RR |
62 | private: |
63 | GnomePrintConfig *m_config; | |
64 | GnomePrintJob *m_job; | |
389076f1 | 65 | |
ff910433 RR |
66 | DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData) |
67 | }; | |
389076f1 | 68 | |
ff910433 RR |
69 | //---------------------------------------------------------------------------- |
70 | // wxGnomePrintFactory | |
71 | //---------------------------------------------------------------------------- | |
72 | ||
73 | class wxGnomePrintFactory: public wxPrintFactory | |
74 | { | |
75 | public: | |
76 | virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data ); | |
389076f1 WS |
77 | |
78 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, | |
79 | wxPrintout *printout = NULL, | |
ff910433 | 80 | wxPrintDialogData *data = NULL ); |
389076f1 | 81 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, |
ff910433 RR |
82 | wxPrintout *printout, |
83 | wxPrintData *data ); | |
389076f1 WS |
84 | |
85 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
ff910433 | 86 | wxPrintDialogData *data = NULL ); |
389076f1 | 87 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, |
ff910433 | 88 | wxPrintData *data ); |
08680429 RR |
89 | |
90 | virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, | |
91 | wxPageSetupDialogData * data = NULL ); | |
389076f1 | 92 | |
4f37154e | 93 | #if wxUSE_NEW_DC |
888dde65 | 94 | virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); |
4f37154e | 95 | #else |
147bf263 | 96 | virtual wxDC* CreatePrinterDC( const wxPrintData& data ); |
4f37154e | 97 | #endif |
147bf263 | 98 | |
ff910433 RR |
99 | virtual bool HasPrintSetupDialog(); |
100 | virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); | |
101 | virtual bool HasOwnPrintToFile(); | |
102 | virtual bool HasPrinterLine(); | |
103 | virtual wxString CreatePrinterLine(); | |
104 | virtual bool HasStatusLine(); | |
105 | virtual wxString CreateStatusLine(); | |
389076f1 | 106 | |
ff910433 RR |
107 | virtual wxPrintNativeDataBase *CreatePrintNativeData(); |
108 | }; | |
109 | ||
110 | //---------------------------------------------------------------------------- | |
2934005d | 111 | // wxGnomePrintDialog |
ff910433 RR |
112 | //---------------------------------------------------------------------------- |
113 | ||
2934005d | 114 | class wxGnomePrintDialog: public wxPrintDialogBase |
ff910433 RR |
115 | { |
116 | public: | |
2934005d | 117 | wxGnomePrintDialog( wxWindow *parent, |
08680429 | 118 | wxPrintDialogData* data = NULL ); |
2934005d | 119 | wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); |
d3c7fc99 | 120 | virtual ~wxGnomePrintDialog(); |
2934005d RR |
121 | |
122 | wxPrintData& GetPrintData() | |
123 | { return m_printDialogData.GetPrintData(); } | |
124 | wxPrintDialogData& GetPrintDialogData() | |
125 | { return m_printDialogData; } | |
389076f1 | 126 | |
2934005d | 127 | wxDC *GetPrintDC(); |
ff910433 RR |
128 | |
129 | virtual int ShowModal(); | |
130 | ||
131 | virtual bool Validate(); | |
132 | virtual bool TransferDataToWindow(); | |
133 | virtual bool TransferDataFromWindow(); | |
134 | ||
3498362e | 135 | protected: |
ff910433 RR |
136 | // Implement some base class methods to do nothing to avoid asserts and |
137 | // GTK warnings, since this is not a real wxDialog. | |
138 | virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), | |
139 | int WXUNUSED(width), int WXUNUSED(height), | |
140 | int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} | |
141 | virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), | |
142 | int WXUNUSED(width), int WXUNUSED(height)) {} | |
389076f1 | 143 | |
3498362e | 144 | private: |
2934005d RR |
145 | void Init(); |
146 | wxPrintDialogData m_printDialogData; | |
389076f1 | 147 | |
2934005d | 148 | DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) |
ff910433 RR |
149 | }; |
150 | ||
151 | //---------------------------------------------------------------------------- | |
08680429 RR |
152 | // wxGnomePageSetupDialog |
153 | //---------------------------------------------------------------------------- | |
154 | ||
155 | class wxGnomePageSetupDialog: public wxPageSetupDialogBase | |
156 | { | |
157 | public: | |
158 | wxGnomePageSetupDialog( wxWindow *parent, | |
159 | wxPageSetupDialogData* data = NULL ); | |
d3c7fc99 | 160 | virtual ~wxGnomePageSetupDialog(); |
08680429 RR |
161 | |
162 | virtual wxPageSetupDialogData& GetPageSetupDialogData(); | |
163 | ||
164 | virtual int ShowModal(); | |
165 | ||
166 | virtual bool Validate(); | |
167 | virtual bool TransferDataToWindow(); | |
168 | virtual bool TransferDataFromWindow(); | |
169 | ||
3498362e | 170 | protected: |
08680429 RR |
171 | // Implement some base class methods to do nothing to avoid asserts and |
172 | // GTK warnings, since this is not a real wxDialog. | |
173 | virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), | |
174 | int WXUNUSED(width), int WXUNUSED(height), | |
175 | int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} | |
176 | virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), | |
177 | int WXUNUSED(width), int WXUNUSED(height)) {} | |
389076f1 | 178 | |
3498362e | 179 | private: |
08680429 | 180 | wxPageSetupDialogData m_pageDialogData; |
389076f1 | 181 | |
08680429 RR |
182 | DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) |
183 | }; | |
184 | ||
185 | //---------------------------------------------------------------------------- | |
ff910433 RR |
186 | // wxGnomePrinter |
187 | //---------------------------------------------------------------------------- | |
188 | ||
189 | class wxGnomePrinter: public wxPrinterBase | |
190 | { | |
191 | public: | |
192 | wxGnomePrinter(wxPrintDialogData *data = NULL); | |
193 | virtual ~wxGnomePrinter(); | |
194 | ||
195 | virtual bool Print(wxWindow *parent, | |
196 | wxPrintout *printout, | |
197 | bool prompt = true); | |
198 | virtual wxDC* PrintDialog(wxWindow *parent); | |
199 | virtual bool Setup(wxWindow *parent); | |
389076f1 | 200 | |
ff910433 | 201 | private: |
0be7709e | 202 | bool m_native_preview; |
ff910433 RR |
203 | |
204 | private: | |
205 | DECLARE_DYNAMIC_CLASS(wxGnomePrinter) | |
c0c133e1 | 206 | wxDECLARE_NO_COPY_CLASS(wxGnomePrinter); |
ff910433 RR |
207 | }; |
208 | ||
209 | //----------------------------------------------------------------------------- | |
c8ddadff | 210 | // wxGnomePrinterDC |
ff910433 RR |
211 | //----------------------------------------------------------------------------- |
212 | ||
4f37154e | 213 | #if wxUSE_NEW_DC |
888dde65 | 214 | class wxGnomePrinterDCImpl : public wxDCImpl |
4f37154e | 215 | #else |
888dde65 | 216 | #define wxGnomePrinterDCImpl wxGnomePrinterDC |
4f37154e RR |
217 | class wxGnomePrinterDC : public wxDC |
218 | #endif | |
ff910433 RR |
219 | { |
220 | public: | |
4f37154e | 221 | #if wxUSE_NEW_DC |
888dde65 | 222 | wxGnomePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ); |
4f37154e | 223 | #else |
c8ddadff | 224 | wxGnomePrinterDC( const wxPrintData& data ); |
4f37154e | 225 | #endif |
888dde65 | 226 | virtual ~wxGnomePrinterDCImpl(); |
389076f1 | 227 | |
b7cacb43 VZ |
228 | bool Ok() const { return IsOk(); } |
229 | bool IsOk() const; | |
389076f1 | 230 | |
3498362e PC |
231 | bool CanDrawBitmap() const { return true; } |
232 | void Clear(); | |
233 | void SetFont( const wxFont& font ); | |
234 | void SetPen( const wxPen& pen ); | |
235 | void SetBrush( const wxBrush& brush ); | |
89efaf2b | 236 | void SetLogicalFunction( wxRasterOperationMode function ); |
3498362e PC |
237 | void SetBackground( const wxBrush& brush ); |
238 | void DestroyClippingRegion(); | |
239 | bool StartDoc(const wxString& message); | |
240 | void EndDoc(); | |
241 | void StartPage(); | |
242 | void EndPage(); | |
243 | wxCoord GetCharHeight() const; | |
244 | wxCoord GetCharWidth() const; | |
245 | bool CanGetTextExtent() const { return true; } | |
246 | wxSize GetPPI() const; | |
3498362e PC |
247 | virtual int GetDepth() const { return 24; } |
248 | void SetBackgroundMode(int WXUNUSED(mode)) { } | |
249 | void SetPalette(const wxPalette& WXUNUSED(palette)) { } | |
3498362e PC |
250 | |
251 | protected: | |
03647350 | 252 | bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, |
89efaf2b | 253 | wxFloodFillStyle style=wxFLOOD_SURFACE ); |
ff910433 RR |
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); | |
4787c92d PC |
260 | void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); |
261 | void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); | |
262 | void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); | |
ff910433 RR |
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); |
6d52ca53 | 268 | #endif |
ff910433 | 269 | bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, |
03647350 | 270 | wxDC *source, wxCoord xsrc, wxCoord ysrc, |
89efaf2b | 271 | wxRasterOperationMode = wxCOPY, bool useMask = false, |
ff910433 RR |
272 | wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); |
273 | void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ); | |
274 | void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false ); | |
ff910433 RR |
275 | void DoDrawText(const wxString& text, wxCoord x, wxCoord y ); |
276 | void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle); | |
ff910433 | 277 | void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
fdaad94e VZ |
278 | void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip) ) |
279 | { | |
280 | wxFAIL_MSG( "not implemented" ); | |
281 | } | |
ff910433 | 282 | void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, |
d3b9f782 VZ |
283 | wxCoord *descent = NULL, |
284 | wxCoord *externalLeading = NULL, | |
285 | const wxFont *theFont = NULL ) const; | |
ff910433 RR |
286 | void DoGetSize(int* width, int* height) const; |
287 | void DoGetSizeMM(int *width, int *height) const; | |
389076f1 | 288 | |
3b7ab6bd | 289 | void SetPrintData(const wxPrintData& data); |
ff910433 | 290 | wxPrintData& GetPrintData() { return m_printData; } |
389076f1 | 291 | |
4c51a665 | 292 | // overridden for wxPrinterDC Impl |
6d52ca53 FM |
293 | virtual wxRect GetPaperRect() const; |
294 | virtual int GetResolution() const; | |
4f37154e | 295 | |
2e66ffc7 RD |
296 | virtual void* GetHandle() const { return (void*)m_gpc; } |
297 | ||
ff910433 | 298 | private: |
147bf263 | 299 | wxPrintData m_printData; |
ff910433 RR |
300 | PangoContext *m_context; |
301 | PangoLayout *m_layout; | |
302 | PangoFontDescription *m_fontdesc; | |
389076f1 | 303 | |
ff910433 RR |
304 | unsigned char m_currentRed; |
305 | unsigned char m_currentGreen; | |
306 | unsigned char m_currentBlue; | |
6d52ca53 | 307 | |
02255e07 | 308 | double m_pageHeight; |
389076f1 | 309 | |
ff910433 | 310 | GnomePrintContext *m_gpc; |
3b7ab6bd | 311 | GnomePrintJob* m_job; |
ff910433 | 312 | |
74ab0bfb | 313 | void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height); |
c94f845b | 314 | |
ff910433 | 315 | private: |
888dde65 | 316 | DECLARE_DYNAMIC_CLASS(wxGnomePrinterDCImpl) |
c0c133e1 | 317 | wxDECLARE_NO_COPY_CLASS(wxGnomePrinterDCImpl); |
ff910433 RR |
318 | }; |
319 | ||
147bf263 JS |
320 | // ---------------------------------------------------------------------------- |
321 | // wxGnomePrintPreview: programmer creates an object of this class to preview a | |
322 | // wxPrintout. | |
323 | // ---------------------------------------------------------------------------- | |
324 | ||
459dbfc0 | 325 | class wxGnomePrintPreview : public wxPrintPreviewBase |
147bf263 JS |
326 | { |
327 | public: | |
328 | wxGnomePrintPreview(wxPrintout *printout, | |
d3b9f782 VZ |
329 | wxPrintout *printoutForPrinting = NULL, |
330 | wxPrintDialogData *data = NULL); | |
147bf263 JS |
331 | wxGnomePrintPreview(wxPrintout *printout, |
332 | wxPrintout *printoutForPrinting, | |
333 | wxPrintData *data); | |
334 | ||
335 | virtual ~wxGnomePrintPreview(); | |
336 | ||
337 | virtual bool Print(bool interactive); | |
338 | virtual void DetermineScaling(); | |
339 | ||
340 | private: | |
341 | void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); | |
342 | ||
343 | private: | |
344 | DECLARE_CLASS(wxGnomePrintPreview) | |
345 | }; | |
346 | ||
347 | ||
7c72311f RR |
348 | #endif |
349 | // wxUSE_LIBGNOMEPRINT | |
350 | ||
ff910433 | 351 | #endif |