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 true; }
43 GnomePrintConfig
* GetPrintConfig() { return m_config
; }
44 void SetPrintJob( GnomePrintJob
*job
) { m_job
= job
; }
45 GnomePrintJob
* GetPrintJob() { return m_job
; }
49 GnomePrintConfig
*m_config
;
53 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData
)
56 //----------------------------------------------------------------------------
57 // wxGnomePrintFactory
58 //----------------------------------------------------------------------------
60 class wxGnomePrintFactory
: public wxPrintFactory
63 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
*data
);
65 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
66 wxPrintout
*printout
= NULL
,
67 wxPrintDialogData
*data
= NULL
);
68 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
72 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
73 wxPrintDialogData
*data
= NULL
);
74 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
77 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
78 wxPageSetupDialogData
* data
= NULL
);
80 virtual bool HasPrintSetupDialog();
81 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
);
82 virtual bool HasOwnPrintToFile();
83 virtual bool HasPrinterLine();
84 virtual wxString
CreatePrinterLine();
85 virtual bool HasStatusLine();
86 virtual wxString
CreateStatusLine();
88 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
91 //----------------------------------------------------------------------------
93 //----------------------------------------------------------------------------
95 class wxGnomePrintDialog
: public wxPrintDialogBase
98 wxGnomePrintDialog( wxWindow
*parent
,
99 wxPrintDialogData
* data
= NULL
);
100 wxGnomePrintDialog( wxWindow
*parent
, wxPrintData
* data
);
101 ~wxGnomePrintDialog();
103 wxPrintData
& GetPrintData()
104 { return m_printDialogData
.GetPrintData(); }
105 wxPrintDialogData
& GetPrintDialogData()
106 { return m_printDialogData
; }
110 virtual int ShowModal();
112 virtual bool Validate();
113 virtual bool TransferDataToWindow();
114 virtual bool TransferDataFromWindow();
117 // Implement some base class methods to do nothing to avoid asserts and
118 // GTK warnings, since this is not a real wxDialog.
119 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
120 int WXUNUSED(width
), int WXUNUSED(height
),
121 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
122 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
123 int WXUNUSED(width
), int WXUNUSED(height
)) {}
126 wxPrintDialogData m_printDialogData
;
129 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog
)
132 //----------------------------------------------------------------------------
133 // wxGnomePageSetupDialog
134 //----------------------------------------------------------------------------
136 class wxGnomePageSetupDialog
: public wxPageSetupDialogBase
139 wxGnomePageSetupDialog( wxWindow
*parent
,
140 wxPageSetupDialogData
* data
= NULL
);
141 ~wxGnomePageSetupDialog();
143 virtual wxPageSetupDialogData
& GetPageSetupDialogData();
145 virtual int ShowModal();
147 virtual bool Validate();
148 virtual bool TransferDataToWindow();
149 virtual bool TransferDataFromWindow();
152 // Implement some base class methods to do nothing to avoid asserts and
153 // GTK warnings, since this is not a real wxDialog.
154 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
155 int WXUNUSED(width
), int WXUNUSED(height
),
156 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
157 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
158 int WXUNUSED(width
), int WXUNUSED(height
)) {}
160 wxPageSetupDialogData m_pageDialogData
;
163 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog
)
166 //----------------------------------------------------------------------------
168 //----------------------------------------------------------------------------
170 class wxGnomePrinter
: public wxPrinterBase
173 wxGnomePrinter(wxPrintDialogData
*data
= NULL
);
174 virtual ~wxGnomePrinter();
176 virtual bool Print(wxWindow
*parent
,
177 wxPrintout
*printout
,
179 virtual wxDC
* PrintDialog(wxWindow
*parent
);
180 virtual bool Setup(wxWindow
*parent
);
182 GnomePrintContext
*GetPrintContext() { return m_gpc
; }
185 GnomePrintContext
*m_gpc
;
186 bool m_native_preview
;
189 DECLARE_DYNAMIC_CLASS(wxGnomePrinter
)
190 DECLARE_NO_COPY_CLASS(wxGnomePrinter
)
193 //-----------------------------------------------------------------------------
195 //-----------------------------------------------------------------------------
197 class wxGnomePrintDC
: public wxDC
200 wxGnomePrintDC( wxGnomePrinter
*printer
);
205 virtual void BeginDrawing() {}
206 virtual void EndDrawing() {}
208 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
209 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
210 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
211 void DoCrossHair(wxCoord x
, wxCoord y
);
212 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
213 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
214 void DoDrawPoint(wxCoord x
, wxCoord y
);
215 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
216 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
217 void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
218 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
219 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20.0);
220 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
222 void DoDrawSpline(wxList
*points
);
223 #endif // wxUSE_SPLINES
225 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
226 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= false,
227 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
228 void DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
);
229 void DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
= false );
230 bool CanDrawBitmap() const { return true; }
232 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
233 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
235 void SetFont( const wxFont
& font
);
236 void SetPen( const wxPen
& pen
);
237 void SetBrush( const wxBrush
& brush
);
238 void SetLogicalFunction( int function
);
239 void SetBackground( const wxBrush
& brush
);
241 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
242 void DestroyClippingRegion();
243 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
245 bool StartDoc(const wxString
& message
);
250 wxCoord
GetCharHeight() const;
251 wxCoord
GetCharWidth() const;
252 bool CanGetTextExtent() const { return true; }
253 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
254 wxCoord
*descent
= (wxCoord
*) NULL
,
255 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
256 wxFont
*theFont
= (wxFont
*) NULL
) const;
258 void DoGetSize(int* width
, int* height
) const;
259 void DoGetSizeMM(int *width
, int *height
) const;
260 wxSize
GetPPI() const;
261 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
262 void SetDeviceOrigin( wxCoord x
, wxCoord y
);
264 virtual int GetDepth() const { return 24; }
266 void SetBackgroundMode(int WXUNUSED(mode
)) { }
267 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
269 wxPrintData
& GetPrintData() { return m_printData
; }
270 void SetPrintData(const wxPrintData
& data
) { m_printData
= data
; }
272 static void SetResolution(int ppi
);
273 static int GetResolution();
276 static float ms_PSScaleFactor
;
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
;
286 wxPrintData m_printData
;
288 wxGnomePrinter
*m_printer
;
289 GnomePrintContext
*m_gpc
;
292 wxCoord
XDEV2LOG(wxCoord x
) const
294 wxCoord new_x
= x
- m_deviceOriginX
;
296 return (wxCoord
)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
298 return (wxCoord
)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
300 wxCoord
XDEV2LOGREL(wxCoord x
) const
303 return (wxCoord
)((double)(x
) / m_scaleX
+ 0.5);
305 return (wxCoord
)((double)(x
) / m_scaleX
- 0.5);
307 wxCoord
YDEV2LOG(wxCoord y
) const
309 wxCoord new_y
= y
- m_deviceOriginY
;
311 return (wxCoord
)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
313 return (wxCoord
)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
315 wxCoord
YDEV2LOGREL(wxCoord y
) const
318 return (wxCoord
)((double)(y
) / m_scaleY
+ 0.5);
320 return (wxCoord
)((double)(y
) / m_scaleY
- 0.5);
322 wxCoord
XLOG2DEV(wxCoord x
) const
324 wxCoord new_x
= x
- m_logicalOriginX
;
326 return (wxCoord
)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
328 return (wxCoord
)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
330 wxCoord
XLOG2DEVREL(wxCoord x
) const
333 return (wxCoord
)((double)(x
) * m_scaleX
+ 0.5);
335 return (wxCoord
)((double)(x
) * m_scaleX
- 0.5);
337 wxCoord
YLOG2DEV(wxCoord y
) const
339 wxCoord new_y
= y
- m_logicalOriginY
;
341 return (wxCoord
)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
343 return (wxCoord
)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
345 wxCoord
YLOG2DEVREL(wxCoord y
) const
348 return (wxCoord
)((double)(y
) * m_scaleY
+ 0.5);
350 return (wxCoord
)((double)(y
) * m_scaleY
- 0.5);
353 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC
)
354 DECLARE_NO_COPY_CLASS(wxGnomePrintDC
)
358 // wxUSE_LIBGNOMEPRINT