]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/cmndata.h
Move wxMulDivInt32 to common math.
[wxWidgets.git] / include / wx / cmndata.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: cmndata.h
3// Purpose: Common GDI data classes
4// Author: Julian Smart and others
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CMNDATA_H_BASE_
13#define _WX_CMNDATA_H_BASE_
14
15#include "wx/window.h"
16#include "wx/font.h"
17#include "wx/encinfo.h"
18#include "wx/colour.h"
19#include "wx/gdicmn.h"
20
21#if wxUSE_STREAMS
22#include "wx/stream.h"
23#endif
24
25
26class WXDLLEXPORT wxPrintNativeDataBase;
27
28
29class WXDLLEXPORT wxColourData: public wxObject
30{
31public:
32 wxColourData();
33 wxColourData(const wxColourData& data);
34 ~wxColourData();
35
36 void SetChooseFull(bool flag) { m_chooseFull = flag; }
37 bool GetChooseFull() const { return m_chooseFull; }
38 void SetColour(const wxColour& colour) { m_dataColour = colour; }
39 const wxColour& GetColour() const { return m_dataColour; }
40 wxColour& GetColour() { return m_dataColour; }
41
42 // Array of 16 custom colours
43 void SetCustomColour(int i, const wxColour& colour);
44 wxColour GetCustomColour(int i);
45
46 void operator=(const wxColourData& data);
47
48public:
49 wxColour m_dataColour;
50 wxColour m_custColours[16];
51 bool m_chooseFull;
52
53private:
54 DECLARE_DYNAMIC_CLASS(wxColourData)
55};
56
57class WXDLLEXPORT wxFontData: public wxObject
58{
59public:
60 wxFontData();
61 ~wxFontData();
62
63 wxFontData(const wxFontData& data)
64 : wxObject()
65 , m_fontColour(data.m_fontColour)
66 , m_showHelp(data.m_showHelp)
67 , m_allowSymbols(data.m_allowSymbols)
68 , m_enableEffects(data.m_enableEffects)
69 , m_initialFont(data.m_initialFont)
70 , m_chosenFont(data.m_chosenFont)
71 , m_minSize(data.m_minSize)
72 , m_maxSize(data.m_maxSize)
73 , m_encoding(data.m_encoding)
74 , m_encodingInfo(data.m_encodingInfo)
75 {
76 }
77
78 wxFontData& operator=(const wxFontData& data)
79 {
80 wxObject::operator=(data);
81 m_fontColour = data.m_fontColour;
82 m_showHelp = data.m_showHelp;
83 m_allowSymbols = data.m_allowSymbols;
84 m_enableEffects = data.m_enableEffects;
85 m_initialFont = data.m_initialFont;
86 m_chosenFont = data.m_chosenFont;
87 m_minSize = data.m_minSize;
88 m_maxSize = data.m_maxSize;
89 m_encoding = data.m_encoding;
90 m_encodingInfo = data.m_encodingInfo;
91 return *this;
92 }
93
94 void SetAllowSymbols(bool flag) { m_allowSymbols = flag; }
95 bool GetAllowSymbols() const { return m_allowSymbols; }
96
97 void SetColour(const wxColour& colour) { m_fontColour = colour; }
98 wxColour &GetColour() { return m_fontColour; }
99
100 void SetShowHelp(bool flag) { m_showHelp = flag; }
101 bool GetShowHelp() const { return m_showHelp; }
102
103 void EnableEffects(bool flag) { m_enableEffects = flag; }
104 bool GetEnableEffects() const { return m_enableEffects; }
105
106 void SetInitialFont(const wxFont& font) { m_initialFont = font; }
107 wxFont GetInitialFont() const { return m_initialFont; }
108
109 void SetChosenFont(const wxFont& font) { m_chosenFont = font; }
110 wxFont GetChosenFont() const { return m_chosenFont; }
111
112 void SetRange(int minRange, int maxRange) { m_minSize = minRange; m_maxSize = maxRange; }
113
114 // encoding info is split into 2 parts: the logical wxWin encoding
115 // (wxFontEncoding) and a structure containing the native parameters for
116 // it (wxNativeEncodingInfo)
117 wxFontEncoding GetEncoding() const { return m_encoding; }
118 void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; }
119
120 wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; }
121
122public:
123 wxColour m_fontColour;
124 bool m_showHelp;
125 bool m_allowSymbols;
126 bool m_enableEffects;
127 wxFont m_initialFont;
128 wxFont m_chosenFont;
129 int m_minSize;
130 int m_maxSize;
131
132private:
133 wxFontEncoding m_encoding;
134 wxNativeEncodingInfo m_encodingInfo;
135
136private:
137 DECLARE_DYNAMIC_CLASS(wxFontData)
138};
139
140#if wxUSE_PRINTING_ARCHITECTURE
141/*
142 * wxPrintData
143 * Encapsulates printer information (not printer dialog information)
144 */
145
146enum wxPrintBin
147{
148 wxPRINTBIN_DEFAULT,
149
150 wxPRINTBIN_ONLYONE,
151 wxPRINTBIN_LOWER,
152 wxPRINTBIN_MIDDLE,
153 wxPRINTBIN_MANUAL,
154 wxPRINTBIN_ENVELOPE,
155 wxPRINTBIN_ENVMANUAL,
156 wxPRINTBIN_AUTO,
157 wxPRINTBIN_TRACTOR,
158 wxPRINTBIN_SMALLFMT,
159 wxPRINTBIN_LARGEFMT,
160 wxPRINTBIN_LARGECAPACITY,
161 wxPRINTBIN_CASSETTE,
162 wxPRINTBIN_FORMSOURCE,
163
164 wxPRINTBIN_USER
165};
166
167
168class WXDLLEXPORT wxPrintData: public wxObject
169{
170public:
171 wxPrintData();
172 wxPrintData(const wxPrintData& printData);
173 ~wxPrintData();
174
175 int GetNoCopies() const { return m_printNoCopies; }
176 bool GetCollate() const { return m_printCollate; }
177 int GetOrientation() const { return m_printOrientation; }
178
179 // Is this data OK for showing the print dialog?
180 bool Ok() const ;
181
182 const wxString& GetPrinterName() const { return m_printerName; }
183 bool GetColour() const { return m_colour; }
184 wxDuplexMode GetDuplex() const { return m_duplexMode; }
185 wxPaperSize GetPaperId() const { return m_paperId; }
186 const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
187 // in wxPageSetupDialogData
188 wxPrintQuality GetQuality() const { return m_printQuality; }
189 wxPrintBin GetBin() const { return m_bin; }
190 wxPrintMode GetPrintMode() const { return m_printMode; }
191
192 void SetNoCopies(int v) { m_printNoCopies = v; }
193 void SetCollate(bool flag) { m_printCollate = flag; }
194 void SetOrientation(int orient) { m_printOrientation = orient; }
195
196 void SetPrinterName(const wxString& name) { m_printerName = name; }
197 void SetColour(bool colour) { m_colour = colour; }
198 void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
199 void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
200 void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
201 void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
202 void SetBin(wxPrintBin bin) { m_bin = bin; }
203 void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
204
205 wxString GetFilename() const { return m_filename; }
206 void SetFilename( const wxString &filename ) { m_filename = filename; }
207
208 void operator=(const wxPrintData& data);
209
210 char* GetPrivData() const { return m_privData; }
211 int GetPrivDataLen() const { return m_privDataLen; }
212 void SetPrivData( char *privData, int len );
213
214
215#if WXWIN_COMPATIBILITY_2_4
216 // PostScript-specific data
217 wxString GetPrinterCommand() const;
218 wxString GetPrinterOptions() const;
219 wxString GetPreviewCommand() const;
220 wxString GetFontMetricPath() const;
221 double GetPrinterScaleX() const;
222 double GetPrinterScaleY() const;
223 long GetPrinterTranslateX() const;
224 long GetPrinterTranslateY() const;
225
226 void SetPrinterCommand(const wxString& command);
227 void SetPrinterOptions(const wxString& options);
228 void SetPreviewCommand(const wxString& command);
229 void SetFontMetricPath(const wxString& path);
230 void SetPrinterScaleX(double x);
231 void SetPrinterScaleY(double y);
232 void SetPrinterScaling(double x, double y);
233 void SetPrinterTranslateX(long x);
234 void SetPrinterTranslateY(long y);
235 void SetPrinterTranslation(long x, long y);
236#endif
237
238 // Convert between wxPrintData and native data
239 void ConvertToNative();
240 void ConvertFromNative();
241 // Holds the native print data
242 wxPrintNativeDataBase *GetNativeData() const { return m_nativeData; }
243
244private:
245 wxPrintBin m_bin;
246 wxPrintMode m_printMode;
247
248 int m_printNoCopies;
249 int m_printOrientation;
250 bool m_printCollate;
251
252 wxString m_printerName;
253 bool m_colour;
254 wxDuplexMode m_duplexMode;
255 wxPrintQuality m_printQuality;
256 wxPaperSize m_paperId;
257 wxSize m_paperSize;
258
259 wxString m_filename;
260
261 char* m_privData;
262 int m_privDataLen;
263
264 wxPrintNativeDataBase *m_nativeData;
265
266private:
267 DECLARE_DYNAMIC_CLASS(wxPrintData)
268};
269
270/*
271 * wxPrintDialogData
272 * Encapsulates information displayed and edited in the printer dialog box.
273 * Contains a wxPrintData object which is filled in according to the values retrieved
274 * from the dialog.
275 */
276
277class WXDLLEXPORT wxPrintDialogData: public wxObject
278{
279public:
280 wxPrintDialogData();
281 wxPrintDialogData(const wxPrintDialogData& dialogData);
282 wxPrintDialogData(const wxPrintData& printData);
283 ~wxPrintDialogData();
284
285 int GetFromPage() const { return m_printFromPage; };
286 int GetToPage() const { return m_printToPage; };
287 int GetMinPage() const { return m_printMinPage; };
288 int GetMaxPage() const { return m_printMaxPage; };
289 int GetNoCopies() const { return m_printNoCopies; };
290 bool GetAllPages() const { return m_printAllPages; };
291 bool GetSelection() const { return m_printSelection; };
292 bool GetCollate() const { return m_printCollate; };
293 bool GetPrintToFile() const { return m_printToFile; };
294#if WXWIN_COMPATIBILITY_2_4
295 bool GetSetupDialog() const { return m_printSetupDialog; };
296#endif
297 void SetFromPage(int v) { m_printFromPage = v; };
298 void SetToPage(int v) { m_printToPage = v; };
299 void SetMinPage(int v) { m_printMinPage = v; };
300 void SetMaxPage(int v) { m_printMaxPage = v; };
301 void SetNoCopies(int v) { m_printNoCopies = v; };
302 void SetAllPages(bool flag) { m_printAllPages = flag; };
303 void SetSelection(bool flag) { m_printSelection = flag; };
304 void SetCollate(bool flag) { m_printCollate = flag; };
305 void SetPrintToFile(bool flag) { m_printToFile = flag; };
306#if WXWIN_COMPATIBILITY_2_4
307 void SetSetupDialog(bool flag) { m_printSetupDialog = flag; };
308#endif
309 void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; };
310 void EnableSelection(bool flag) { m_printEnableSelection = flag; };
311 void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; };
312 void EnableHelp(bool flag) { m_printEnableHelp = flag; };
313
314 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; };
315 bool GetEnableSelection() const { return m_printEnableSelection; };
316 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; };
317 bool GetEnableHelp() const { return m_printEnableHelp; };
318
319 // Is this data OK for showing the print dialog?
320 bool Ok() const { return m_printData.Ok() ; }
321
322 wxPrintData& GetPrintData() { return m_printData; }
323 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
324
325 void operator=(const wxPrintDialogData& data);
326 void operator=(const wxPrintData& data); // Sets internal m_printData member
327
328private:
329 int m_printFromPage;
330 int m_printToPage;
331 int m_printMinPage;
332 int m_printMaxPage;
333 int m_printNoCopies;
334 bool m_printAllPages;
335 bool m_printCollate;
336 bool m_printToFile;
337 bool m_printSelection;
338 bool m_printEnableSelection;
339 bool m_printEnablePageNumbers;
340 bool m_printEnableHelp;
341 bool m_printEnablePrintToFile;
342#if WXWIN_COMPATIBILITY_2_4
343 bool m_printSetupDialog;
344#endif
345 wxPrintData m_printData;
346
347private:
348 DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
349};
350
351/*
352* This is the data used (and returned) by the wxPageSetupDialog.
353*/
354
355// Compatibility with old name
356#define wxPageSetupData wxPageSetupDialogData
357
358class WXDLLEXPORT wxPageSetupDialogData: public wxObject
359{
360public:
361 wxPageSetupDialogData();
362 wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
363 wxPageSetupDialogData(const wxPrintData& printData);
364 ~wxPageSetupDialogData();
365
366 wxSize GetPaperSize() const { return m_paperSize; };
367 wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); };
368 wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; };
369 wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; };
370 wxPoint GetMarginTopLeft() const { return m_marginTopLeft; };
371 wxPoint GetMarginBottomRight() const { return m_marginBottomRight; };
372
373 bool GetDefaultMinMargins() const { return m_defaultMinMargins; };
374 bool GetEnableMargins() const { return m_enableMargins; };
375 bool GetEnableOrientation() const { return m_enableOrientation; };
376 bool GetEnablePaper() const { return m_enablePaper; };
377 bool GetEnablePrinter() const { return m_enablePrinter; };
378 bool GetDefaultInfo() const { return m_getDefaultInfo; };
379 bool GetEnableHelp() const { return m_enableHelp; };
380
381 // Is this data OK for showing the page setup dialog?
382 bool Ok() const { return m_printData.Ok() ; }
383
384 // If a corresponding paper type is found in the paper database, will set the m_printData
385 // paper size id member as well.
386 void SetPaperSize(const wxSize& sz);
387
388 void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); };
389
390 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
391 void SetPaperSize(wxPaperSize id);
392
393 void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; };
394 void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; };
395 void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; };
396 void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; };
397 void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; };
398 void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; };
399
400 void EnableMargins(bool flag) { m_enableMargins = flag; };
401 void EnableOrientation(bool flag) { m_enableOrientation = flag; };
402 void EnablePaper(bool flag) { m_enablePaper = flag; };
403 void EnablePrinter(bool flag) { m_enablePrinter = flag; };
404 void EnableHelp(bool flag) { m_enableHelp = flag; };
405
406 // Use paper size defined in this object to set the wxPrintData
407 // paper id
408 void CalculateIdFromPaperSize();
409
410 // Use paper id in wxPrintData to set this object's paper size
411 void CalculatePaperSizeFromId();
412
413 wxPageSetupDialogData& operator=(const wxPageSetupData& data);
414 wxPageSetupDialogData& operator=(const wxPrintData& data);
415
416 wxPrintData& GetPrintData() { return m_printData; }
417 void SetPrintData(const wxPrintData& printData);
418
419private:
420 wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
421 wxPoint m_minMarginTopLeft;
422 wxPoint m_minMarginBottomRight;
423 wxPoint m_marginTopLeft;
424 wxPoint m_marginBottomRight;
425 bool m_defaultMinMargins;
426 bool m_enableMargins;
427 bool m_enableOrientation;
428 bool m_enablePaper;
429 bool m_enablePrinter;
430 bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
431 bool m_enableHelp;
432 wxPrintData m_printData;
433
434private:
435 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
436};
437
438#endif // wxUSE_PRINTING_ARCHITECTURE
439
440#endif
441// _WX_CMNDATA_H_BASE_