]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/gnome/gprint.h
remove warnings of intentionally unreachable code
[wxWidgets.git] / include / wx / gtk / gnome / gprint.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/gnome/gprint.h
3// Author: Robert Roebling
4// Purpose: GNOME printing support
5// Created: 09/20/04
6// RCS-ID: $Id$
7// Copyright: Robert Roebling
8// Licence: wxWindows Licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_GTK_GPRINT_H_
12#define _WX_GTK_GPRINT_H_
13
14#include "wx/defs.h"
15
16#if wxUSE_LIBGNOMEPRINT
17
18#include "wx/print.h"
19#include "wx/printdlg.h"
20#include "wx/dc.h"
21
22typedef struct _GnomePrintJob GnomePrintJob;
23typedef struct _GnomePrintContext GnomePrintContext;
24typedef struct _GnomePrintConfig GnomePrintConfig;
25
26//----------------------------------------------------------------------------
27// wxGnomePrintNativeData
28//----------------------------------------------------------------------------
29
30class wxGnomePrintNativeData: public wxPrintNativeDataBase
31{
32public:
33 wxGnomePrintNativeData();
34 virtual ~wxGnomePrintNativeData();
35
36 virtual bool TransferTo( wxPrintData &data );
37 virtual bool TransferFrom( const wxPrintData &data );
38
39 virtual bool Ok() const { return IsOk(); }
40 virtual bool IsOk() const { return true; }
41
42 GnomePrintConfig* GetPrintConfig() { return m_config; }
43 void SetPrintJob( GnomePrintJob *job ) { m_job = job; }
44 GnomePrintJob* GetPrintJob() { return m_job; }
45
46
47private:
48 GnomePrintConfig *m_config;
49 GnomePrintJob *m_job;
50
51 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData)
52};
53
54//----------------------------------------------------------------------------
55// wxGnomePrintFactory
56//----------------------------------------------------------------------------
57
58class wxGnomePrintFactory: public wxPrintFactory
59{
60public:
61 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
62
63 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
64 wxPrintout *printout = NULL,
65 wxPrintDialogData *data = NULL );
66 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
67 wxPrintout *printout,
68 wxPrintData *data );
69
70 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
71 wxPrintDialogData *data = NULL );
72 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
73 wxPrintData *data );
74
75 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
76 wxPageSetupDialogData * data = NULL );
77
78 virtual wxDC* CreatePrinterDC( const wxPrintData& data );
79
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();
87
88 virtual wxPrintNativeDataBase *CreatePrintNativeData();
89};
90
91//----------------------------------------------------------------------------
92// wxGnomePrintDialog
93//----------------------------------------------------------------------------
94
95class wxGnomePrintDialog: public wxPrintDialogBase
96{
97public:
98 wxGnomePrintDialog( wxWindow *parent,
99 wxPrintDialogData* data = NULL );
100 wxGnomePrintDialog( wxWindow *parent, wxPrintData* data);
101 virtual ~wxGnomePrintDialog();
102
103 wxPrintData& GetPrintData()
104 { return m_printDialogData.GetPrintData(); }
105 wxPrintDialogData& GetPrintDialogData()
106 { return m_printDialogData; }
107
108 wxDC *GetPrintDC();
109
110 virtual int ShowModal();
111
112 virtual bool Validate();
113 virtual bool TransferDataToWindow();
114 virtual bool TransferDataFromWindow();
115
116protected:
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)) {}
124
125private:
126 void Init();
127 wxPrintDialogData m_printDialogData;
128
129 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog)
130};
131
132//----------------------------------------------------------------------------
133// wxGnomePageSetupDialog
134//----------------------------------------------------------------------------
135
136class wxGnomePageSetupDialog: public wxPageSetupDialogBase
137{
138public:
139 wxGnomePageSetupDialog( wxWindow *parent,
140 wxPageSetupDialogData* data = NULL );
141 virtual ~wxGnomePageSetupDialog();
142
143 virtual wxPageSetupDialogData& GetPageSetupDialogData();
144
145 virtual int ShowModal();
146
147 virtual bool Validate();
148 virtual bool TransferDataToWindow();
149 virtual bool TransferDataFromWindow();
150
151protected:
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)) {}
159
160private:
161 wxPageSetupDialogData m_pageDialogData;
162
163 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog)
164};
165
166//----------------------------------------------------------------------------
167// wxGnomePrinter
168//----------------------------------------------------------------------------
169
170class wxGnomePrinter: public wxPrinterBase
171{
172public:
173 wxGnomePrinter(wxPrintDialogData *data = NULL);
174 virtual ~wxGnomePrinter();
175
176 virtual bool Print(wxWindow *parent,
177 wxPrintout *printout,
178 bool prompt = true);
179 virtual wxDC* PrintDialog(wxWindow *parent);
180 virtual bool Setup(wxWindow *parent);
181
182 GnomePrintContext *GetPrintContext() { return m_gpc; }
183
184private:
185 GnomePrintContext *m_gpc;
186 bool m_native_preview;
187
188private:
189 DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
190 DECLARE_NO_COPY_CLASS(wxGnomePrinter)
191};
192
193//-----------------------------------------------------------------------------
194// wxGnomePrintDC
195//-----------------------------------------------------------------------------
196
197class wxGnomePrintDC: public wxDC
198{
199public:
200 wxGnomePrintDC( wxGnomePrinter *printer );
201 wxGnomePrintDC( const wxPrintData& data );
202 virtual ~wxGnomePrintDC();
203
204 bool Ok() const { return IsOk(); }
205 bool IsOk() const;
206
207 bool CanDrawBitmap() const { return true; }
208 void Clear();
209 void SetFont( const wxFont& font );
210 void SetPen( const wxPen& pen );
211 void SetBrush( const wxBrush& brush );
212 void SetLogicalFunction( int function );
213 void SetBackground( const wxBrush& brush );
214 void DestroyClippingRegion();
215 bool StartDoc(const wxString& message);
216 void EndDoc();
217 void StartPage();
218 void EndPage();
219 wxCoord GetCharHeight() const;
220 wxCoord GetCharWidth() const;
221 bool CanGetTextExtent() const { return true; }
222 wxSize GetPPI() const;
223 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
224 void SetLogicalOrigin( wxCoord x, wxCoord y );
225 void SetDeviceOrigin( wxCoord x, wxCoord y );
226 virtual int GetDepth() const { return 24; }
227 void SetBackgroundMode(int WXUNUSED(mode)) { }
228 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
229 static void SetResolution(int ppi);
230 static int GetResolution();
231
232protected:
233 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE );
234 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
235 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
236 void DoCrossHair(wxCoord x, wxCoord y);
237 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
238 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
239 void DoDrawPoint(wxCoord x, wxCoord y);
240 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
241 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
242 void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
243 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
244 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0);
245 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
246#if wxUSE_SPLINES
247 void DoDrawSpline(wxList *points);
248#endif // wxUSE_SPLINES
249 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
250 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false,
251 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
252 void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y );
253 void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false );
254 void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
255 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
256 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
257 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
258 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
259 wxCoord *descent = (wxCoord *) NULL,
260 wxCoord *externalLeading = (wxCoord *) NULL,
261 const wxFont *theFont = (wxFont *) NULL ) const;
262 void DoGetSize(int* width, int* height) const;
263 void DoGetSizeMM(int *width, int *height) const;
264
265 wxPrintData& GetPrintData() { return m_printData; }
266 void SetPrintData(const wxPrintData& data) { m_printData = data; }
267
268private:
269 static float ms_PSScaleFactor;
270
271private:
272 wxPrintData m_printData;
273 PangoContext *m_context;
274 PangoLayout *m_layout;
275 PangoFontDescription *m_fontdesc;
276
277 unsigned char m_currentRed;
278 unsigned char m_currentGreen;
279 unsigned char m_currentBlue;
280
281 int m_deviceOffsetY;
282
283 wxGnomePrinter *m_printer;
284 GnomePrintContext *m_gpc;
285 GnomePrintJob* m_job; // only used and destroyed when created with wxPrintData
286
287 void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
288
289private:
290 wxCoord XDEV2LOG(wxCoord x) const
291 {
292 return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
293 }
294 wxCoord XDEV2LOGREL(wxCoord x) const
295 {
296 return wxRound((double)(x) / m_scaleX);
297 }
298 wxCoord YDEV2LOG(wxCoord y) const
299 {
300 return wxRound((double)(y + m_deviceOriginY - m_deviceOffsetY) / m_scaleY) * m_signY + m_logicalOriginY;
301 }
302 wxCoord YDEV2LOGREL(wxCoord y) const
303 {
304 return wxRound((double)(y) / m_scaleY);
305 }
306 wxCoord XLOG2DEV(wxCoord x) const
307 {
308 return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
309 }
310 wxCoord XLOG2DEVREL(wxCoord x) const
311 {
312 return wxRound((double)(x) * m_scaleX);
313 }
314 wxCoord YLOG2DEV(wxCoord y) const
315 {
316 return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY - m_deviceOriginY + m_deviceOffsetY;
317 }
318 wxCoord YLOG2DEVREL(wxCoord y) const
319 {
320 return wxRound((double)(y) * m_scaleY);
321 }
322private:
323 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC)
324 DECLARE_NO_COPY_CLASS(wxGnomePrintDC)
325};
326
327// ----------------------------------------------------------------------------
328// wxGnomePrintPreview: programmer creates an object of this class to preview a
329// wxPrintout.
330// ----------------------------------------------------------------------------
331
332class wxGnomePrintPreview : public wxPrintPreviewBase
333{
334public:
335 wxGnomePrintPreview(wxPrintout *printout,
336 wxPrintout *printoutForPrinting = (wxPrintout *) NULL,
337 wxPrintDialogData *data = (wxPrintDialogData *) NULL);
338 wxGnomePrintPreview(wxPrintout *printout,
339 wxPrintout *printoutForPrinting,
340 wxPrintData *data);
341
342 virtual ~wxGnomePrintPreview();
343
344 virtual bool Print(bool interactive);
345 virtual void DetermineScaling();
346
347private:
348 void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
349
350private:
351 DECLARE_CLASS(wxGnomePrintPreview)
352};
353
354
355#endif
356 // wxUSE_LIBGNOMEPRINT
357
358#endif