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 wxGnomePrintDC
: public wxDC
213 wxGnomePrintDC( const wxPrintData
& data
);
214 virtual ~wxGnomePrintDC();
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 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
236 void SetLogicalOrigin( wxCoord x
, wxCoord y
);
237 void SetDeviceOrigin( wxCoord x
, wxCoord y
);
238 virtual int GetDepth() const { return 24; }
239 void SetBackgroundMode(int WXUNUSED(mode
)) { }
240 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
241 static void SetResolution(int ppi
);
242 static int GetResolution();
245 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
246 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
247 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
248 void DoCrossHair(wxCoord x
, wxCoord y
);
249 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
250 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
251 void DoDrawPoint(wxCoord x
, wxCoord y
);
252 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
253 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
254 void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
255 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
256 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20.0);
257 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
259 void DoDrawSpline(wxList
*points
);
260 #endif // wxUSE_SPLINES
261 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
262 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= false,
263 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
264 void DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
);
265 void DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
= false );
266 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
267 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
268 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
269 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
270 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
271 wxCoord
*descent
= (wxCoord
*) NULL
,
272 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
273 const wxFont
*theFont
= (wxFont
*) NULL
) const;
274 void DoGetSize(int* width
, int* height
) const;
275 void DoGetSizeMM(int *width
, int *height
) const;
277 void SetPrintData(const wxPrintData
& data
);
278 wxPrintData
& GetPrintData() { return m_printData
; }
281 static float ms_PSScaleFactor
;
284 wxPrintData m_printData
;
285 PangoContext
*m_context
;
286 PangoLayout
*m_layout
;
287 PangoFontDescription
*m_fontdesc
;
289 unsigned char m_currentRed
;
290 unsigned char m_currentGreen
;
291 unsigned char m_currentBlue
;
295 GnomePrintContext
*m_gpc
;
296 GnomePrintJob
* m_job
;
298 void makeEllipticalPath(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
301 wxCoord
XDEV2LOG(wxCoord x
) const
303 return wxRound((double)(x
- m_deviceOriginX
) / m_scaleX
) * m_signX
+ m_logicalOriginX
;
305 wxCoord
XDEV2LOGREL(wxCoord x
) const
307 return wxRound((double)(x
) / m_scaleX
);
309 wxCoord
YDEV2LOG(wxCoord y
) const
311 return wxRound((double)(y
+ m_deviceOriginY
- m_deviceOffsetY
) / m_scaleY
) * m_signY
+ m_logicalOriginY
;
313 wxCoord
YDEV2LOGREL(wxCoord y
) const
315 return wxRound((double)(y
) / m_scaleY
);
317 wxCoord
XLOG2DEV(wxCoord x
) const
319 return wxRound((double)(x
- m_logicalOriginX
) * m_scaleX
) * m_signX
+ m_deviceOriginX
;
321 wxCoord
XLOG2DEVREL(wxCoord x
) const
323 return wxRound((double)(x
) * m_scaleX
);
325 wxCoord
YLOG2DEV(wxCoord y
) const
327 return wxRound((double)(y
- m_logicalOriginY
) * m_scaleY
) * m_signY
- m_deviceOriginY
+ m_deviceOffsetY
;
329 wxCoord
YLOG2DEVREL(wxCoord y
) const
331 return wxRound((double)(y
) * m_scaleY
);
334 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC
)
335 DECLARE_NO_COPY_CLASS(wxGnomePrintDC
)
338 // ----------------------------------------------------------------------------
339 // wxGnomePrintPreview: programmer creates an object of this class to preview a
341 // ----------------------------------------------------------------------------
343 class wxGnomePrintPreview
: public wxPrintPreviewBase
346 wxGnomePrintPreview(wxPrintout
*printout
,
347 wxPrintout
*printoutForPrinting
= (wxPrintout
*) NULL
,
348 wxPrintDialogData
*data
= (wxPrintDialogData
*) NULL
);
349 wxGnomePrintPreview(wxPrintout
*printout
,
350 wxPrintout
*printoutForPrinting
,
353 virtual ~wxGnomePrintPreview();
355 virtual bool Print(bool interactive
);
356 virtual void DetermineScaling();
359 void Init(wxPrintout
*printout
, wxPrintout
*printoutForPrinting
);
362 DECLARE_CLASS(wxGnomePrintPreview
)
367 // wxUSE_LIBGNOMEPRINT