1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_POSTSCRPH__
13 #define _WX_POSTSCRPH__
16 #pragma interface "postscrp.h"
20 #include "wx/dialog.h"
21 #include "wx/module.h"
25 // A module to allow initialization/cleanup of PostScript-related
26 // things without calling these functions from app.cpp.
28 class WXDLLEXPORT wxPostScriptModule
: public wxModule
30 DECLARE_DYNAMIC_CLASS(wxPostScriptModule
)
32 wxPostScriptModule() {}
46 class WXDLLEXPORT wxPostScriptDC
: public wxDC
48 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
51 // Create a printer DC
53 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
57 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
59 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) NULL
);
61 inline virtual void BeginDrawing(void) {} ;
62 inline virtual void EndDrawing(void) {} ;
64 void FloodFill(long x1
, long y1
, wxColour
*col
, int style
=wxFLOOD_SURFACE
) ;
65 bool GetPixel(long x1
, long y1
, wxColour
*col
) const;
67 void DrawLine(long x1
, long y1
, long x2
, long y2
);
68 void CrossHair(long x
, long y
) ;
69 void DrawArc(long x1
,long y1
,long x2
,long y2
,long xc
,long yc
);
70 void DrawEllipticArc(long x
,long y
,long w
,long h
,double sa
,double ea
);
71 void DrawPoint(long x
, long y
);
72 // Avoid compiler warning
73 void DrawPoint(wxPoint
& point
) { wxDC::DrawPoint(point
); }
74 void DrawLines(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0);
75 // Avoid compiler warning
76 void DrawLines(wxList
*lines
, long xoffset
= 0, long yoffset
= 0)
77 { wxDC::DrawLines(lines
, xoffset
, yoffset
); }
78 void DrawPolygon(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
79 // Avoid compiler warning
80 void DrawPolygon(wxList
*lines
, long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
)
81 { wxDC::DrawPolygon(lines
, xoffset
, yoffset
, fillStyle
); }
82 void DrawRectangle(long x
, long y
, long width
, long height
);
83 void DrawRoundedRectangle(long x
, long y
, long width
, long height
, double radius
= 20);
84 void DrawEllipse(long x
, long y
, long width
, long height
);
86 void DrawSpline(wxList
*points
);
88 void DrawIcon(const wxIcon
& icon
, long x
, long y
);
90 void DrawIcon(const wxIcon
& icon
, long x
, long y
, bool WXUNUSED(usemask
) )
91 { DrawIcon( icon
, x
, y
); }
93 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
96 void SetFont(const wxFont
& font
);
97 void SetPen(const wxPen
& pen
);
98 void SetBrush(const wxBrush
& brush
);
99 void SetLogicalFunction(int function
);
100 void SetBackground(const wxBrush
& brush
);
101 void SetClippingRegion(long x
, long y
, long width
, long height
);
102 void DestroyClippingRegion();
104 bool StartDoc(const wxString
& message
);
109 long GetCharHeight();
111 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
112 long *descent
= (long *) NULL
,
113 long *externalLeading
= (long *) NULL
,
114 wxFont
*theFont
= (wxFont
*) NULL
, bool use16
= FALSE
);
115 virtual void SetLogicalOrigin(long x
, long y
);
116 virtual void CalcBoundingBox(long x
, long y
);
118 void SetMapMode(int mode
);
119 void SetUserScale(double x
, double y
);
120 long DeviceToLogicalX(int x
) const;
121 long DeviceToLogicalY(int y
) const;
122 long DeviceToLogicalXRel(int x
) const;
123 long DeviceToLogicalYRel(int y
) const;
124 long LogicalToDeviceX(long x
) const;
125 long LogicalToDeviceY(long y
) const;
126 long LogicalToDeviceXRel(long x
) const;
127 long LogicalToDeviceYRel(long y
) const;
128 bool Blit(long xdest
, long ydest
, long width
, long height
,
129 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
130 inline bool CanGetTextExtent(void) const { return FALSE
; }
131 inline bool CanDrawBitmap(void) const { return FALSE
; }
133 void GetSize(int* width
, int* height
) const;
134 void GetSizeMM(long *width
, long *height
) const;
136 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
137 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
139 inline ofstream
*GetStream(void) const { return m_pstream
; }
140 inline int GetYOrigin(void) const { return m_yOrigin
; }
145 int m_yOrigin
; // For EPS
146 ofstream
* m_pstream
; // PostScript output stream
148 unsigned char m_currentRed
;
149 unsigned char m_currentGreen
;
150 unsigned char m_currentBlue
;
151 double m_scaleFactor
;
154 #define wxID_PRINTER_COMMAND 1
155 #define wxID_PRINTER_OPTIONS 2
156 #define wxID_PRINTER_ORIENTATION 3
157 #define wxID_PRINTER_MODES 4
158 #define wxID_PRINTER_X_SCALE 5
159 #define wxID_PRINTER_Y_SCALE 6
160 #define wxID_PRINTER_X_TRANS 7
161 #define wxID_PRINTER_Y_TRANS 8
163 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
165 DECLARE_CLASS(wxPostScriptPrintDialog
)
167 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
168 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
169 long style
= wxDEFAULT_DIALOG_STYLE
);
171 virtual int ShowModal(void) ;
175 // Print Orientation (Should also add Left, Right)
179 };// ps_orientation = PS_PORTRAIT;
186 };// ps_action = PS_PREVIEW;
188 // PostScript printer settings
189 WXDLLEXPORT
void wxSetPrinterCommand(const char *cmd
);
190 WXDLLEXPORT
void wxSetPrintPreviewCommand(const char *cmd
);
191 WXDLLEXPORT
void wxSetPrinterOptions(const char *flags
);
192 WXDLLEXPORT
void wxSetPrinterOrientation(int orientation
);
193 WXDLLEXPORT
void wxSetPrinterScaling(double x
, double y
);
194 WXDLLEXPORT
void wxSetPrinterTranslation(long x
, long y
);
195 WXDLLEXPORT
void wxSetPrinterMode(int mode
);
196 WXDLLEXPORT
void wxSetPrinterFile(const char *f
);
197 WXDLLEXPORT
void wxSetAFMPath(const char *f
);
199 // Get current values
200 WXDLLEXPORT
char* wxGetPrinterCommand();
201 WXDLLEXPORT
char* wxGetPrintPreviewCommand();
202 WXDLLEXPORT
char* wxGetPrinterOptions();
203 WXDLLEXPORT
int wxGetPrinterOrientation();
204 WXDLLEXPORT
void wxGetPrinterScaling(double* x
, double* y
);
205 WXDLLEXPORT
void wxGetPrinterTranslation(long *x
, long *y
);
206 WXDLLEXPORT
int wxGetPrinterMode();
207 WXDLLEXPORT
char* wxGetPrinterFile();
208 WXDLLEXPORT
char* wxGetAFMPath();
211 * PostScript print setup information
214 class WXDLLEXPORT wxPrintSetupData
: public wxObject
217 char *printerCommand
;
218 char *previewCommand
;
222 double printerScaleX
;
223 double printerScaleY
;
224 long printerTranslateX
;
225 long printerTranslateY
;
226 // 1 = Preview, 2 = print to file, 3 = send to printer
229 // A name in the paper database (see wx_print.h: the printing framework)
237 void SetPrinterCommand(const char *cmd
);
238 void SetPaperName(const char *paper
);
239 void SetPrintPreviewCommand(const char *cmd
);
240 void SetPrinterOptions(const char *flags
);
241 void SetPrinterFile(const char *f
);
242 void SetPrinterOrientation(int orient
);
243 void SetPrinterScaling(double x
, double y
);
244 void SetPrinterTranslation(long x
, long y
);
245 // 1 = Preview, 2 = print to file, 3 = send to printer
246 void SetPrinterMode(int mode
);
247 void SetAFMPath(const char *f
);
248 void SetColour(bool col
);
250 // Get current values
251 char *GetPrinterCommand();
252 char *GetPrintPreviewCommand();
253 char *GetPrinterOptions();
254 char *GetPrinterFile();
255 char *GetPaperName();
256 int GetPrinterOrientation();
257 void GetPrinterScaling(double* x
, double* y
);
258 void GetPrinterTranslation(long *x
, long *y
);
259 int GetPrinterMode();
263 void operator=(wxPrintSetupData
& data
);
266 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
269 WXDLLEXPORT_DATA(extern wxPrintSetupData
*) wxThePrintSetupData
;
270 WXDLLEXPORT
extern void wxInitializePrintSetupData(bool init
= TRUE
);
273 * Again, this only really needed for non-Windows platforms
274 * or if you want to test the PostScript printing under Windows.
277 class WXDLLEXPORT wxPrintPaperType
: public wxObject
280 wxPrintPaperType(const char *name
= (const char *) NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
291 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
294 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
297 wxPrintPaperDatabase();
298 ~wxPrintPaperDatabase();
300 void CreateDatabase();
301 void ClearDatabase();
303 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
304 wxPrintPaperType
*FindPaperType(const char *name
);
307 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
310 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;
312 #endif // wxUSE_POSTSCRIPT