]> git.saurik.com Git - wxWidgets.git/blame - include/wx/postscrp.h
1. suppressed some messages from HasEntry()/HasKeys()
[wxWidgets.git] / include / wx / postscrp.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: postscrp.h
3// Purpose: wxPostScriptDC class
4// Author: Julian Smart and others
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
a6f6393c 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_POSTSCRPH__
13#define _WX_POSTSCRPH__
c801d85f
KB
14
15#ifdef __GNUG__
16#pragma interface "postscrp.h"
17#endif
18
19#include "wx/dc.h"
20#include "wx/dialog.h"
dfad0599 21#include "wx/module.h"
c801d85f 22
47d67540 23#if wxUSE_POSTSCRIPT
c801d85f 24
dfad0599
JS
25// A module to allow initialization/cleanup of PostScript-related
26// things without calling these functions from app.cpp.
27
28class WXDLLEXPORT wxPostScriptModule: public wxModule
29{
30DECLARE_DYNAMIC_CLASS(wxPostScriptModule)
31public:
32 wxPostScriptModule() {}
33 bool OnInit();
34 void OnExit();
35};
36
fbc535ff
JS
37#if wxUSE_IOSTREAMH
38# include <fstream.h>
39#else
40# include <fstream>
41# ifdef _MSC_VER
42 using namespace std;
43# endif
44#endif
45
f04371f0
RR
46#ifdef __WXGTK__
47
48// wxGTK has its own wxPostscriptDC
49
50#include "wx/gtk/dcps.h"
51
52#else
53
c801d85f
KB
54class WXDLLEXPORT wxPostScriptDC: public wxDC
55{
56 DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
57
58 public:
59 // Create a printer DC
a6f6393c 60 wxPostScriptDC();
c67daf87 61 wxPostScriptDC(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
c801d85f 62
a6f6393c 63 ~wxPostScriptDC();
c801d85f 64
c67daf87 65 bool Create(const wxString& output, bool interactive = TRUE, wxWindow *parent = (wxWindow *) NULL);
c801d85f 66
c67daf87 67 virtual bool PrinterDialog(wxWindow *parent = (wxWindow *) NULL);
c801d85f
KB
68
69 inline virtual void BeginDrawing(void) {} ;
70 inline virtual void EndDrawing(void) {} ;
71
463c1fa1 72 void FloodFill(long x1, long y1, const wxColour &col, int style=wxFLOOD_SURFACE) ;
c801d85f
KB
73 bool GetPixel(long x1, long y1, wxColour *col) const;
74
75 void DrawLine(long x1, long y1, long x2, long y2);
76 void CrossHair(long x, long y) ;
77 void DrawArc(long x1,long y1,long x2,long y2,long xc,long yc);
78 void DrawEllipticArc(long x,long y,long w,long h,double sa,double ea);
79 void DrawPoint(long x, long y);
80 // Avoid compiler warning
81 void DrawPoint(wxPoint& point) { wxDC::DrawPoint(point); }
82 void DrawLines(int n, wxPoint points[], long xoffset = 0, long yoffset = 0);
83 // Avoid compiler warning
84 void DrawLines(wxList *lines, long xoffset = 0, long yoffset = 0)
85 { wxDC::DrawLines(lines, xoffset, yoffset); }
86 void DrawPolygon(int n, wxPoint points[], long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE);
87 // Avoid compiler warning
88 void DrawPolygon(wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE)
89 { wxDC::DrawPolygon(lines, xoffset, yoffset, fillStyle); }
90 void DrawRectangle(long x, long y, long width, long height);
91 void DrawRoundedRectangle(long x, long y, long width, long height, double radius = 20);
92 void DrawEllipse(long x, long y, long width, long height);
93
c801d85f 94 void DrawSpline(wxList *points);
c801d85f 95
463c1fa1
RR
96 void DrawIcon( const wxIcon& icon, long x, long y );
97 void DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask=FALSE );
c801d85f
KB
98 void DrawText(const wxString& text, long x, long y, bool use16 = FALSE);
99
a6f6393c 100 void Clear();
c801d85f
KB
101 void SetFont(const wxFont& font);
102 void SetPen(const wxPen& pen);
103 void SetBrush(const wxBrush& brush);
104 void SetLogicalFunction(int function);
105 void SetBackground(const wxBrush& brush);
463c1fa1 106
c801d85f 107 void SetClippingRegion(long x, long y, long width, long height);
463c1fa1 108 void SetClippingRegion( const wxRegion &region );
a6f6393c 109 void DestroyClippingRegion();
c801d85f
KB
110
111 bool StartDoc(const wxString& message);
a6f6393c
VZ
112 void EndDoc();
113 void StartPage();
114 void EndPage();
c801d85f 115
a6f6393c
VZ
116 long GetCharHeight();
117 long GetCharWidth();
c801d85f 118 void GetTextExtent(const wxString& string, long *x, long *y,
a6f6393c
VZ
119 long *descent = (long *) NULL,
120 long *externalLeading = (long *) NULL,
c67daf87 121 wxFont *theFont = (wxFont *) NULL, bool use16 = FALSE);
c801d85f
KB
122 virtual void SetLogicalOrigin(long x, long y);
123 virtual void CalcBoundingBox(long x, long y);
124
125 void SetMapMode(int mode);
126 void SetUserScale(double x, double y);
127 long DeviceToLogicalX(int x) const;
128 long DeviceToLogicalY(int y) const;
129 long DeviceToLogicalXRel(int x) const;
130 long DeviceToLogicalYRel(int y) const;
131 long LogicalToDeviceX(long x) const;
132 long LogicalToDeviceY(long y) const;
133 long LogicalToDeviceXRel(long x) const;
134 long LogicalToDeviceYRel(long y) const;
135 bool Blit(long xdest, long ydest, long width, long height,
136 wxDC *source, long xsrc, long ysrc, int rop = wxCOPY, bool useMask = FALSE);
137 inline bool CanGetTextExtent(void) const { return FALSE; }
138 inline bool CanDrawBitmap(void) const { return FALSE; }
139
140 void GetSize(int* width, int* height) const;
141 void GetSizeMM(long *width, long *height) const;
142
143 inline void SetBackgroundMode(int WXUNUSED(mode)) {};
144 inline void SetPalette(const wxPalette& WXUNUSED(palette)) {}
145
146 inline ofstream *GetStream(void) const { return m_pstream; }
147 inline int GetYOrigin(void) const { return m_yOrigin; }
148
149 void SetupCTM();
150
151protected:
152 int m_yOrigin; // For EPS
153 ofstream * m_pstream; // PostScript output stream
154 wxString m_title;
155 unsigned char m_currentRed;
156 unsigned char m_currentGreen;
157 unsigned char m_currentBlue;
158 double m_scaleFactor;
159};
160
f04371f0
RR
161#endif
162 // __WXGTK__
163
c801d85f
KB
164#define wxID_PRINTER_COMMAND 1
165#define wxID_PRINTER_OPTIONS 2
166#define wxID_PRINTER_ORIENTATION 3
167#define wxID_PRINTER_MODES 4
168#define wxID_PRINTER_X_SCALE 5
169#define wxID_PRINTER_Y_SCALE 6
170#define wxID_PRINTER_X_TRANS 7
171#define wxID_PRINTER_Y_TRANS 8
172
173class WXDLLEXPORT wxPostScriptPrintDialog: public wxDialog
174{
175DECLARE_CLASS(wxPostScriptPrintDialog)
176public:
177 wxPostScriptPrintDialog (wxWindow *parent, const wxString& title,
a6f6393c
VZ
178 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
179 long style = wxDEFAULT_DIALOG_STYLE);
c801d85f
KB
180
181 virtual int ShowModal(void) ;
182};
183
184
185// Print Orientation (Should also add Left, Right)
186enum {
187 PS_PORTRAIT = 1,
188 PS_LANDSCAPE = 2
189};// ps_orientation = PS_PORTRAIT;
190
191// Print Actions
192enum {
193 PS_PRINTER,
194 PS_FILE,
195 PS_PREVIEW
196};// ps_action = PS_PREVIEW;
197
198// PostScript printer settings
184b5d99
JS
199WXDLLEXPORT void wxSetPrinterCommand(const char *cmd);
200WXDLLEXPORT void wxSetPrintPreviewCommand(const char *cmd);
201WXDLLEXPORT void wxSetPrinterOptions(const char *flags);
202WXDLLEXPORT void wxSetPrinterOrientation(int orientation);
203WXDLLEXPORT void wxSetPrinterScaling(double x, double y);
204WXDLLEXPORT void wxSetPrinterTranslation(long x, long y);
205WXDLLEXPORT void wxSetPrinterMode(int mode);
206WXDLLEXPORT void wxSetPrinterFile(const char *f);
207WXDLLEXPORT void wxSetAFMPath(const char *f);
c801d85f
KB
208
209// Get current values
a6f6393c
VZ
210WXDLLEXPORT char* wxGetPrinterCommand();
211WXDLLEXPORT char* wxGetPrintPreviewCommand();
212WXDLLEXPORT char* wxGetPrinterOptions();
213WXDLLEXPORT int wxGetPrinterOrientation();
184b5d99
JS
214WXDLLEXPORT void wxGetPrinterScaling(double* x, double* y);
215WXDLLEXPORT void wxGetPrinterTranslation(long *x, long *y);
a6f6393c
VZ
216WXDLLEXPORT int wxGetPrinterMode();
217WXDLLEXPORT char* wxGetPrinterFile();
218WXDLLEXPORT char* wxGetAFMPath();
c801d85f
KB
219
220/*
221 * PostScript print setup information
222 */
223
224class WXDLLEXPORT wxPrintSetupData: public wxObject
225{
a6f6393c
VZ
226public:
227 char *printerCommand;
228 char *previewCommand;
229 char *printerFlags;
230 char *printerFile;
231 int printerOrient;
232 double printerScaleX;
233 double printerScaleY;
234 long printerTranslateX;
235 long printerTranslateY;
236 // 1 = Preview, 2 = print to file, 3 = send to printer
237 int printerMode;
238 char *afmPath;
239 // A name in the paper database (see wx_print.h: the printing framework)
240 char *paperName;
241 bool printColour;
c801d85f 242
a6f6393c
VZ
243public:
244 wxPrintSetupData();
245 ~wxPrintSetupData();
246
247 void SetPrinterCommand(const char *cmd);
248 void SetPaperName(const char *paper);
249 void SetPrintPreviewCommand(const char *cmd);
250 void SetPrinterOptions(const char *flags);
251 void SetPrinterFile(const char *f);
252 void SetPrinterOrientation(int orient);
253 void SetPrinterScaling(double x, double y);
254 void SetPrinterTranslation(long x, long y);
255 // 1 = Preview, 2 = print to file, 3 = send to printer
256 void SetPrinterMode(int mode);
257 void SetAFMPath(const char *f);
258 void SetColour(bool col);
259
260 // Get current values
261 char *GetPrinterCommand();
262 char *GetPrintPreviewCommand();
263 char *GetPrinterOptions();
264 char *GetPrinterFile();
265 char *GetPaperName();
266 int GetPrinterOrientation();
267 void GetPrinterScaling(double* x, double* y);
268 void GetPrinterTranslation(long *x, long *y);
269 int GetPrinterMode();
270 char *GetAFMPath();
271 bool GetColour();
272
273 void operator=(wxPrintSetupData& data);
274
275private:
276 DECLARE_DYNAMIC_CLASS(wxPrintSetupData)
c801d85f
KB
277};
278
184b5d99
JS
279WXDLLEXPORT_DATA(extern wxPrintSetupData*) wxThePrintSetupData;
280WXDLLEXPORT extern void wxInitializePrintSetupData(bool init = TRUE);
c801d85f
KB
281
282/*
283 * Again, this only really needed for non-Windows platforms
284 * or if you want to test the PostScript printing under Windows.
285 */
286
287class WXDLLEXPORT wxPrintPaperType: public wxObject
288{
a6f6393c
VZ
289public:
290 wxPrintPaperType(const char *name = (const char *) NULL, int wmm = 0, int hmm = 0, int wp = 0, int hp = 0);
291 ~wxPrintPaperType();
c801d85f 292
a6f6393c
VZ
293public:
294 int widthMM;
295 int heightMM;
296 int widthPixels;
297 int heightPixels;
298 char *pageName;
299
300private:
301 DECLARE_DYNAMIC_CLASS(wxPrintPaperType)
c801d85f
KB
302};
303
304class WXDLLEXPORT wxPrintPaperDatabase: public wxList
305{
a6f6393c
VZ
306public:
307 wxPrintPaperDatabase();
308 ~wxPrintPaperDatabase();
c801d85f 309
a6f6393c
VZ
310 void CreateDatabase();
311 void ClearDatabase();
c801d85f 312
a6f6393c
VZ
313 void AddPaperType(const char *name, int wmm, int hmm, int wp, int hp);
314 wxPrintPaperType *FindPaperType(const char *name);
c801d85f 315
a6f6393c
VZ
316private:
317 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
c801d85f
KB
318};
319
320WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase;
321
ed880dd4
RR
322#endif
323 // wxUSE_POSTSCRIPT
324
c801d85f 325#endif
34138703 326 // _WX_POSTSCRPH__
ed880dd4 327
ed880dd4 328