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 /////////////////////////////////////////////////////////////////////////////
14 // Include wxWindows' headers
18 #if wxUSE_LIBGNOMEPRINT
21 #include "wx/printdlg.h"
24 typedef struct _GnomePrintJob GnomePrintJob
;
25 typedef struct _GnomePrintContext GnomePrintContext
;
26 typedef struct _GnomePrintConfig GnomePrintConfig
;
28 //----------------------------------------------------------------------------
29 // wxGnomePrintNativeData
30 //----------------------------------------------------------------------------
32 class wxGnomePrintNativeData
: public wxPrintNativeDataBase
35 wxGnomePrintNativeData();
36 virtual ~wxGnomePrintNativeData();
38 virtual bool TransferTo( wxPrintData
&data
);
39 virtual bool TransferFrom( const wxPrintData
&data
);
41 virtual bool Ok() const { return IsOk(); }
42 virtual bool IsOk() const { return true; }
44 GnomePrintConfig
* GetPrintConfig() { return m_config
; }
45 void SetPrintJob( GnomePrintJob
*job
) { m_job
= job
; }
46 GnomePrintJob
* GetPrintJob() { return m_job
; }
50 GnomePrintConfig
*m_config
;
54 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData
)
57 //----------------------------------------------------------------------------
58 // wxGnomePrintFactory
59 //----------------------------------------------------------------------------
61 class wxGnomePrintFactory
: public wxPrintFactory
64 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
*data
);
66 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
67 wxPrintout
*printout
= NULL
,
68 wxPrintDialogData
*data
= NULL
);
69 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
73 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
74 wxPrintDialogData
*data
= NULL
);
75 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
78 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
79 wxPageSetupDialogData
* data
= NULL
);
81 virtual bool HasPrintSetupDialog();
82 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
);
83 virtual bool HasOwnPrintToFile();
84 virtual bool HasPrinterLine();
85 virtual wxString
CreatePrinterLine();
86 virtual bool HasStatusLine();
87 virtual wxString
CreateStatusLine();
89 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
92 //----------------------------------------------------------------------------
94 //----------------------------------------------------------------------------
96 class wxGnomePrintDialog
: public wxPrintDialogBase
99 wxGnomePrintDialog( wxWindow
*parent
,
100 wxPrintDialogData
* data
= NULL
);
101 wxGnomePrintDialog( wxWindow
*parent
, wxPrintData
* data
);
102 virtual ~wxGnomePrintDialog();
104 wxPrintData
& GetPrintData()
105 { return m_printDialogData
.GetPrintData(); }
106 wxPrintDialogData
& GetPrintDialogData()
107 { return m_printDialogData
; }
111 virtual int ShowModal();
113 virtual bool Validate();
114 virtual bool TransferDataToWindow();
115 virtual bool TransferDataFromWindow();
118 // Implement some base class methods to do nothing to avoid asserts and
119 // GTK warnings, since this is not a real wxDialog.
120 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
121 int WXUNUSED(width
), int WXUNUSED(height
),
122 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
123 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
124 int WXUNUSED(width
), int WXUNUSED(height
)) {}
127 wxPrintDialogData m_printDialogData
;
130 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog
)
133 //----------------------------------------------------------------------------
134 // wxGnomePageSetupDialog
135 //----------------------------------------------------------------------------
137 class wxGnomePageSetupDialog
: public wxPageSetupDialogBase
140 wxGnomePageSetupDialog( wxWindow
*parent
,
141 wxPageSetupDialogData
* data
= NULL
);
142 virtual ~wxGnomePageSetupDialog();
144 virtual wxPageSetupDialogData
& GetPageSetupDialogData();
146 virtual int ShowModal();
148 virtual bool Validate();
149 virtual bool TransferDataToWindow();
150 virtual bool TransferDataFromWindow();
153 // Implement some base class methods to do nothing to avoid asserts and
154 // GTK warnings, since this is not a real wxDialog.
155 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
156 int WXUNUSED(width
), int WXUNUSED(height
),
157 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
158 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
159 int WXUNUSED(width
), int WXUNUSED(height
)) {}
161 wxPageSetupDialogData m_pageDialogData
;
164 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog
)
167 //----------------------------------------------------------------------------
169 //----------------------------------------------------------------------------
171 class wxGnomePrinter
: public wxPrinterBase
174 wxGnomePrinter(wxPrintDialogData
*data
= NULL
);
175 virtual ~wxGnomePrinter();
177 virtual bool Print(wxWindow
*parent
,
178 wxPrintout
*printout
,
180 virtual wxDC
* PrintDialog(wxWindow
*parent
);
181 virtual bool Setup(wxWindow
*parent
);
183 GnomePrintContext
*GetPrintContext() { return m_gpc
; }
186 GnomePrintContext
*m_gpc
;
187 bool m_native_preview
;
190 DECLARE_DYNAMIC_CLASS(wxGnomePrinter
)
191 DECLARE_NO_COPY_CLASS(wxGnomePrinter
)
194 //-----------------------------------------------------------------------------
196 //-----------------------------------------------------------------------------
198 class wxGnomePrintDC
: public wxDC
201 wxGnomePrintDC( wxGnomePrinter
*printer
);
202 virtual ~wxGnomePrintDC();
204 bool Ok() const { return IsOk(); }
207 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
208 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
209 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
210 void DoCrossHair(wxCoord x
, wxCoord y
);
211 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
212 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
213 void DoDrawPoint(wxCoord x
, wxCoord y
);
214 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
215 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
216 void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
217 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
218 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20.0);
219 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
221 void DoDrawSpline(wxList
*points
);
222 #endif // wxUSE_SPLINES
224 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
225 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= false,
226 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
227 void DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
);
228 void DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
= false );
229 bool CanDrawBitmap() const { return true; }
231 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
232 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
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
);
240 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
241 void DestroyClippingRegion();
242 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
244 bool StartDoc(const wxString
& message
);
249 wxCoord
GetCharHeight() const;
250 wxCoord
GetCharWidth() const;
251 bool CanGetTextExtent() const { return true; }
252 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
253 wxCoord
*descent
= (wxCoord
*) NULL
,
254 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
255 wxFont
*theFont
= (wxFont
*) NULL
) const;
257 void DoGetSize(int* width
, int* height
) const;
258 void DoGetSizeMM(int *width
, int *height
) const;
259 wxSize
GetPPI() const;
260 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
261 void SetDeviceOrigin( wxCoord x
, wxCoord y
);
263 virtual int GetDepth() const { return 24; }
265 void SetBackgroundMode(int WXUNUSED(mode
)) { }
266 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
268 wxPrintData
& GetPrintData() { return m_printData
; }
269 void SetPrintData(const wxPrintData
& data
) { m_printData
= data
; }
271 static void SetResolution(int ppi
);
272 static int GetResolution();
275 static float ms_PSScaleFactor
;
278 PangoContext
*m_context
;
279 PangoLayout
*m_layout
;
280 PangoFontDescription
*m_fontdesc
;
282 unsigned char m_currentRed
;
283 unsigned char m_currentGreen
;
284 unsigned char m_currentBlue
;
285 wxPrintData m_printData
;
287 wxGnomePrinter
*m_printer
;
288 GnomePrintContext
*m_gpc
;
290 void makeEllipticalPath(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
293 wxCoord
XDEV2LOG(wxCoord x
) const
295 wxCoord new_x
= x
- m_deviceOriginX
;
297 return (wxCoord
)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
299 return (wxCoord
)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
301 wxCoord
XDEV2LOGREL(wxCoord x
) const
304 return (wxCoord
)((double)(x
) / m_scaleX
+ 0.5);
306 return (wxCoord
)((double)(x
) / m_scaleX
- 0.5);
308 wxCoord
YDEV2LOG(wxCoord y
) const
310 wxCoord new_y
= y
- m_deviceOriginY
;
312 return (wxCoord
)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
314 return (wxCoord
)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
316 wxCoord
YDEV2LOGREL(wxCoord y
) const
319 return (wxCoord
)((double)(y
) / m_scaleY
+ 0.5);
321 return (wxCoord
)((double)(y
) / m_scaleY
- 0.5);
323 wxCoord
XLOG2DEV(wxCoord x
) const
325 wxCoord new_x
= x
- m_logicalOriginX
;
327 return (wxCoord
)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
329 return (wxCoord
)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
331 wxCoord
XLOG2DEVREL(wxCoord x
) const
334 return (wxCoord
)((double)(x
) * m_scaleX
+ 0.5);
336 return (wxCoord
)((double)(x
) * m_scaleX
- 0.5);
338 wxCoord
YLOG2DEV(wxCoord y
) const
340 wxCoord new_y
= y
- m_logicalOriginY
;
342 return (wxCoord
)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
344 return (wxCoord
)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
346 wxCoord
YLOG2DEVREL(wxCoord y
) const
349 return (wxCoord
)((double)(y
) * m_scaleY
+ 0.5);
351 return (wxCoord
)((double)(y
) * m_scaleY
- 0.5);
354 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC
)
355 DECLARE_NO_COPY_CLASS(wxGnomePrintDC
)
359 // wxUSE_LIBGNOMEPRINT