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 #if defined(__WXGTK__) || defined(__WXMOTIF__)
48 // wxGTK has its own wxPostscriptDC
50 #include "wx/gtk/dcps.h"
54 class WXDLLEXPORT wxPostScriptDC
: public wxDC
56 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
59 // Create a printer DC
61 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
65 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
67 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) NULL
);
69 inline virtual void BeginDrawing(void) {} ;
70 inline virtual void EndDrawing(void) {} ;
72 void FloodFill(long x1
, long y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
) ;
73 bool GetPixel(long x1
, long y1
, wxColour
*col
) const;
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
);
94 void DrawSpline(wxList
*points
);
96 void DrawIcon( const wxIcon
& icon
, long x
, long y
);
97 void DrawBitmap( const wxBitmap
& bitmap
, long x
, long y
, bool useMask
=FALSE
);
98 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
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
);
107 void SetClippingRegion(long x
, long y
, long width
, long height
);
108 void SetClippingRegion( const wxRegion
®ion
);
109 void DestroyClippingRegion();
111 bool StartDoc(const wxString
& message
);
116 long GetCharHeight();
118 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
119 long *descent
= (long *) NULL
,
120 long *externalLeading
= (long *) NULL
,
121 wxFont
*theFont
= (wxFont
*) NULL
, bool use16
= FALSE
);
122 virtual void SetLogicalOrigin(long x
, long y
);
123 virtual void CalcBoundingBox(long x
, long y
);
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
; }
140 void GetSize(int* width
, int* height
) const;
141 void GetSizeMM(long *width
, long *height
) const;
143 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
144 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
146 inline ofstream
*GetStream(void) const { return m_pstream
; }
147 inline int GetYOrigin(void) const { return m_yOrigin
; }
152 int m_yOrigin
; // For EPS
153 ofstream
* m_pstream
; // PostScript output stream
155 unsigned char m_currentRed
;
156 unsigned char m_currentGreen
;
157 unsigned char m_currentBlue
;
158 double m_scaleFactor
;
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
173 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
175 DECLARE_CLASS(wxPostScriptPrintDialog
)
177 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
178 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
179 long style
= wxDEFAULT_DIALOG_STYLE
);
181 virtual int ShowModal(void) ;
185 // Print Orientation (Should also add Left, Right)
189 };// ps_orientation = PS_PORTRAIT;
196 };// ps_action = PS_PREVIEW;
198 // PostScript printer settings
199 WXDLLEXPORT
void wxSetPrinterCommand(const char *cmd
);
200 WXDLLEXPORT
void wxSetPrintPreviewCommand(const char *cmd
);
201 WXDLLEXPORT
void wxSetPrinterOptions(const char *flags
);
202 WXDLLEXPORT
void wxSetPrinterOrientation(int orientation
);
203 WXDLLEXPORT
void wxSetPrinterScaling(double x
, double y
);
204 WXDLLEXPORT
void wxSetPrinterTranslation(long x
, long y
);
205 WXDLLEXPORT
void wxSetPrinterMode(int mode
);
206 WXDLLEXPORT
void wxSetPrinterFile(const char *f
);
207 WXDLLEXPORT
void wxSetAFMPath(const char *f
);
209 // Get current values
210 WXDLLEXPORT
char* wxGetPrinterCommand();
211 WXDLLEXPORT
char* wxGetPrintPreviewCommand();
212 WXDLLEXPORT
char* wxGetPrinterOptions();
213 WXDLLEXPORT
int wxGetPrinterOrientation();
214 WXDLLEXPORT
void wxGetPrinterScaling(double* x
, double* y
);
215 WXDLLEXPORT
void wxGetPrinterTranslation(long *x
, long *y
);
216 WXDLLEXPORT
int wxGetPrinterMode();
217 WXDLLEXPORT
char* wxGetPrinterFile();
218 WXDLLEXPORT
char* wxGetAFMPath();
221 * PostScript print setup information
224 class WXDLLEXPORT wxPrintSetupData
: public wxObject
227 char *printerCommand
;
228 char *previewCommand
;
232 double printerScaleX
;
233 double printerScaleY
;
234 long printerTranslateX
;
235 long printerTranslateY
;
236 // 1 = Preview, 2 = print to file, 3 = send to printer
239 // A name in the paper database (see wx_print.h: the printing framework)
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
);
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();
273 void operator=(wxPrintSetupData
& data
);
276 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
279 WXDLLEXPORT_DATA(extern wxPrintSetupData
*) wxThePrintSetupData
;
280 WXDLLEXPORT
extern void wxInitializePrintSetupData(bool init
= TRUE
);
283 * Again, this only really needed for non-Windows platforms
284 * or if you want to test the PostScript printing under Windows.
287 class WXDLLEXPORT wxPrintPaperType
: public wxObject
290 wxPrintPaperType(const char *name
= (const char *) NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
301 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
304 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
307 wxPrintPaperDatabase();
308 ~wxPrintPaperDatabase();
310 void CreateDatabase();
311 void ClearDatabase();
313 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
314 wxPrintPaperType
*FindPaperType(const char *name
);
317 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
320 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;