1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/gnome/gprint.h
3 // Author: Robert Roebling
4 // Purpose: GNOME printing support
7 // Copyright: Robert Roebling
8 // Licence: wxWindows Licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTK_GPRINT_H_
12 #define _WX_GTK_GPRINT_H_
16 #if wxUSE_LIBGNOMEPRINT
19 #include "wx/printdlg.h"
21 #include "wx/module.h"
23 typedef struct _GnomePrintJob GnomePrintJob
;
24 typedef struct _GnomePrintContext GnomePrintContext
;
25 typedef struct _GnomePrintConfig GnomePrintConfig
;
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class wxGnomePrintModule
: public wxModule
34 wxGnomePrintModule() {}
39 DECLARE_DYNAMIC_CLASS(wxGnomePrintModule
)
42 //----------------------------------------------------------------------------
43 // wxGnomePrintNativeData
44 //----------------------------------------------------------------------------
46 class wxGnomePrintNativeData
: public wxPrintNativeDataBase
49 wxGnomePrintNativeData();
50 virtual ~wxGnomePrintNativeData();
52 virtual bool TransferTo( wxPrintData
&data
);
53 virtual bool TransferFrom( const wxPrintData
&data
);
55 virtual bool Ok() const { return IsOk(); }
56 virtual bool IsOk() const { return true; }
58 GnomePrintConfig
* GetPrintConfig() { return m_config
; }
59 void SetPrintJob( GnomePrintJob
*job
) { m_job
= job
; }
60 GnomePrintJob
* GetPrintJob() { return m_job
; }
64 GnomePrintConfig
*m_config
;
67 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData
)
70 //----------------------------------------------------------------------------
71 // wxGnomePrintFactory
72 //----------------------------------------------------------------------------
74 class wxGnomePrintFactory
: public wxPrintFactory
77 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
*data
);
79 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
80 wxPrintout
*printout
= NULL
,
81 wxPrintDialogData
*data
= NULL
);
82 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
86 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
87 wxPrintDialogData
*data
= NULL
);
88 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
91 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
92 wxPageSetupDialogData
* data
= NULL
);
94 virtual wxDC
* CreatePrinterDC( const wxPrintData
& data
);
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();
104 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
107 //----------------------------------------------------------------------------
108 // wxGnomePrintDialog
109 //----------------------------------------------------------------------------
111 class wxGnomePrintDialog
: public wxPrintDialogBase
114 wxGnomePrintDialog( wxWindow
*parent
,
115 wxPrintDialogData
* data
= NULL
);
116 wxGnomePrintDialog( wxWindow
*parent
, wxPrintData
* data
);
117 virtual ~wxGnomePrintDialog();
119 wxPrintData
& GetPrintData()
120 { return m_printDialogData
.GetPrintData(); }
121 wxPrintDialogData
& GetPrintDialogData()
122 { return m_printDialogData
; }
126 virtual int ShowModal();
128 virtual bool Validate();
129 virtual bool TransferDataToWindow();
130 virtual bool TransferDataFromWindow();
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
)) {}
143 wxPrintDialogData m_printDialogData
;
145 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog
)
148 //----------------------------------------------------------------------------
149 // wxGnomePageSetupDialog
150 //----------------------------------------------------------------------------
152 class wxGnomePageSetupDialog
: public wxPageSetupDialogBase
155 wxGnomePageSetupDialog( wxWindow
*parent
,
156 wxPageSetupDialogData
* data
= NULL
);
157 virtual ~wxGnomePageSetupDialog();
159 virtual wxPageSetupDialogData
& GetPageSetupDialogData();
161 virtual int ShowModal();
163 virtual bool Validate();
164 virtual bool TransferDataToWindow();
165 virtual bool TransferDataFromWindow();
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
)) {}
177 wxPageSetupDialogData m_pageDialogData
;
179 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog
)
182 //----------------------------------------------------------------------------
184 //----------------------------------------------------------------------------
186 class wxGnomePrinter
: public wxPrinterBase
189 wxGnomePrinter(wxPrintDialogData
*data
= NULL
);
190 virtual ~wxGnomePrinter();
192 virtual bool Print(wxWindow
*parent
,
193 wxPrintout
*printout
,
195 virtual wxDC
* PrintDialog(wxWindow
*parent
);
196 virtual bool Setup(wxWindow
*parent
);
199 bool m_native_preview
;
202 DECLARE_DYNAMIC_CLASS(wxGnomePrinter
)
203 DECLARE_NO_COPY_CLASS(wxGnomePrinter
)
206 //-----------------------------------------------------------------------------
208 //-----------------------------------------------------------------------------
210 class wxGnomePrinterDC
: public wxDC
213 wxGnomePrinterDC( const wxPrintData
& data
);
214 virtual ~wxGnomePrinterDC();
216 bool Ok() const { return IsOk(); }
219 bool CanDrawBitmap() const { return true; }
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
);
231 wxCoord
GetCharHeight() const;
232 wxCoord
GetCharWidth() const;
233 bool CanGetTextExtent() const { return true; }
234 wxSize
GetPPI() const;
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();
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
);
256 void DoDrawSpline(const wxPointList
*points
);
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 );
263 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
264 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
265 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
266 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
267 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
268 wxCoord
*descent
= (wxCoord
*) NULL
,
269 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
270 const wxFont
*theFont
= (wxFont
*) NULL
) const;
271 void DoGetSize(int* width
, int* height
) const;
272 void DoGetSizeMM(int *width
, int *height
) const;
274 void SetPrintData(const wxPrintData
& data
);
275 wxPrintData
& GetPrintData() { return m_printData
; }
278 wxPrintData m_printData
;
279 PangoContext
*m_context
;
280 PangoLayout
*m_layout
;
281 PangoFontDescription
*m_fontdesc
;
283 unsigned char m_currentRed
;
284 unsigned char m_currentGreen
;
285 unsigned char m_currentBlue
;
289 GnomePrintContext
*m_gpc
;
290 GnomePrintJob
* m_job
;
292 void makeEllipticalPath(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
295 DECLARE_DYNAMIC_CLASS(wxGnomePrinterDC
)
296 DECLARE_NO_COPY_CLASS(wxGnomePrinterDC
)
299 // ----------------------------------------------------------------------------
300 // wxGnomePrintPreview: programmer creates an object of this class to preview a
302 // ----------------------------------------------------------------------------
304 class wxGnomePrintPreview
: public wxPrintPreviewBase
307 wxGnomePrintPreview(wxPrintout
*printout
,
308 wxPrintout
*printoutForPrinting
= (wxPrintout
*) NULL
,
309 wxPrintDialogData
*data
= (wxPrintDialogData
*) NULL
);
310 wxGnomePrintPreview(wxPrintout
*printout
,
311 wxPrintout
*printoutForPrinting
,
314 virtual ~wxGnomePrintPreview();
316 virtual bool Print(bool interactive
);
317 virtual void DetermineScaling();
320 void Init(wxPrintout
*printout
, wxPrintout
*printoutForPrinting
);
323 DECLARE_CLASS(wxGnomePrintPreview
)
328 // wxUSE_LIBGNOMEPRINT