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