]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/gnome/gprint.h
solution to wxMBConv stuff - make a seperate XX2XX for strings of a specified length...
[wxWidgets.git] / include / wx / gtk / gnome / gprint.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gprint.h
3 // Author: Robert Roebling
4 // Purpose: GNOME printing support
5 // Created: 09/20/04
6 // Copyright: Robert Roebling
7 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef __gprint_H__
10 #define __gprint_H__
11
12 #if defined(__GNUG__) && !defined(__APPLE__)
13 #pragma interface "gprint.h"
14 #endif
15
16 // Include wxWindows' headers
17
18 #ifndef WX_PRECOMP
19 #include <wx/wx.h>
20 #endif
21
22 #include "wx/print.h"
23 #include "wx/prntbase.h"
24 #include "wx/printdlg.h"
25
26 typedef struct _GnomePrintJob GnomePrintJob;
27 typedef struct _GnomePrintContext GnomePrintContext;
28 typedef struct _GnomePrintConfig GnomePrintConfig;
29
30 //----------------------------------------------------------------------------
31 // wxGnomePrintNativeData
32 //----------------------------------------------------------------------------
33
34 class wxGnomePrintNativeData: public wxPrintNativeDataBase
35 {
36 public:
37 wxGnomePrintNativeData();
38 virtual ~wxGnomePrintNativeData();
39
40 virtual bool TransferTo( wxPrintData &data );
41 virtual bool TransferFrom( const wxPrintData &data );
42
43 virtual bool Ok() const { return true; }
44
45 GnomePrintConfig* GetPrintConfig() { return m_config; }
46 GnomePrintJob* GetPrintJob() { return m_job; }
47
48
49 private:
50 GnomePrintConfig *m_config;
51 GnomePrintJob *m_job;
52
53 private:
54 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData)
55 };
56
57 //----------------------------------------------------------------------------
58 // wxGnomePrintFactory
59 //----------------------------------------------------------------------------
60
61 class wxGnomePrintFactory: public wxPrintFactory
62 {
63 public:
64 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
65
66 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
67 wxPrintout *printout = NULL,
68 wxPrintDialogData *data = NULL );
69 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
70 wxPrintout *printout,
71 wxPrintData *data );
72
73 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
74 wxPrintDialogData *data = NULL );
75 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
76 wxPrintData *data );
77
78 virtual bool HasPrintSetupDialog();
79 virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data );
80 virtual bool HasOwnPrintToFile();
81 virtual bool HasPrinterLine();
82 virtual wxString CreatePrinterLine();
83 virtual bool HasStatusLine();
84 virtual wxString CreateStatusLine();
85
86 virtual wxPrintNativeDataBase *CreatePrintNativeData();
87 };
88
89 //----------------------------------------------------------------------------
90 // wxGnomePrintSetupDialog
91 //----------------------------------------------------------------------------
92
93 class wxGnomePrintSetupDialog: public wxDialog
94 {
95 public:
96 wxGnomePrintSetupDialog( wxWindow *parent, wxPrintData *data );
97 ~wxGnomePrintSetupDialog();
98
99 virtual int ShowModal();
100
101 virtual bool Validate();
102 virtual bool TransferDataToWindow();
103 virtual bool TransferDataFromWindow();
104
105 private:
106 // Implement some base class methods to do nothing to avoid asserts and
107 // GTK warnings, since this is not a real wxDialog.
108 virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
109 int WXUNUSED(width), int WXUNUSED(height),
110 int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
111 virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
112 int WXUNUSED(width), int WXUNUSED(height)) {}
113 private:
114 DECLARE_DYNAMIC_CLASS(wxGnomePrintSetupDialog)
115 };
116
117 //----------------------------------------------------------------------------
118 // wxGnomePrinter
119 //----------------------------------------------------------------------------
120
121 class wxGnomePrinter: public wxPrinterBase
122 {
123 public:
124 wxGnomePrinter(wxPrintDialogData *data = NULL);
125 virtual ~wxGnomePrinter();
126
127 virtual bool Print(wxWindow *parent,
128 wxPrintout *printout,
129 bool prompt = true);
130 virtual wxDC* PrintDialog(wxWindow *parent);
131 virtual bool Setup(wxWindow *parent);
132
133 GnomePrintContext *GetPrintContext() { return m_gpc; }
134
135 private:
136 GnomePrintContext *m_gpc;
137
138 private:
139 DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
140 DECLARE_NO_COPY_CLASS(wxGnomePrinter)
141 };
142
143 //-----------------------------------------------------------------------------
144 // wxGnomePrintDC
145 //-----------------------------------------------------------------------------
146
147 class wxGnomePrintDC: public wxDC
148 {
149 public:
150 wxGnomePrintDC( wxGnomePrinter *printer );
151 ~wxGnomePrintDC();
152
153 bool Ok() const;
154
155 virtual void BeginDrawing() {}
156 virtual void EndDrawing() {}
157
158 bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE );
159 bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const;
160 void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
161 void DoCrossHair(wxCoord x, wxCoord y);
162 void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc);
163 void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea);
164 void DoDrawPoint(wxCoord x, wxCoord y);
165 void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0);
166 void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
167 void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle=wxODDEVEN_RULE);
168 void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
169 void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0);
170 void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
171 void DoDrawSpline(wxList *points);
172
173 bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
174 wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false,
175 wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
176 void DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y );
177 void DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask = false );
178 bool CanDrawBitmap() const { return true; }
179
180 void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
181 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
182 void Clear();
183 void SetFont( const wxFont& font );
184 void SetPen( const wxPen& pen );
185 void SetBrush( const wxBrush& brush );
186 void SetLogicalFunction( int function );
187 void SetBackground( const wxBrush& brush );
188
189 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
190 void DestroyClippingRegion();
191 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
192
193 bool StartDoc(const wxString& message);
194 void EndDoc();
195 void StartPage();
196 void EndPage();
197
198 wxCoord GetCharHeight() const;
199 wxCoord GetCharWidth() const;
200 bool CanGetTextExtent() const { return true; }
201 void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
202 wxCoord *descent = (wxCoord *) NULL,
203 wxCoord *externalLeading = (wxCoord *) NULL,
204 wxFont *theFont = (wxFont *) NULL ) const;
205
206 void DoGetSize(int* width, int* height) const;
207 void DoGetSizeMM(int *width, int *height) const;
208 wxSize GetPPI() const;
209 void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
210 void SetDeviceOrigin( wxCoord x, wxCoord y );
211
212 virtual int GetDepth() const { return 24; }
213
214 void SetBackgroundMode(int WXUNUSED(mode)) { }
215 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
216
217 wxPrintData& GetPrintData() { return m_printData; }
218 void SetPrintData(const wxPrintData& data) { m_printData = data; }
219
220 static void SetResolution(int ppi);
221 static int GetResolution();
222
223 private:
224 static float ms_PSScaleFactor;
225
226 private:
227 PangoContext *m_context;
228 PangoLayout *m_layout;
229 PangoFontDescription *m_fontdesc;
230
231 unsigned char m_currentRed;
232 unsigned char m_currentGreen;
233 unsigned char m_currentBlue;
234 wxPrintData m_printData;
235
236 wxGnomePrinter *m_printer;
237 GnomePrintContext *m_gpc;
238
239 private:
240 wxCoord XDEV2LOG(wxCoord x) const
241 {
242 wxCoord new_x = x - m_deviceOriginX;
243 if (new_x > 0)
244 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
245 else
246 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
247 }
248 wxCoord XDEV2LOGREL(wxCoord x) const
249 {
250 if (x > 0)
251 return (wxCoord)((double)(x) / m_scaleX + 0.5);
252 else
253 return (wxCoord)((double)(x) / m_scaleX - 0.5);
254 }
255 wxCoord YDEV2LOG(wxCoord y) const
256 {
257 wxCoord new_y = y - m_deviceOriginY;
258 if (new_y > 0)
259 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
260 else
261 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
262 }
263 wxCoord YDEV2LOGREL(wxCoord y) const
264 {
265 if (y > 0)
266 return (wxCoord)((double)(y) / m_scaleY + 0.5);
267 else
268 return (wxCoord)((double)(y) / m_scaleY - 0.5);
269 }
270 wxCoord XLOG2DEV(wxCoord x) const
271 {
272 wxCoord new_x = x - m_logicalOriginX;
273 if (new_x > 0)
274 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
275 else
276 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
277 }
278 wxCoord XLOG2DEVREL(wxCoord x) const
279 {
280 if (x > 0)
281 return (wxCoord)((double)(x) * m_scaleX + 0.5);
282 else
283 return (wxCoord)((double)(x) * m_scaleX - 0.5);
284 }
285 wxCoord YLOG2DEV(wxCoord y) const
286 {
287 wxCoord new_y = y - m_logicalOriginY;
288 if (new_y > 0)
289 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
290 else
291 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
292 }
293 wxCoord YLOG2DEVREL(wxCoord y) const
294 {
295 if (y > 0)
296 return (wxCoord)((double)(y) * m_scaleY + 0.5);
297 else
298 return (wxCoord)((double)(y) * m_scaleY - 0.5);
299 }
300 private:
301 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC)
302 DECLARE_NO_COPY_CLASS(wxGnomePrintDC)
303 };
304
305 #endif