]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cmndata.h
allow specifying the initial modifier keys values in the ctor
[wxWidgets.git] / include / wx / cmndata.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/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
26 class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
27
28
29 class WXDLLIMPEXP_CORE wxColourData : public wxObject
30 {
31 public:
32 // number of custom colours we store
33 enum
34 {
35 NUM_CUSTOM = 16
36 };
37
38 wxColourData();
39 wxColourData(const wxColourData& data);
40 wxColourData& operator=(const wxColourData& data);
41 virtual ~wxColourData();
42
43 void SetChooseFull(bool flag) { m_chooseFull = flag; }
44 bool GetChooseFull() const { return m_chooseFull; }
45 void SetColour(const wxColour& colour) { m_dataColour = colour; }
46 const wxColour& GetColour() const { return m_dataColour; }
47 wxColour& GetColour() { return m_dataColour; }
48
49 // These functions modify colours in an internal array of NUM_CUSTOM custom
50 // colours
51 void SetCustomColour(int i, const wxColour& colour);
52 wxColour GetCustomColour(int i);
53
54 // Serialize the object to a string and restore it from it
55 wxString ToString() const;
56 bool FromString(const wxString& str);
57
58 public: // TODO: make these fields private
59 wxColour m_dataColour;
60 wxColour m_custColours[NUM_CUSTOM];
61 bool m_chooseFull;
62
63 private:
64 DECLARE_DYNAMIC_CLASS(wxColourData)
65 };
66
67 class WXDLLIMPEXP_CORE wxFontData : public wxObject
68 {
69 public:
70 wxFontData();
71 virtual ~wxFontData();
72
73 wxFontData(const wxFontData& data)
74 : wxObject(),
75 m_fontColour(data.m_fontColour),
76 m_showHelp(data.m_showHelp),
77 m_allowSymbols(data.m_allowSymbols),
78 m_enableEffects(data.m_enableEffects),
79 m_initialFont(data.m_initialFont),
80 m_chosenFont(data.m_chosenFont),
81 m_minSize(data.m_minSize),
82 m_maxSize(data.m_maxSize),
83 m_encoding(data.m_encoding),
84 m_encodingInfo(data.m_encodingInfo)
85 {
86 }
87
88 wxFontData& operator=(const wxFontData& data)
89 {
90 if (&data != this)
91 {
92 wxObject::operator=(data);
93 m_fontColour = data.m_fontColour;
94 m_showHelp = data.m_showHelp;
95 m_allowSymbols = data.m_allowSymbols;
96 m_enableEffects = data.m_enableEffects;
97 m_initialFont = data.m_initialFont;
98 m_chosenFont = data.m_chosenFont;
99 m_minSize = data.m_minSize;
100 m_maxSize = data.m_maxSize;
101 m_encoding = data.m_encoding;
102 m_encodingInfo = data.m_encodingInfo;
103 }
104 return *this;
105 }
106
107 void SetAllowSymbols(bool flag) { m_allowSymbols = flag; }
108 bool GetAllowSymbols() const { return m_allowSymbols; }
109
110 void SetColour(const wxColour& colour) { m_fontColour = colour; }
111 const wxColour& GetColour() const { return m_fontColour; }
112
113 void SetShowHelp(bool flag) { m_showHelp = flag; }
114 bool GetShowHelp() const { return m_showHelp; }
115
116 void EnableEffects(bool flag) { m_enableEffects = flag; }
117 bool GetEnableEffects() const { return m_enableEffects; }
118
119 void SetInitialFont(const wxFont& font) { m_initialFont = font; }
120 wxFont GetInitialFont() const { return m_initialFont; }
121
122 void SetChosenFont(const wxFont& font) { m_chosenFont = font; }
123 wxFont GetChosenFont() const { return m_chosenFont; }
124
125 void SetRange(int minRange, int maxRange) { m_minSize = minRange; m_maxSize = maxRange; }
126
127 // encoding info is split into 2 parts: the logical wxWin encoding
128 // (wxFontEncoding) and a structure containing the native parameters for
129 // it (wxNativeEncodingInfo)
130 wxFontEncoding GetEncoding() const { return m_encoding; }
131 void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; }
132
133 wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; }
134
135
136 // public for backwards compatibility only: don't use directly
137 public:
138 wxColour m_fontColour;
139 bool m_showHelp;
140 bool m_allowSymbols;
141 bool m_enableEffects;
142 wxFont m_initialFont;
143 wxFont m_chosenFont;
144 int m_minSize;
145 int m_maxSize;
146
147 private:
148 wxFontEncoding m_encoding;
149 wxNativeEncodingInfo m_encodingInfo;
150
151 private:
152 DECLARE_DYNAMIC_CLASS(wxFontData)
153 };
154
155 #if wxUSE_PRINTING_ARCHITECTURE
156 /*
157 * wxPrintData
158 * Encapsulates printer information (not printer dialog information)
159 */
160
161 enum wxPrintBin
162 {
163 wxPRINTBIN_DEFAULT,
164
165 wxPRINTBIN_ONLYONE,
166 wxPRINTBIN_LOWER,
167 wxPRINTBIN_MIDDLE,
168 wxPRINTBIN_MANUAL,
169 wxPRINTBIN_ENVELOPE,
170 wxPRINTBIN_ENVMANUAL,
171 wxPRINTBIN_AUTO,
172 wxPRINTBIN_TRACTOR,
173 wxPRINTBIN_SMALLFMT,
174 wxPRINTBIN_LARGEFMT,
175 wxPRINTBIN_LARGECAPACITY,
176 wxPRINTBIN_CASSETTE,
177 wxPRINTBIN_FORMSOURCE,
178
179 wxPRINTBIN_USER
180 };
181
182 const int wxPRINTMEDIA_DEFAULT = 0;
183
184 class WXDLLIMPEXP_CORE wxPrintData: public wxObject
185 {
186 public:
187 wxPrintData();
188 wxPrintData(const wxPrintData& printData);
189 virtual ~wxPrintData();
190
191 int GetNoCopies() const { return m_printNoCopies; }
192 bool GetCollate() const { return m_printCollate; }
193 int GetOrientation() const { return m_printOrientation; }
194 bool IsOrientationReversed() const { return m_printOrientationReversed; }
195
196 // Is this data OK for showing the print dialog?
197 bool Ok() const { return IsOk(); }
198 bool IsOk() const ;
199
200 const wxString& GetPrinterName() const { return m_printerName; }
201 bool GetColour() const { return m_colour; }
202 wxDuplexMode GetDuplex() const { return m_duplexMode; }
203 wxPaperSize GetPaperId() const { return m_paperId; }
204 const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
205 // in wxPageSetupDialogData
206 wxPrintQuality GetQuality() const { return m_printQuality; }
207 wxPrintBin GetBin() const { return m_bin; }
208 wxPrintMode GetPrintMode() const { return m_printMode; }
209 int GetMedia() const { return m_media; }
210
211 void SetNoCopies(int v) { m_printNoCopies = v; }
212 void SetCollate(bool flag) { m_printCollate = flag; }
213 void SetOrientation(int orient) { m_printOrientation = orient; }
214 void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; }
215
216 void SetPrinterName(const wxString& name) { m_printerName = name; }
217 void SetColour(bool colour) { m_colour = colour; }
218 void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
219 void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
220 void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
221 void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
222 void SetBin(wxPrintBin bin) { m_bin = bin; }
223 void SetMedia(int media) { m_media = media; }
224 void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
225
226 wxString GetFilename() const { return m_filename; }
227 void SetFilename( const wxString &filename ) { m_filename = filename; }
228
229 void operator=(const wxPrintData& data);
230
231 char* GetPrivData() const { return m_privData; }
232 int GetPrivDataLen() const { return m_privDataLen; }
233 void SetPrivData( char *privData, int len );
234
235
236 // Convert between wxPrintData and native data
237 void ConvertToNative();
238 void ConvertFromNative();
239 // Holds the native print data
240 wxPrintNativeDataBase *GetNativeData() const { return m_nativeData; }
241
242 private:
243 wxPrintBin m_bin;
244 int m_media;
245 wxPrintMode m_printMode;
246
247 int m_printNoCopies;
248 int m_printOrientation;
249 bool m_printOrientationReversed;
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
266 private:
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
277 class WXDLLIMPEXP_CORE wxPrintDialogData: public wxObject
278 {
279 public:
280 wxPrintDialogData();
281 wxPrintDialogData(const wxPrintDialogData& dialogData);
282 wxPrintDialogData(const wxPrintData& printData);
283 virtual ~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
295 void SetFromPage(int v) { m_printFromPage = v; }
296 void SetToPage(int v) { m_printToPage = v; }
297 void SetMinPage(int v) { m_printMinPage = v; }
298 void SetMaxPage(int v) { m_printMaxPage = v; }
299 void SetNoCopies(int v) { m_printNoCopies = v; }
300 void SetAllPages(bool flag) { m_printAllPages = flag; }
301 void SetSelection(bool flag) { m_printSelection = flag; }
302 void SetCollate(bool flag) { m_printCollate = flag; }
303 void SetPrintToFile(bool flag) { m_printToFile = flag; }
304
305 void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }
306 void EnableSelection(bool flag) { m_printEnableSelection = flag; }
307 void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }
308 void EnableHelp(bool flag) { m_printEnableHelp = flag; }
309
310 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; }
311 bool GetEnableSelection() const { return m_printEnableSelection; }
312 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; }
313 bool GetEnableHelp() const { return m_printEnableHelp; }
314
315 // Is this data OK for showing the print dialog?
316 bool Ok() const { return IsOk(); }
317 bool IsOk() const { return m_printData.Ok() ; }
318
319 wxPrintData& GetPrintData() { return m_printData; }
320 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
321
322 void operator=(const wxPrintDialogData& data);
323 void operator=(const wxPrintData& data); // Sets internal m_printData member
324
325 private:
326 int m_printFromPage;
327 int m_printToPage;
328 int m_printMinPage;
329 int m_printMaxPage;
330 int m_printNoCopies;
331 bool m_printAllPages;
332 bool m_printCollate;
333 bool m_printToFile;
334 bool m_printSelection;
335 bool m_printEnableSelection;
336 bool m_printEnablePageNumbers;
337 bool m_printEnableHelp;
338 bool m_printEnablePrintToFile;
339 wxPrintData m_printData;
340
341 private:
342 DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
343 };
344
345 /*
346 * This is the data used (and returned) by the wxPageSetupDialog.
347 */
348
349 // Compatibility with old name
350 #define wxPageSetupData wxPageSetupDialogData
351
352 class WXDLLIMPEXP_CORE wxPageSetupDialogData: public wxObject
353 {
354 public:
355 wxPageSetupDialogData();
356 wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
357 wxPageSetupDialogData(const wxPrintData& printData);
358 virtual ~wxPageSetupDialogData();
359
360 wxSize GetPaperSize() const { return m_paperSize; }
361 wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); }
362 wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; }
363 wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; }
364 wxPoint GetMarginTopLeft() const { return m_marginTopLeft; }
365 wxPoint GetMarginBottomRight() const { return m_marginBottomRight; }
366
367 bool GetDefaultMinMargins() const { return m_defaultMinMargins; }
368 bool GetEnableMargins() const { return m_enableMargins; }
369 bool GetEnableOrientation() const { return m_enableOrientation; }
370 bool GetEnablePaper() const { return m_enablePaper; }
371 bool GetEnablePrinter() const { return m_enablePrinter; }
372 bool GetDefaultInfo() const { return m_getDefaultInfo; }
373 bool GetEnableHelp() const { return m_enableHelp; }
374
375 // Is this data OK for showing the page setup dialog?
376 bool Ok() const { return IsOk(); }
377 bool IsOk() const { return m_printData.Ok() ; }
378
379 // If a corresponding paper type is found in the paper database, will set the m_printData
380 // paper size id member as well.
381 void SetPaperSize(const wxSize& sz);
382
383 void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); }
384
385 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
386 void SetPaperSize(wxPaperSize id);
387
388 void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; }
389 void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; }
390 void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; }
391 void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; }
392 void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; }
393 void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; }
394
395 void EnableMargins(bool flag) { m_enableMargins = flag; }
396 void EnableOrientation(bool flag) { m_enableOrientation = flag; }
397 void EnablePaper(bool flag) { m_enablePaper = flag; }
398 void EnablePrinter(bool flag) { m_enablePrinter = flag; }
399 void EnableHelp(bool flag) { m_enableHelp = flag; }
400
401 // Use paper size defined in this object to set the wxPrintData
402 // paper id
403 void CalculateIdFromPaperSize();
404
405 // Use paper id in wxPrintData to set this object's paper size
406 void CalculatePaperSizeFromId();
407
408 wxPageSetupDialogData& operator=(const wxPageSetupData& data);
409 wxPageSetupDialogData& operator=(const wxPrintData& data);
410
411 wxPrintData& GetPrintData() { return m_printData; }
412 const wxPrintData& GetPrintData() const { return m_printData; }
413 void SetPrintData(const wxPrintData& printData);
414
415 private:
416 wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
417 wxPoint m_minMarginTopLeft;
418 wxPoint m_minMarginBottomRight;
419 wxPoint m_marginTopLeft;
420 wxPoint m_marginBottomRight;
421 bool m_defaultMinMargins;
422 bool m_enableMargins;
423 bool m_enableOrientation;
424 bool m_enablePaper;
425 bool m_enablePrinter;
426 bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
427 bool m_enableHelp;
428 wxPrintData m_printData;
429
430 private:
431 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
432 };
433
434 #endif // wxUSE_PRINTING_ARCHITECTURE
435
436 #endif
437 // _WX_CMNDATA_H_BASE_