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 wxDC
* CreatePrinterDC( const wxPrintData
& data
);
83 virtual bool HasPrintSetupDialog();
84 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
);
85 virtual bool HasOwnPrintToFile();
86 virtual bool HasPrinterLine();
87 virtual wxString
CreatePrinterLine();
88 virtual bool HasStatusLine();
89 virtual wxString
CreateStatusLine();
91 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
94 //----------------------------------------------------------------------------
96 //----------------------------------------------------------------------------
98 class wxGnomePrintDialog
: public wxPrintDialogBase
101 wxGnomePrintDialog( wxWindow
*parent
,
102 wxPrintDialogData
* data
= NULL
);
103 wxGnomePrintDialog( wxWindow
*parent
, wxPrintData
* data
);
104 virtual ~wxGnomePrintDialog();
106 wxPrintData
& GetPrintData()
107 { return m_printDialogData
.GetPrintData(); }
108 wxPrintDialogData
& GetPrintDialogData()
109 { return m_printDialogData
; }
113 virtual int ShowModal();
115 virtual bool Validate();
116 virtual bool TransferDataToWindow();
117 virtual bool TransferDataFromWindow();
120 // Implement some base class methods to do nothing to avoid asserts and
121 // GTK warnings, since this is not a real wxDialog.
122 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
123 int WXUNUSED(width
), int WXUNUSED(height
),
124 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
125 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
126 int WXUNUSED(width
), int WXUNUSED(height
)) {}
129 wxPrintDialogData m_printDialogData
;
132 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog
)
135 //----------------------------------------------------------------------------
136 // wxGnomePageSetupDialog
137 //----------------------------------------------------------------------------
139 class wxGnomePageSetupDialog
: public wxPageSetupDialogBase
142 wxGnomePageSetupDialog( wxWindow
*parent
,
143 wxPageSetupDialogData
* data
= NULL
);
144 virtual ~wxGnomePageSetupDialog();
146 virtual wxPageSetupDialogData
& GetPageSetupDialogData();
148 virtual int ShowModal();
150 virtual bool Validate();
151 virtual bool TransferDataToWindow();
152 virtual bool TransferDataFromWindow();
155 // Implement some base class methods to do nothing to avoid asserts and
156 // GTK warnings, since this is not a real wxDialog.
157 virtual void DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
158 int WXUNUSED(width
), int WXUNUSED(height
),
159 int WXUNUSED(sizeFlags
) = wxSIZE_AUTO
) {}
160 virtual void DoMoveWindow(int WXUNUSED(x
), int WXUNUSED(y
),
161 int WXUNUSED(width
), int WXUNUSED(height
)) {}
163 wxPageSetupDialogData m_pageDialogData
;
166 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog
)
169 //----------------------------------------------------------------------------
171 //----------------------------------------------------------------------------
173 class wxGnomePrinter
: public wxPrinterBase
176 wxGnomePrinter(wxPrintDialogData
*data
= NULL
);
177 virtual ~wxGnomePrinter();
179 virtual bool Print(wxWindow
*parent
,
180 wxPrintout
*printout
,
182 virtual wxDC
* PrintDialog(wxWindow
*parent
);
183 virtual bool Setup(wxWindow
*parent
);
185 GnomePrintContext
*GetPrintContext() { return m_gpc
; }
188 GnomePrintContext
*m_gpc
;
189 bool m_native_preview
;
192 DECLARE_DYNAMIC_CLASS(wxGnomePrinter
)
193 DECLARE_NO_COPY_CLASS(wxGnomePrinter
)
196 //-----------------------------------------------------------------------------
198 //-----------------------------------------------------------------------------
200 class wxGnomePrintDC
: public wxDC
203 wxGnomePrintDC( wxGnomePrinter
*printer
);
204 wxGnomePrintDC( const wxPrintData
& data
);
205 virtual ~wxGnomePrintDC();
207 bool Ok() const { return IsOk(); }
210 bool DoFloodFill(wxCoord x1
, wxCoord y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
);
211 bool DoGetPixel(wxCoord x1
, wxCoord y1
, wxColour
*col
) const;
212 void DoDrawLine(wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
);
213 void DoCrossHair(wxCoord x
, wxCoord y
);
214 void DoDrawArc(wxCoord x1
,wxCoord y1
,wxCoord x2
,wxCoord y2
,wxCoord xc
,wxCoord yc
);
215 void DoDrawEllipticArc(wxCoord x
,wxCoord y
,wxCoord w
,wxCoord h
,double sa
,double ea
);
216 void DoDrawPoint(wxCoord x
, wxCoord y
);
217 void DoDrawLines(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0);
218 void DoDrawPolygon(int n
, wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
219 void DoDrawPolyPolygon(int n
, int count
[], wxPoint points
[], wxCoord xoffset
= 0, wxCoord yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
220 void DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
221 void DoDrawRoundedRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, double radius
= 20.0);
222 void DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
224 void DoDrawSpline(wxList
*points
);
225 #endif // wxUSE_SPLINES
227 bool DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
228 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int rop
= wxCOPY
, bool useMask
= false,
229 wxCoord xsrcMask
= wxDefaultCoord
, wxCoord ysrcMask
= wxDefaultCoord
);
230 void DoDrawIcon( const wxIcon
& icon
, wxCoord x
, wxCoord y
);
231 void DoDrawBitmap( const wxBitmap
& bitmap
, wxCoord x
, wxCoord y
, bool useMask
= false );
232 bool CanDrawBitmap() const { return true; }
234 void DoDrawText(const wxString
& text
, wxCoord x
, wxCoord y
);
235 void DoDrawRotatedText(const wxString
& text
, wxCoord x
, wxCoord y
, double angle
);
237 void SetFont( const wxFont
& font
);
238 void SetPen( const wxPen
& pen
);
239 void SetBrush( const wxBrush
& brush
);
240 void SetLogicalFunction( int function
);
241 void SetBackground( const wxBrush
& brush
);
243 void DoSetClippingRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
244 void DestroyClippingRegion();
245 void DoSetClippingRegionAsRegion( const wxRegion
&WXUNUSED(clip
) ) { }
247 bool StartDoc(const wxString
& message
);
252 wxCoord
GetCharHeight() const;
253 wxCoord
GetCharWidth() const;
254 bool CanGetTextExtent() const { return true; }
255 void DoGetTextExtent(const wxString
& string
, wxCoord
*x
, wxCoord
*y
,
256 wxCoord
*descent
= (wxCoord
*) NULL
,
257 wxCoord
*externalLeading
= (wxCoord
*) NULL
,
258 wxFont
*theFont
= (wxFont
*) NULL
) const;
260 void DoGetSize(int* width
, int* height
) const;
261 void DoGetSizeMM(int *width
, int *height
) const;
262 wxSize
GetPPI() const;
263 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
265 void SetLogicalOrigin( wxCoord x
, wxCoord y
);
266 void SetDeviceOrigin( wxCoord x
, wxCoord y
);
268 virtual int GetDepth() const { return 24; }
270 void SetBackgroundMode(int WXUNUSED(mode
)) { }
271 void SetPalette(const wxPalette
& WXUNUSED(palette
)) { }
273 wxPrintData
& GetPrintData() { return m_printData
; }
274 void SetPrintData(const wxPrintData
& data
) { m_printData
= data
; }
276 static void SetResolution(int ppi
);
277 static int GetResolution();
280 static float ms_PSScaleFactor
;
283 wxPrintData m_printData
;
284 PangoContext
*m_context
;
285 PangoLayout
*m_layout
;
286 PangoFontDescription
*m_fontdesc
;
288 unsigned char m_currentRed
;
289 unsigned char m_currentGreen
;
290 unsigned char m_currentBlue
;
294 wxGnomePrinter
*m_printer
;
295 GnomePrintContext
*m_gpc
;
296 GnomePrintJob
* m_job
; // only used and destroyed when created with wxPrintData
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