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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 // Include wxWindows' headers
24 #if wxUSE_LIBGNOMEPRINT
27 #include "wx/prntbase.h"
28 #include "wx/printdlg.h"
30 typedef struct _GnomePrintJob GnomePrintJob
;
31 typedef struct _GnomePrintContext GnomePrintContext
;
32 typedef struct _GnomePrintConfig GnomePrintConfig
;
34 //----------------------------------------------------------------------------
35 // wxGnomePrintNativeData
36 //----------------------------------------------------------------------------
38 class wxGnomePrintNativeData
: public wxPrintNativeDataBase
41 wxGnomePrintNativeData();
42 virtual ~wxGnomePrintNativeData();
44 virtual bool TransferTo( wxPrintData
&data
);
45 virtual bool TransferFrom( const wxPrintData
&data
);
47 virtual bool Ok() const { return true; }
49 GnomePrintConfig
* GetPrintConfig() { return m_config
; }
50 void SetPrintJob( GnomePrintJob
*job
) { m_job
= job
; }
51 GnomePrintJob
* GetPrintJob() { return m_job
; }
55 GnomePrintConfig
*m_config
;
59 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData
)
62 //----------------------------------------------------------------------------
63 // wxGnomePrintFactory
64 //----------------------------------------------------------------------------
66 class wxGnomePrintFactory
: public wxPrintFactory
69 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
*data
);
71 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
72 wxPrintout
*printout
= NULL
,
73 wxPrintDialogData
*data
= NULL
);
74 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
78 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
79 wxPrintDialogData
*data
= NULL
);
80 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
83 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
84 wxPageSetupDialogData
* data
= NULL
);
86 virtual bool HasPrintSetupDialog();
87 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
);
88 virtual bool HasOwnPrintToFile();
89 virtual bool HasPrinterLine();
90 virtual wxString
CreatePrinterLine();
91 virtual bool HasStatusLine();
92 virtual wxString
CreateStatusLine();
94 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
97 //----------------------------------------------------------------------------
99 //----------------------------------------------------------------------------
101 class wxGnomePrintDialog
: public wxPrintDialogBase
104 wxGnomePrintDialog( wxWindow
*parent
,
105 wxPrintDialogData
* data
= NULL
);
106 wxGnomePrintDialog( wxWindow
*parent
, wxPrintData
* data
);
107 ~wxGnomePrintDialog();
109 wxPrintData
& GetPrintData()
110 { return m_printDialogData
.GetPrintData(); }
111 wxPrintDialogData
& GetPrintDialogData()
112 { return m_printDialogData
; }
116 virtual int ShowModal();
118 virtual bool Validate();
119 virtual bool TransferDataToWindow();
120 virtual bool TransferDataFromWindow();
123 // Implement some base class methods to do nothing to avoid asserts and
124 // GTK warnings, since this is not a real wxDialog.
125 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
126 int WXUNUSED(width
), int WXUNUSED(height
),
127 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
128 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
129 int WXUNUSED(width
), int WXUNUSED(height
)) {}
132 wxPrintDialogData m_printDialogData
;
135 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog
)
138 //----------------------------------------------------------------------------
139 // wxGnomePageSetupDialog
140 //----------------------------------------------------------------------------
142 class wxGnomePageSetupDialog
: public wxPageSetupDialogBase
145 wxGnomePageSetupDialog( wxWindow
*parent
,
146 wxPageSetupDialogData
* data
= NULL
);
147 ~wxGnomePageSetupDialog();
149 virtual wxPageSetupDialogData
& GetPageSetupDialogData();
151 virtual int ShowModal();
153 virtual bool Validate();
154 virtual bool TransferDataToWindow();
155 virtual bool TransferDataFromWindow();
158 // Implement some base class methods to do nothing to avoid asserts and
159 // GTK warnings, since this is not a real wxDialog.
160 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
161 int WXUNUSED(width
), int WXUNUSED(height
),
162 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
163 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
164 int WXUNUSED(width
), int WXUNUSED(height
)) {}
166 wxPageSetupDialogData m_pageDialogData
;
169 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog
)
172 //----------------------------------------------------------------------------
174 //----------------------------------------------------------------------------
176 class wxGnomePrinter
: public wxPrinterBase
179 wxGnomePrinter(wxPrintDialogData
*data
= NULL
);
180 virtual ~wxGnomePrinter();
182 virtual bool Print(wxWindow
*parent
,
183 wxPrintout
*printout
,
185 virtual wxDC
* PrintDialog(wxWindow
*parent
);
186 virtual bool Setup(wxWindow
*parent
);
188 GnomePrintContext
*GetPrintContext() { return m_gpc
; }
191 GnomePrintContext
*m_gpc
;
192 bool m_native_preview
;
195 DECLARE_DYNAMIC_CLASS(wxGnomePrinter
)
196 DECLARE_NO_COPY_CLASS(wxGnomePrinter
)
199 //-----------------------------------------------------------------------------
201 //-----------------------------------------------------------------------------
203 class wxGnomePrintDC
: public wxDC
206 wxGnomePrintDC( wxGnomePrinter
*printer
);
211 virtual void BeginDrawing() {}
212 virtual void EndDrawing() {}
214 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
215 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
216 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
217 void DoCrossHair(wxCoord x
, wxCoord y
);
218 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
219 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
220 void DoDrawPoint(wxCoord x
, wxCoord y
);
221 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
222 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
223 void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
224 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
225 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20.0);
226 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
228 void DoDrawSpline(wxList
*points
);
229 #endif // wxUSE_SPLINES
231 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
232 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= false,
233 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
234 void DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
);
235 void DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
= false );
236 bool CanDrawBitmap() const { return true; }
238 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
239 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
241 void SetFont( const wxFont
& font
);
242 void SetPen( const wxPen
& pen
);
243 void SetBrush( const wxBrush
& brush
);
244 void SetLogicalFunction( int function
);
245 void SetBackground( const wxBrush
& brush
);
247 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
248 void DestroyClippingRegion();
249 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
251 bool StartDoc(const wxString
& message
);
256 wxCoord
GetCharHeight() const;
257 wxCoord
GetCharWidth() const;
258 bool CanGetTextExtent() const { return true; }
259 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
260 wxCoord
*descent
= (wxCoord
*) NULL
,
261 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
262 wxFont
*theFont
= (wxFont
*) NULL
) const;
264 void DoGetSize(int* width
, int* height
) const;
265 void DoGetSizeMM(int *width
, int *height
) const;
266 wxSize
GetPPI() const;
267 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
268 void SetDeviceOrigin( wxCoord x
, wxCoord y
);
270 virtual int GetDepth() const { return 24; }
272 void SetBackgroundMode(int WXUNUSED(mode
)) { }
273 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
275 wxPrintData
& GetPrintData() { return m_printData
; }
276 void SetPrintData(const wxPrintData
& data
) { m_printData
= data
; }
278 static void SetResolution(int ppi
);
279 static int GetResolution();
282 static float ms_PSScaleFactor
;
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
;
292 wxPrintData m_printData
;
294 wxGnomePrinter
*m_printer
;
295 GnomePrintContext
*m_gpc
;
298 wxCoord
XDEV2LOG(wxCoord x
) const
300 wxCoord new_x
= x
- m_deviceOriginX
;
302 return (wxCoord
)((double)(new_x
) / m_scaleX
+ 0.5) * m_signX
+ m_logicalOriginX
;
304 return (wxCoord
)((double)(new_x
) / m_scaleX
- 0.5) * m_signX
+ m_logicalOriginX
;
306 wxCoord
XDEV2LOGREL(wxCoord x
) const
309 return (wxCoord
)((double)(x
) / m_scaleX
+ 0.5);
311 return (wxCoord
)((double)(x
) / m_scaleX
- 0.5);
313 wxCoord
YDEV2LOG(wxCoord y
) const
315 wxCoord new_y
= y
- m_deviceOriginY
;
317 return (wxCoord
)((double)(new_y
) / m_scaleY
+ 0.5) * m_signY
+ m_logicalOriginY
;
319 return (wxCoord
)((double)(new_y
) / m_scaleY
- 0.5) * m_signY
+ m_logicalOriginY
;
321 wxCoord
YDEV2LOGREL(wxCoord y
) const
324 return (wxCoord
)((double)(y
) / m_scaleY
+ 0.5);
326 return (wxCoord
)((double)(y
) / m_scaleY
- 0.5);
328 wxCoord
XLOG2DEV(wxCoord x
) const
330 wxCoord new_x
= x
- m_logicalOriginX
;
332 return (wxCoord
)((double)(new_x
) * m_scaleX
+ 0.5) * m_signX
+ m_deviceOriginX
;
334 return (wxCoord
)((double)(new_x
) * m_scaleX
- 0.5) * m_signX
+ m_deviceOriginX
;
336 wxCoord
XLOG2DEVREL(wxCoord x
) const
339 return (wxCoord
)((double)(x
) * m_scaleX
+ 0.5);
341 return (wxCoord
)((double)(x
) * m_scaleX
- 0.5);
343 wxCoord
YLOG2DEV(wxCoord y
) const
345 wxCoord new_y
= y
- m_logicalOriginY
;
347 return (wxCoord
)((double)(new_y
) * m_scaleY
+ 0.5) * m_signY
+ m_deviceOriginY
;
349 return (wxCoord
)((double)(new_y
) * m_scaleY
- 0.5) * m_signY
+ m_deviceOriginY
;
351 wxCoord
YLOG2DEVREL(wxCoord y
) const
354 return (wxCoord
)((double)(y
) * m_scaleY
+ 0.5);
356 return (wxCoord
)((double)(y
) * m_scaleY
- 0.5);
359 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC
)
360 DECLARE_NO_COPY_CLASS(wxGnomePrintDC
)
364 // wxUSE_LIBGNOMEPRINT