1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/gnome/gprint.h
3 // Author: Robert Roebling
4 // Purpose: GNOME printing support
6 // Copyright: Robert Roebling
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_GPRINT_H_
11 #define _WX_GTK_GPRINT_H_
15 #if wxUSE_LIBGNOMEPRINT
18 #include "wx/printdlg.h"
20 #include "wx/module.h"
22 typedef struct _GnomePrintJob GnomePrintJob
;
23 typedef struct _GnomePrintContext GnomePrintContext
;
24 typedef struct _GnomePrintConfig GnomePrintConfig
;
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class wxGnomePrintModule
: public wxModule
33 wxGnomePrintModule() {}
38 DECLARE_DYNAMIC_CLASS(wxGnomePrintModule
)
41 //----------------------------------------------------------------------------
42 // wxGnomePrintNativeData
43 //----------------------------------------------------------------------------
45 class wxGnomePrintNativeData
: public wxPrintNativeDataBase
48 wxGnomePrintNativeData();
49 virtual ~wxGnomePrintNativeData();
51 virtual bool TransferTo( wxPrintData
&data
);
52 virtual bool TransferFrom( const wxPrintData
&data
);
54 virtual bool Ok() const { return IsOk(); }
55 virtual bool IsOk() const { return true; }
57 GnomePrintConfig
* GetPrintConfig() { return m_config
; }
58 void SetPrintJob( GnomePrintJob
*job
) { m_job
= job
; }
59 GnomePrintJob
* GetPrintJob() { return m_job
; }
63 GnomePrintConfig
*m_config
;
66 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData
)
69 //----------------------------------------------------------------------------
70 // wxGnomePrintFactory
71 //----------------------------------------------------------------------------
73 class wxGnomePrintFactory
: public wxPrintFactory
76 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
*data
);
78 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
79 wxPrintout
*printout
= NULL
,
80 wxPrintDialogData
*data
= NULL
);
81 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
85 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
86 wxPrintDialogData
*data
= NULL
);
87 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
90 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
91 wxPageSetupDialogData
* data
= NULL
);
94 virtual wxDCImpl
* CreatePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
);
96 virtual wxDC
* CreatePrinterDC( const wxPrintData
& data
);
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();
107 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
110 //----------------------------------------------------------------------------
111 // wxGnomePrintDialog
112 //----------------------------------------------------------------------------
114 class wxGnomePrintDialog
: public wxPrintDialogBase
117 wxGnomePrintDialog( wxWindow
*parent
,
118 wxPrintDialogData
* data
= NULL
);
119 wxGnomePrintDialog( wxWindow
*parent
, wxPrintData
* data
);
120 virtual ~wxGnomePrintDialog();
122 wxPrintData
& GetPrintData()
123 { return m_printDialogData
.GetPrintData(); }
124 wxPrintDialogData
& GetPrintDialogData()
125 { return m_printDialogData
; }
129 virtual int ShowModal();
131 virtual bool Validate();
132 virtual bool TransferDataToWindow();
133 virtual bool TransferDataFromWindow();
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
)) {}
146 wxPrintDialogData m_printDialogData
;
148 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog
)
151 //----------------------------------------------------------------------------
152 // wxGnomePageSetupDialog
153 //----------------------------------------------------------------------------
155 class wxGnomePageSetupDialog
: public wxPageSetupDialogBase
158 wxGnomePageSetupDialog( wxWindow
*parent
,
159 wxPageSetupDialogData
* data
= NULL
);
160 virtual ~wxGnomePageSetupDialog();
162 virtual wxPageSetupDialogData
& GetPageSetupDialogData();
164 virtual int ShowModal();
166 virtual bool Validate();
167 virtual bool TransferDataToWindow();
168 virtual bool TransferDataFromWindow();
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
)) {}
180 wxPageSetupDialogData m_pageDialogData
;
182 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog
)
185 //----------------------------------------------------------------------------
187 //----------------------------------------------------------------------------
189 class wxGnomePrinter
: public wxPrinterBase
192 wxGnomePrinter(wxPrintDialogData
*data
= NULL
);
193 virtual ~wxGnomePrinter();
195 virtual bool Print(wxWindow
*parent
,
196 wxPrintout
*printout
,
198 virtual wxDC
* PrintDialog(wxWindow
*parent
);
199 virtual bool Setup(wxWindow
*parent
);
202 bool m_native_preview
;
205 DECLARE_DYNAMIC_CLASS(wxGnomePrinter
)
206 wxDECLARE_NO_COPY_CLASS(wxGnomePrinter
);
209 //-----------------------------------------------------------------------------
211 //-----------------------------------------------------------------------------
214 class wxGnomePrinterDCImpl
: public wxDCImpl
216 #define wxGnomePrinterDCImpl wxGnomePrinterDC
217 class wxGnomePrinterDC
: public wxDC
222 wxGnomePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
);
224 wxGnomePrinterDC( const wxPrintData
& data
);
226 virtual ~wxGnomePrinterDCImpl();
228 bool Ok() const { return IsOk(); }
231 bool CanDrawBitmap() const { return true; }
233 void SetFont( const wxFont
& font
);
234 void SetPen( const wxPen
& pen
);
235 void SetBrush( const wxBrush
& brush
);
236 void SetLogicalFunction( wxRasterOperationMode function
);
237 void SetBackground( const wxBrush
& brush
);
238 void DestroyClippingRegion();
239 bool StartDoc(const wxString
& message
);
243 wxCoord
GetCharHeight() const;
244 wxCoord
GetCharWidth() const;
245 bool CanGetTextExtent() const { return true; }
246 wxSize
GetPPI() const;
247 virtual int GetDepth() const { return 24; }
248 void SetBackgroundMode(int WXUNUSED(mode
)) { }
249 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
252 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
,
253 wxFloodFillStyle 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
, 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
);
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
);
267 void DoDrawSpline(const wxPointList
*points
);
269 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
270 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
,
271 wxRasterOperationMode
= wxCOPY
, bool useMask
= false,
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 );
275 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
276 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
277 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
278 void DoSetDeviceClippingRegion( const wxRegion
&WXUNUSED(clip
) )
280 wxFAIL_MSG( "not implemented" );
282 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
283 wxCoord
*descent
= NULL
,
284 wxCoord
*externalLeading
= NULL
,
285 const wxFont
*theFont
= NULL
) const;
286 void DoGetSize(int* width
, int* height
) const;
287 void DoGetSizeMM(int *width
, int *height
) const;
289 void SetPrintData(const wxPrintData
& data
);
290 wxPrintData
& GetPrintData() { return m_printData
; }
292 // overridden for wxPrinterDC Impl
293 virtual wxRect
GetPaperRect() const;
294 virtual int GetResolution() const;
296 virtual void* GetHandle() const { return (void*)m_gpc
; }
299 wxPrintData m_printData
;
300 PangoContext
*m_context
;
301 PangoLayout
*m_layout
;
302 PangoFontDescription
*m_fontdesc
;
304 unsigned char m_currentRed
;
305 unsigned char m_currentGreen
;
306 unsigned char m_currentBlue
;
310 GnomePrintContext
*m_gpc
;
311 GnomePrintJob
* m_job
;
313 void makeEllipticalPath(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
316 DECLARE_DYNAMIC_CLASS(wxGnomePrinterDCImpl
)
317 wxDECLARE_NO_COPY_CLASS(wxGnomePrinterDCImpl
);
320 // ----------------------------------------------------------------------------
321 // wxGnomePrintPreview: programmer creates an object of this class to preview a
323 // ----------------------------------------------------------------------------
325 class wxGnomePrintPreview
: public wxPrintPreviewBase
328 wxGnomePrintPreview(wxPrintout
*printout
,
329 wxPrintout
*printoutForPrinting
= NULL
,
330 wxPrintDialogData
*data
= NULL
);
331 wxGnomePrintPreview(wxPrintout
*printout
,
332 wxPrintout
*printoutForPrinting
,
335 virtual ~wxGnomePrintPreview();
337 virtual bool Print(bool interactive
);
338 virtual void DetermineScaling();
341 void Init(wxPrintout
*printout
, wxPrintout
*printoutForPrinting
);
344 DECLARE_CLASS(wxGnomePrintPreview
)
349 // wxUSE_LIBGNOMEPRINT