1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/gtk/dcps.h"
18 #ifndef _WX_POSTSCRPH__
19 #define _WX_POSTSCRPH__
22 #pragma interface "postscrp.h"
26 #include "wx/dialog.h"
27 #include "wx/module.h"
31 // A module to allow initialization/cleanup of PostScript-related
32 // things without calling these functions from app.cpp.
34 class WXDLLEXPORT wxPostScriptModule
: public wxModule
36 DECLARE_DYNAMIC_CLASS(wxPostScriptModule
)
38 wxPostScriptModule() {}
52 class WXDLLEXPORT wxPostScriptDC
: public wxDC
54 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
57 // Create a printer DC
59 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
63 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
65 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) NULL
);
67 inline virtual void BeginDrawing(void) {} ;
68 inline virtual void EndDrawing(void) {} ;
70 void FloodFill(long x1
, long y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
) ;
71 bool GetPixel(long x1
, long y1
, wxColour
*col
) const;
73 void DrawLine(long x1
, long y1
, long x2
, long y2
);
74 void CrossHair(long x
, long y
) ;
75 void DrawArc(long x1
,long y1
,long x2
,long y2
,long xc
,long yc
);
76 void DrawEllipticArc(long x
,long y
,long w
,long h
,double sa
,double ea
);
77 void DrawPoint(long x
, long y
);
78 // Avoid compiler warning
79 void DrawPoint(wxPoint
& point
) { wxDC::DrawPoint(point
); }
80 void DrawLines(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0);
81 // Avoid compiler warning
82 void DrawLines(wxList
*lines
, long xoffset
= 0, long yoffset
= 0)
83 { wxDC::DrawLines(lines
, xoffset
, yoffset
); }
84 void DrawPolygon(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
85 // Avoid compiler warning
86 void DrawPolygon(wxList
*lines
, long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
)
87 { wxDC::DrawPolygon(lines
, xoffset
, yoffset
, fillStyle
); }
88 void DrawRectangle(long x
, long y
, long width
, long height
);
89 void DrawRoundedRectangle(long x
, long y
, long width
, long height
, double radius
= 20);
90 void DrawEllipse(long x
, long y
, long width
, long height
);
92 void DrawSpline(wxList
*points
);
94 void DrawIcon( const wxIcon
& icon
, long x
, long y
);
95 void DrawBitmap( const wxBitmap
& bitmap
, long x
, long y
, bool useMask
=FALSE
);
96 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
99 void SetFont(const wxFont
& font
);
100 void SetPen(const wxPen
& pen
);
101 void SetBrush(const wxBrush
& brush
);
102 void SetLogicalFunction(int function
);
103 void SetBackground(const wxBrush
& brush
);
105 void SetClippingRegion(long x
, long y
, long width
, long height
);
106 void SetClippingRegion( const wxRegion
®ion
);
107 void DestroyClippingRegion();
109 bool StartDoc(const wxString
& message
);
114 long GetCharHeight();
116 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
117 long *descent
= (long *) NULL
,
118 long *externalLeading
= (long *) NULL
,
119 wxFont
*theFont
= (wxFont
*) NULL
, bool use16
= FALSE
);
120 virtual void SetLogicalOrigin(long x
, long y
);
121 virtual void CalcBoundingBox(long x
, long y
);
123 void SetMapMode(int mode
);
124 void SetUserScale(double x
, double y
);
125 long DeviceToLogicalX(int x
) const;
126 long DeviceToLogicalY(int y
) const;
127 long DeviceToLogicalXRel(int x
) const;
128 long DeviceToLogicalYRel(int y
) const;
129 long LogicalToDeviceX(long x
) const;
130 long LogicalToDeviceY(long y
) const;
131 long LogicalToDeviceXRel(long x
) const;
132 long LogicalToDeviceYRel(long y
) const;
133 bool Blit(long xdest
, long ydest
, long width
, long height
,
134 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
135 inline bool CanGetTextExtent(void) const { return FALSE
; }
136 inline bool CanDrawBitmap(void) const { return FALSE
; }
138 void GetSize(int* width
, int* height
) const;
139 void GetSizeMM(long *width
, long *height
) const;
141 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
142 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
144 inline ofstream
*GetStream(void) const { return m_pstream
; }
145 inline int GetYOrigin(void) const { return m_yOrigin
; }
150 int m_yOrigin
; // For EPS
151 ofstream
* m_pstream
; // PostScript output stream
153 unsigned char m_currentRed
;
154 unsigned char m_currentGreen
;
155 unsigned char m_currentBlue
;
156 double m_scaleFactor
;
159 #define wxID_PRINTER_COMMAND 1
160 #define wxID_PRINTER_OPTIONS 2
161 #define wxID_PRINTER_ORIENTATION 3
162 #define wxID_PRINTER_MODES 4
163 #define wxID_PRINTER_X_SCALE 5
164 #define wxID_PRINTER_Y_SCALE 6
165 #define wxID_PRINTER_X_TRANS 7
166 #define wxID_PRINTER_Y_TRANS 8
168 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
170 DECLARE_CLASS(wxPostScriptPrintDialog
)
172 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
173 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
174 long style
= wxDEFAULT_DIALOG_STYLE
);
176 virtual int ShowModal(void) ;
180 // Print Orientation (Should also add Left, Right)
184 };// ps_orientation = PS_PORTRAIT;
191 };// ps_action = PS_PREVIEW;
193 // PostScript printer settings
194 WXDLLEXPORT
void wxSetPrinterCommand(const char *cmd
);
195 WXDLLEXPORT
void wxSetPrintPreviewCommand(const char *cmd
);
196 WXDLLEXPORT
void wxSetPrinterOptions(const char *flags
);
197 WXDLLEXPORT
void wxSetPrinterOrientation(int orientation
);
198 WXDLLEXPORT
void wxSetPrinterScaling(double x
, double y
);
199 WXDLLEXPORT
void wxSetPrinterTranslation(long x
, long y
);
200 WXDLLEXPORT
void wxSetPrinterMode(int mode
);
201 WXDLLEXPORT
void wxSetPrinterFile(const char *f
);
202 WXDLLEXPORT
void wxSetAFMPath(const char *f
);
204 // Get current values
205 WXDLLEXPORT
char* wxGetPrinterCommand();
206 WXDLLEXPORT
char* wxGetPrintPreviewCommand();
207 WXDLLEXPORT
char* wxGetPrinterOptions();
208 WXDLLEXPORT
int wxGetPrinterOrientation();
209 WXDLLEXPORT
void wxGetPrinterScaling(double* x
, double* y
);
210 WXDLLEXPORT
void wxGetPrinterTranslation(long *x
, long *y
);
211 WXDLLEXPORT
int wxGetPrinterMode();
212 WXDLLEXPORT
char* wxGetPrinterFile();
213 WXDLLEXPORT
char* wxGetAFMPath();
216 * PostScript print setup information
219 class WXDLLEXPORT wxPrintSetupData
: public wxObject
222 char *printerCommand
;
223 char *previewCommand
;
227 double printerScaleX
;
228 double printerScaleY
;
229 long printerTranslateX
;
230 long printerTranslateY
;
231 // 1 = Preview, 2 = print to file, 3 = send to printer
234 // A name in the paper database (see wx_print.h: the printing framework)
242 void SetPrinterCommand(const char *cmd
);
243 void SetPaperName(const char *paper
);
244 void SetPrintPreviewCommand(const char *cmd
);
245 void SetPrinterOptions(const char *flags
);
246 void SetPrinterFile(const char *f
);
247 void SetPrinterOrientation(int orient
);
248 void SetPrinterScaling(double x
, double y
);
249 void SetPrinterTranslation(long x
, long y
);
250 // 1 = Preview, 2 = print to file, 3 = send to printer
251 void SetPrinterMode(int mode
);
252 void SetAFMPath(const char *f
);
253 void SetColour(bool col
);
255 // Get current values
256 char *GetPrinterCommand();
257 char *GetPrintPreviewCommand();
258 char *GetPrinterOptions();
259 char *GetPrinterFile();
260 char *GetPaperName();
261 int GetPrinterOrientation();
262 void GetPrinterScaling(double* x
, double* y
);
263 void GetPrinterTranslation(long *x
, long *y
);
264 int GetPrinterMode();
268 void operator=(wxPrintSetupData
& data
);
271 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
274 WXDLLEXPORT_DATA(extern wxPrintSetupData
*) wxThePrintSetupData
;
275 WXDLLEXPORT
extern void wxInitializePrintSetupData(bool init
= TRUE
);
278 * Again, this only really needed for non-Windows platforms
279 * or if you want to test the PostScript printing under Windows.
282 class WXDLLEXPORT wxPrintPaperType
: public wxObject
285 wxPrintPaperType(const char *name
= (const char *) NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
296 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
299 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
302 wxPrintPaperDatabase();
303 ~wxPrintPaperDatabase();
305 void CreateDatabase();
306 void ClearDatabase();
308 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
309 wxPrintPaperType
*FindPaperType(const char *name
);
312 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)
315 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;