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
);
95 virtual wxDCImpl
* CreatePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
);
97 virtual wxDC
* CreatePrinterDC( const wxPrintData
& data
);
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();
108 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
111 //----------------------------------------------------------------------------
112 // wxGnomePrintDialog
113 //----------------------------------------------------------------------------
115 class wxGnomePrintDialog
: public wxPrintDialogBase
118 wxGnomePrintDialog( wxWindow
*parent
,
119 wxPrintDialogData
* data
= NULL
);
120 wxGnomePrintDialog( wxWindow
*parent
, wxPrintData
* data
);
121 virtual ~wxGnomePrintDialog();
123 wxPrintData
& GetPrintData()
124 { return m_printDialogData
.GetPrintData(); }
125 wxPrintDialogData
& GetPrintDialogData()
126 { return m_printDialogData
; }
130 virtual int ShowModal();
132 virtual bool Validate();
133 virtual bool TransferDataToWindow();
134 virtual bool TransferDataFromWindow();
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
)) {}
147 wxPrintDialogData m_printDialogData
;
149 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog
)
152 //----------------------------------------------------------------------------
153 // wxGnomePageSetupDialog
154 //----------------------------------------------------------------------------
156 class wxGnomePageSetupDialog
: public wxPageSetupDialogBase
159 wxGnomePageSetupDialog( wxWindow
*parent
,
160 wxPageSetupDialogData
* data
= NULL
);
161 virtual ~wxGnomePageSetupDialog();
163 virtual wxPageSetupDialogData
& GetPageSetupDialogData();
165 virtual int ShowModal();
167 virtual bool Validate();
168 virtual bool TransferDataToWindow();
169 virtual bool TransferDataFromWindow();
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
)) {}
181 wxPageSetupDialogData m_pageDialogData
;
183 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog
)
186 //----------------------------------------------------------------------------
188 //----------------------------------------------------------------------------
190 class wxGnomePrinter
: public wxPrinterBase
193 wxGnomePrinter(wxPrintDialogData
*data
= NULL
);
194 virtual ~wxGnomePrinter();
196 virtual bool Print(wxWindow
*parent
,
197 wxPrintout
*printout
,
199 virtual wxDC
* PrintDialog(wxWindow
*parent
);
200 virtual bool Setup(wxWindow
*parent
);
203 bool m_native_preview
;
206 DECLARE_DYNAMIC_CLASS(wxGnomePrinter
)
207 DECLARE_NO_COPY_CLASS(wxGnomePrinter
)
210 //-----------------------------------------------------------------------------
212 //-----------------------------------------------------------------------------
215 class wxGnomePrinterDCImpl
: public wxDCImpl
217 #define wxGnomePrinterDCImpl wxGnomePrinterDC
218 class wxGnomePrinterDC
: public wxDC
223 wxGnomePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
);
225 wxGnomePrinterDC( const wxPrintData
& data
);
227 virtual ~wxGnomePrinterDCImpl();
229 bool Ok() const { return IsOk(); }
232 bool CanDrawBitmap() const { return true; }
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
);
244 wxCoord
GetCharHeight() const;
245 wxCoord
GetCharWidth() const;
246 bool CanGetTextExtent() const { return true; }
247 wxSize
GetPPI() const;
248 virtual int GetDepth() const { return 24; }
249 void SetBackgroundMode(int WXUNUSED(mode
)) { }
250 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
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
);
267 void DoDrawSpline(const wxPointList
*points
);
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 );
274 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
275 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
276 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
277 void DoSetDeviceClippingRegion( const wxRegion
&WXUNUSED(clip
) )
279 wxFAIL_MSG( "not implemented" );
281 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
282 wxCoord
*descent
= (wxCoord
*) NULL
,
283 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
284 const wxFont
*theFont
= (wxFont
*) NULL
) const;
285 void DoGetSize(int* width
, int* height
) const;
286 void DoGetSizeMM(int *width
, int *height
) const;
288 void SetPrintData(const wxPrintData
& data
);
289 wxPrintData
& GetPrintData() { return m_printData
; }
291 // overriden for wxPrinterDC Impl
292 virtual wxRect
GetPaperRect() const;
293 virtual int GetResolution() const;
296 wxPrintData m_printData
;
297 PangoContext
*m_context
;
298 PangoLayout
*m_layout
;
299 PangoFontDescription
*m_fontdesc
;
301 unsigned char m_currentRed
;
302 unsigned char m_currentGreen
;
303 unsigned char m_currentBlue
;
307 GnomePrintContext
*m_gpc
;
308 GnomePrintJob
* m_job
;
310 void makeEllipticalPath(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
313 DECLARE_DYNAMIC_CLASS(wxGnomePrinterDCImpl
)
314 DECLARE_NO_COPY_CLASS(wxGnomePrinterDCImpl
)
317 // ----------------------------------------------------------------------------
318 // wxGnomePrintPreview: programmer creates an object of this class to preview a
320 // ----------------------------------------------------------------------------
322 class wxGnomePrintPreview
: public wxPrintPreviewBase
325 wxGnomePrintPreview(wxPrintout
*printout
,
326 wxPrintout
*printoutForPrinting
= (wxPrintout
*) NULL
,
327 wxPrintDialogData
*data
= (wxPrintDialogData
*) NULL
);
328 wxGnomePrintPreview(wxPrintout
*printout
,
329 wxPrintout
*printoutForPrinting
,
332 virtual ~wxGnomePrintPreview();
334 virtual bool Print(bool interactive
);
335 virtual void DetermineScaling();
338 void Init(wxPrintout
*printout
, wxPrintout
*printoutForPrinting
);
341 DECLARE_CLASS(wxGnomePrintPreview
)
346 // wxUSE_LIBGNOMEPRINT