1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPostScriptDC class
4 // Author: Julian Smart and others
7 // Copyright: (c) Julian Smart, Robert Roebling and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_POSTSCRPH__
12 #define _WX_POSTSCRPH__
19 #include "wx/dialog.h"
20 #include "wx/module.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 class wxPostScriptModule
;
31 class wxPostScriptPrintDialog
;
32 class wxPrintSetupData
;
33 class wxPrintPaperType
;
34 class wxPrintPaperDatabase
;
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 #define wxID_PRINTER_COMMAND 1
41 #define wxID_PRINTER_OPTIONS 2
42 #define wxID_PRINTER_ORIENTATION 3
43 #define wxID_PRINTER_MODES 4
44 #define wxID_PRINTER_X_SCALE 5
45 #define wxID_PRINTER_Y_SCALE 6
46 #define wxID_PRINTER_X_TRANS 7
47 #define wxID_PRINTER_Y_TRANS 8
49 // Print Orientation (Should also add Left, Right)
53 };// ps_orientation = PS_PORTRAIT;
60 };// ps_action = PS_PREVIEW;
62 //-----------------------------------------------------------------------------
64 //-----------------------------------------------------------------------------
66 WXDLLEXPORT_DATA(extern wxPrintSetupData
*) wxThePrintSetupData
;
67 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase
*) wxThePrintPaperDatabase
;
69 //-----------------------------------------------------------------------------
70 // functions for compatibility
71 //-----------------------------------------------------------------------------
73 // PostScript printer settings
74 WXDLLEXPORT
void wxSetPrinterCommand(const char *cmd
);
75 WXDLLEXPORT
void wxSetPrintPreviewCommand(const char *cmd
);
76 WXDLLEXPORT
void wxSetPrinterOptions(const char *flags
);
77 WXDLLEXPORT
void wxSetPrinterOrientation(int orientation
);
78 WXDLLEXPORT
void wxSetPrinterScaling(double x
, double y
);
79 WXDLLEXPORT
void wxSetPrinterTranslation(long x
, long y
);
80 WXDLLEXPORT
void wxSetPrinterMode(int mode
);
81 WXDLLEXPORT
void wxSetPrinterFile(const char *f
);
82 WXDLLEXPORT
void wxSetAFMPath(const char *f
);
85 WXDLLEXPORT
char* wxGetPrinterCommand();
86 WXDLLEXPORT
char* wxGetPrintPreviewCommand();
87 WXDLLEXPORT
char* wxGetPrinterOptions();
88 WXDLLEXPORT
int wxGetPrinterOrientation();
89 WXDLLEXPORT
void wxGetPrinterScaling(double* x
, double* y
);
90 WXDLLEXPORT
void wxGetPrinterTranslation(long *x
, long *y
);
91 WXDLLEXPORT
int wxGetPrinterMode();
92 WXDLLEXPORT
char* wxGetPrinterFile();
93 WXDLLEXPORT
char* wxGetAFMPath();
95 WXDLLEXPORT
extern void wxInitializePrintSetupData(bool init
= TRUE
);
97 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
101 // A module to allow initialization/cleanup of PostScript-related
102 // things without calling these functions from app.cpp.
104 class WXDLLEXPORT wxPostScriptModule
: public wxModule
106 DECLARE_DYNAMIC_CLASS(wxPostScriptModule
)
108 wxPostScriptModule() {}
113 //-----------------------------------------------------------------------------
115 //-----------------------------------------------------------------------------
117 class WXDLLEXPORT wxPostScriptDC
: public wxDC
119 DECLARE_DYNAMIC_CLASS(wxPostScriptDC
)
124 wxPostScriptDC(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
128 bool Create(const wxString
& output
, bool interactive
= TRUE
, wxWindow
*parent
= (wxWindow
*) NULL
);
130 virtual bool PrinterDialog(wxWindow
*parent
= (wxWindow
*) NULL
);
132 inline virtual void BeginDrawing(void) {} ;
133 inline virtual void EndDrawing(void) {} ;
135 void FloodFill(long x1
, long y1
, const wxColour
&col
, int style
=wxFLOOD_SURFACE
) ;
136 bool GetPixel(long x1
, long y1
, wxColour
*col
) const;
138 void DrawLine(long x1
, long y1
, long x2
, long y2
);
139 void CrossHair(long x
, long y
) ;
140 void DrawArc(long x1
,long y1
,long x2
,long y2
,long xc
,long yc
);
141 void DrawEllipticArc(long x
,long y
,long w
,long h
,double sa
,double ea
);
142 void DrawPoint(long x
, long y
);
143 // Avoid compiler warning
144 void DrawPoint(wxPoint
& point
) { wxDC::DrawPoint(point
); }
145 void DrawLines(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0);
146 // Avoid compiler warning
147 void DrawLines(wxList
*lines
, long xoffset
= 0, long yoffset
= 0)
148 { wxDC::DrawLines(lines
, xoffset
, yoffset
); }
149 void DrawPolygon(int n
, wxPoint points
[], long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
);
150 // Avoid compiler warning
151 void DrawPolygon(wxList
*lines
, long xoffset
= 0, long yoffset
= 0, int fillStyle
=wxODDEVEN_RULE
)
152 { wxDC::DrawPolygon(lines
, xoffset
, yoffset
, fillStyle
); }
153 void DrawRectangle(long x
, long y
, long width
, long height
);
154 void DrawRoundedRectangle(long x
, long y
, long width
, long height
, double radius
= 20);
155 void DrawEllipse(long x
, long y
, long width
, long height
);
157 void DrawSpline(wxList
*points
);
159 bool Blit(long xdest
, long ydest
, long width
, long height
,
160 wxDC
*source
, long xsrc
, long ysrc
, int rop
= wxCOPY
, bool useMask
= FALSE
);
161 inline bool CanDrawBitmap(void) const { return TRUE
; }
163 void DrawIcon( const wxIcon
& icon
, long x
, long y
);
164 void DrawBitmap( const wxBitmap
& bitmap
, long x
, long y
, bool useMask
=FALSE
);
167 void DrawText(const wxString
& text
, long x
, long y
, bool use16
= FALSE
);
170 void SetFont( const wxFont
& font
);
171 void SetPen( const wxPen
& pen
);
172 void SetBrush( const wxBrush
& brush
);
173 void SetLogicalFunction( int function
);
174 void SetBackground( const wxBrush
& brush
);
176 void SetClippingRegion(long x
, long y
, long width
, long height
);
177 void SetClippingRegion( const wxRegion
®ion
);
178 void DestroyClippingRegion();
180 bool StartDoc(const wxString
& message
);
185 long GetCharHeight();
187 inline bool CanGetTextExtent(void) const { return FALSE
; }
188 void GetTextExtent(const wxString
& string
, long *x
, long *y
,
189 long *descent
= (long *) NULL
,
190 long *externalLeading
= (long *) NULL
,
191 wxFont
*theFont
= (wxFont
*) NULL
, bool use16
= FALSE
);
193 void GetSize(int* width
, int* height
) const;
194 void GetSizeMM(long *width
, long *height
) const;
196 void SetAxisOrientation( bool xLeftRight
, bool yBottomUp
);
197 void SetDeviceOrigin( long x
, long y
);
199 inline void SetBackgroundMode(int WXUNUSED(mode
)) {};
200 inline void SetPalette(const wxPalette
& WXUNUSED(palette
)) {}
202 inline ofstream
*GetStream(void) const { return m_pstream
; }
206 ofstream
* m_pstream
; // PostScript output stream
208 unsigned char m_currentRed
;
209 unsigned char m_currentGreen
;
210 unsigned char m_currentBlue
;
213 double m_underlinePosition
;
214 double m_underlineThickness
;
217 //-----------------------------------------------------------------------------
218 // wxPostScriptPrintDialog
219 //-----------------------------------------------------------------------------
221 class WXDLLEXPORT wxPostScriptPrintDialog
: public wxDialog
223 DECLARE_CLASS(wxPostScriptPrintDialog
)
225 wxPostScriptPrintDialog (wxWindow
*parent
, const wxString
& title
,
226 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
227 long style
= wxDEFAULT_DIALOG_STYLE
);
229 virtual int ShowModal(void) ;
232 //-----------------------------------------------------------------------------
234 //-----------------------------------------------------------------------------
237 * PostScript print setup information
240 class WXDLLEXPORT wxPrintSetupData
: public wxObject
243 char *printerCommand
;
244 char *previewCommand
;
248 double printerScaleX
;
249 double printerScaleY
;
250 long printerTranslateX
;
251 long printerTranslateY
;
252 // 1 = Preview, 2 = print to file, 3 = send to printer
255 // A name in the paper database (see wx_print.h: the printing framework)
263 void SetPrinterCommand(const char *cmd
);
264 void SetPaperName(const char *paper
);
265 void SetPrintPreviewCommand(const char *cmd
);
266 void SetPrinterOptions(const char *flags
);
267 void SetPrinterFile(const char *f
);
268 void SetPrinterOrientation(int orient
);
269 void SetPrinterScaling(double x
, double y
);
270 void SetPrinterTranslation(long x
, long y
);
271 // 1 = Preview, 2 = print to file, 3 = send to printer
272 void SetPrinterMode(int mode
);
273 void SetAFMPath(const char *f
);
274 void SetColour(bool col
);
276 // Get current values
277 char *GetPrinterCommand();
278 char *GetPrintPreviewCommand();
279 char *GetPrinterOptions();
280 char *GetPrinterFile();
281 char *GetPaperName();
282 int GetPrinterOrientation();
283 void GetPrinterScaling(double* x
, double* y
);
284 void GetPrinterTranslation(long *x
, long *y
);
285 int GetPrinterMode();
289 void operator=(wxPrintSetupData
& data
);
292 DECLARE_DYNAMIC_CLASS(wxPrintSetupData
)
295 //-----------------------------------------------------------------------------
297 //-----------------------------------------------------------------------------
300 * Again, this only really needed for non-Windows platforms
301 * or if you want to test the PostScript printing under Windows.
304 class WXDLLEXPORT wxPrintPaperType
: public wxObject
307 wxPrintPaperType(const char *name
= (const char *) NULL
, int wmm
= 0, int hmm
= 0, int wp
= 0, int hp
= 0);
318 DECLARE_DYNAMIC_CLASS(wxPrintPaperType
)
321 //-----------------------------------------------------------------------------
322 // wxPrintPaperDataBase
323 //-----------------------------------------------------------------------------
325 class WXDLLEXPORT wxPrintPaperDatabase
: public wxList
328 wxPrintPaperDatabase();
329 ~wxPrintPaperDatabase();
331 void CreateDatabase();
332 void ClearDatabase();
334 void AddPaperType(const char *name
, int wmm
, int hmm
, int wp
, int hp
);
335 wxPrintPaperType
*FindPaperType(const char *name
);
338 DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase
)