]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/gnome/gprint.h
don't set focus to a hidden notebook (patch 1299005)
[wxWidgets.git] / include / wx / gtk / gnome / gprint.h
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 __gprint_H__
12 #define __gprint_H__
13
14 // Include wxWindows' headers
15
16 #ifndef WX_PRECOMP
17 #include <wx/wx.h>
18 #endif
19
20 #if wxUSE_LIBGNOMEPRINT
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 void SetPrintJob( GnomePrintJob *job ) { m_job = job; }
47 GnomePrintJob* GetPrintJob() { return m_job; }
48
49
50 private:
51 GnomePrintConfig *m_config;
52 GnomePrintJob *m_job;
53
54 private:
55 DECLARE_DYNAMIC_CLASS(wxGnomePrintNativeData)
56 };
57
58 //----------------------------------------------------------------------------
59 // wxGnomePrintFactory
60 //----------------------------------------------------------------------------
61
62 class wxGnomePrintFactory: public wxPrintFactory
63 {
64 public:
65 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
66
67 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
68 wxPrintout *printout = NULL,
69 wxPrintDialogData *data = NULL );
70 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
71 wxPrintout *printout,
72 wxPrintData *data );
73
74 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
75 wxPrintDialogData *data = NULL );
76 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
77 wxPrintData *data );
78
79 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
80 wxPageSetupDialogData * data = NULL );
81
82 virtual bool HasPrintSetupDialog();
83 virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data );
84 virtual bool HasOwnPrintToFile();
85 virtual bool HasPrinterLine();
86 virtual wxString CreatePrinterLine();
87 virtual bool HasStatusLine();
88 virtual wxString CreateStatusLine();
89
90 virtual wxPrintNativeDataBase *CreatePrintNativeData();
91 };
92
93 //----------------------------------------------------------------------------
94 // wxGnomePrintDialog
95 //----------------------------------------------------------------------------
96
97 class wxGnomePrintDialog: public wxPrintDialogBase
98 {
99 public:
100 wxGnomePrintDialog( wxWindow *parent,
101 wxPrintDialogData* data = NULL );
102 wxGnomePrintDialog( wxWindow *parent, wxPrintData* data);
103 ~wxGnomePrintDialog();
104
105 wxPrintData& GetPrintData()
106 { return m_printDialogData.GetPrintData(); }
107 wxPrintDialogData& GetPrintDialogData()
108 { return m_printDialogData; }
109
110 wxDC *GetPrintDC();
111
112 virtual int ShowModal();
113
114 virtual bool Validate();
115 virtual bool TransferDataToWindow();
116 virtual bool TransferDataFromWindow();
117
118 private:
119 // Implement some base class methods to do nothing to avoid asserts and
120 // GTK warnings, since this is not a real wxDialog.
121 virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
122 int WXUNUSED(width), int WXUNUSED(height),
123 int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
124 virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
125 int WXUNUSED(width), int WXUNUSED(height)) {}
126
127 void Init();
128 wxPrintDialogData m_printDialogData;
129
130 private:
131 DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog)
132 };
133
134 //----------------------------------------------------------------------------
135 // wxGnomePageSetupDialog
136 //----------------------------------------------------------------------------
137
138 class wxGnomePageSetupDialog: public wxPageSetupDialogBase
139 {
140 public:
141 wxGnomePageSetupDialog( wxWindow *parent,
142 wxPageSetupDialogData* data = NULL );
143 ~wxGnomePageSetupDialog();
144
145 virtual wxPageSetupDialogData& GetPageSetupDialogData();
146
147 virtual int ShowModal();
148
149 virtual bool Validate();
150 virtual bool TransferDataToWindow();
151 virtual bool TransferDataFromWindow();
152
153 private:
154 // Implement some base class methods to do nothing to avoid asserts and
155 // GTK warnings, since this is not a real wxDialog.
156 virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
157 int WXUNUSED(width), int WXUNUSED(height),
158 int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
159 virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y),
160 int WXUNUSED(width), int WXUNUSED(height)) {}
161
162 wxPageSetupDialogData m_pageDialogData;
163
164 private:
165 DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog)
166 };
167
168 //----------------------------------------------------------------------------
169 // wxGnomePrinter
170 //----------------------------------------------------------------------------
171
172 class wxGnomePrinter: public wxPrinterBase
173 {
174 public:
175 wxGnomePrinter(wxPrintDialogData *data = NULL);
176 virtual ~wxGnomePrinter();
177
178 virtual bool Print(wxWindow *parent,
179 wxPrintout *printout,
180 bool prompt = true);
181 virtual wxDC* PrintDialog(wxWindow *parent);
182 virtual bool Setup(wxWindow *parent);
183
184 GnomePrintContext *GetPrintContext() { return m_gpc; }
185
186 private:
187 GnomePrintContext *m_gpc;
188 bool m_native_preview;
189
190 private:
191 DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
192 DECLARE_NO_COPY_CLASS(wxGnomePrinter)
193 };
194
195 //-----------------------------------------------------------------------------
196 // wxGnomePrintDC
197 //-----------------------------------------------------------------------------
198
199 class wxGnomePrintDC: public wxDC
200 {
201 public:
202 wxGnomePrintDC( wxGnomePrinter *printer );
203 ~wxGnomePrintDC();
204
205 bool Ok() const;
206
207 virtual void BeginDrawing() {}
208 virtual void EndDrawing() {}
209
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);
223 #if wxUSE_SPLINES
224 void DoDrawSpline(wxList *points);
225 #endif // wxUSE_SPLINES
226
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; }
233
234 void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
235 void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
236 void Clear();
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 );
242
243 void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
244 void DestroyClippingRegion();
245 void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
246
247 bool StartDoc(const wxString& message);
248 void EndDoc();
249 void StartPage();
250 void EndPage();
251
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;
259
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 );
264 void SetDeviceOrigin( wxCoord x, wxCoord y );
265
266 virtual int GetDepth() const { return 24; }
267
268 void SetBackgroundMode(int WXUNUSED(mode)) { }
269 void SetPalette(const wxPalette& WXUNUSED(palette)) { }
270
271 wxPrintData& GetPrintData() { return m_printData; }
272 void SetPrintData(const wxPrintData& data) { m_printData = data; }
273
274 static void SetResolution(int ppi);
275 static int GetResolution();
276
277 private:
278 static float ms_PSScaleFactor;
279
280 private:
281 PangoContext *m_context;
282 PangoLayout *m_layout;
283 PangoFontDescription *m_fontdesc;
284
285 unsigned char m_currentRed;
286 unsigned char m_currentGreen;
287 unsigned char m_currentBlue;
288 wxPrintData m_printData;
289
290 wxGnomePrinter *m_printer;
291 GnomePrintContext *m_gpc;
292
293 private:
294 wxCoord XDEV2LOG(wxCoord x) const
295 {
296 wxCoord new_x = x - m_deviceOriginX;
297 if (new_x > 0)
298 return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
299 else
300 return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
301 }
302 wxCoord XDEV2LOGREL(wxCoord x) const
303 {
304 if (x > 0)
305 return (wxCoord)((double)(x) / m_scaleX + 0.5);
306 else
307 return (wxCoord)((double)(x) / m_scaleX - 0.5);
308 }
309 wxCoord YDEV2LOG(wxCoord y) const
310 {
311 wxCoord new_y = y - m_deviceOriginY;
312 if (new_y > 0)
313 return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
314 else
315 return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
316 }
317 wxCoord YDEV2LOGREL(wxCoord y) const
318 {
319 if (y > 0)
320 return (wxCoord)((double)(y) / m_scaleY + 0.5);
321 else
322 return (wxCoord)((double)(y) / m_scaleY - 0.5);
323 }
324 wxCoord XLOG2DEV(wxCoord x) const
325 {
326 wxCoord new_x = x - m_logicalOriginX;
327 if (new_x > 0)
328 return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
329 else
330 return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
331 }
332 wxCoord XLOG2DEVREL(wxCoord x) const
333 {
334 if (x > 0)
335 return (wxCoord)((double)(x) * m_scaleX + 0.5);
336 else
337 return (wxCoord)((double)(x) * m_scaleX - 0.5);
338 }
339 wxCoord YLOG2DEV(wxCoord y) const
340 {
341 wxCoord new_y = y - m_logicalOriginY;
342 if (new_y > 0)
343 return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
344 else
345 return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
346 }
347 wxCoord YLOG2DEVREL(wxCoord y) const
348 {
349 if (y > 0)
350 return (wxCoord)((double)(y) * m_scaleY + 0.5);
351 else
352 return (wxCoord)((double)(y) * m_scaleY - 0.5);
353 }
354 private:
355 DECLARE_DYNAMIC_CLASS(wxGnomePrintDC)
356 DECLARE_NO_COPY_CLASS(wxGnomePrintDC)
357 };
358
359 #endif
360 // wxUSE_LIBGNOMEPRINT
361
362 #endif