]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cmndata.h
simplify wxEVT_MENU_OPEN/CLOSE generation
[wxWidgets.git] / include / wx / cmndata.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/cmndata.h
c801d85f
KB
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
77b497a0 15#include "wx/window.h"
34138703 16#include "wx/font.h"
0bc93470 17#include "wx/encinfo.h"
34138703 18#include "wx/colour.h"
8bedcdce 19#include "wx/gdicmn.h"
34138703 20
244e5e34
VZ
21#if wxUSE_STREAMS
22#include "wx/stream.h"
23#endif
24
8850cbd3 25
b5dbe15d 26class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
8850cbd3
RR
27
28
e6ef9ea4 29class WXDLLEXPORT wxColourData : public wxObject
c801d85f 30{
7bcb11d3 31public:
e6ef9ea4
VZ
32 // number of custom colours we store
33 enum
34 {
35 NUM_CUSTOM = 16
36 };
37
7bcb11d3
JS
38 wxColourData();
39 wxColourData(const wxColourData& data);
5cd0202b 40 wxColourData& operator=(const wxColourData& data);
d3c7fc99 41 virtual ~wxColourData();
d6b9496a 42
ae500232
JS
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; }
7bcb11d3 48
e6ef9ea4
VZ
49 // These functions modify colours in an internal array of NUM_CUSTOM custom
50 // colours
cebf2fec 51 void SetCustomColour(int i, const wxColour& colour);
7bcb11d3 52 wxColour GetCustomColour(int i);
d6b9496a 53
e6ef9ea4
VZ
54 // Serialize the object to a string and restore it from it
55 wxString ToString() const;
56 bool FromString(const wxString& str);
7bcb11d3 57
e6ef9ea4 58public: // TODO: make these fields private
ae500232 59 wxColour m_dataColour;
e6ef9ea4 60 wxColour m_custColours[NUM_CUSTOM];
ae500232 61 bool m_chooseFull;
68379eaf 62
eba33006
RR
63private:
64 DECLARE_DYNAMIC_CLASS(wxColourData)
c801d85f
KB
65};
66
aae53500 67class WXDLLEXPORT wxFontData : public wxObject
c801d85f 68{
7bcb11d3
JS
69public:
70 wxFontData();
aae53500 71 virtual ~wxFontData();
7bcb11d3 72
5e472c1f 73 wxFontData(const wxFontData& data)
aae53500
VZ
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)
5e472c1f
GD
85 {
86 }
87
88 wxFontData& operator=(const wxFontData& data)
89 {
162e998c
PC
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 }
5e472c1f
GD
104 return *this;
105 }
68379eaf 106
ae500232
JS
107 void SetAllowSymbols(bool flag) { m_allowSymbols = flag; }
108 bool GetAllowSymbols() const { return m_allowSymbols; }
d6b9496a 109
ae500232 110 void SetColour(const wxColour& colour) { m_fontColour = colour; }
aae53500 111 const wxColour& GetColour() const { return m_fontColour; }
7bcb11d3 112
ae500232
JS
113 void SetShowHelp(bool flag) { m_showHelp = flag; }
114 bool GetShowHelp() const { return m_showHelp; }
7bcb11d3 115
ae500232
JS
116 void EnableEffects(bool flag) { m_enableEffects = flag; }
117 bool GetEnableEffects() const { return m_enableEffects; }
7bcb11d3 118
ae500232
JS
119 void SetInitialFont(const wxFont& font) { m_initialFont = font; }
120 wxFont GetInitialFont() const { return m_initialFont; }
7bcb11d3 121
ae500232
JS
122 void SetChosenFont(const wxFont& font) { m_chosenFont = font; }
123 wxFont GetChosenFont() const { return m_chosenFont; }
7bcb11d3 124
ae500232 125 void SetRange(int minRange, int maxRange) { m_minSize = minRange; m_maxSize = maxRange; }
7bcb11d3 126
7beba2fc
VZ
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; }
7bcb11d3 134
aae53500
VZ
135
136 // public for backwards compatibility only: don't use directly
7bcb11d3 137public:
ae500232
JS
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;
7beba2fc
VZ
146
147private:
148 wxFontEncoding m_encoding;
149 wxNativeEncodingInfo m_encodingInfo;
68379eaf 150
eba33006
RR
151private:
152 DECLARE_DYNAMIC_CLASS(wxFontData)
c801d85f
KB
153};
154
88ac883a 155#if wxUSE_PRINTING_ARCHITECTURE
c801d85f
KB
156/*
157 * wxPrintData
7bcb11d3 158 * Encapsulates printer information (not printer dialog information)
c801d85f 159 */
7bcb11d3 160
60090256
VZ
161enum 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
1399de55 179 wxPRINTBIN_USER
60090256
VZ
180};
181
781609f2 182const int wxPRINTMEDIA_DEFAULT = 0;
60090256 183
c801d85f
KB
184class WXDLLEXPORT wxPrintData: public wxObject
185{
eba33006 186public:
7bcb11d3
JS
187 wxPrintData();
188 wxPrintData(const wxPrintData& printData);
d3c7fc99 189 virtual ~wxPrintData();
d6b9496a 190
dbc37e68
RR
191 int GetNoCopies() const { return m_printNoCopies; }
192 bool GetCollate() const { return m_printCollate; }
193 int GetOrientation() const { return m_printOrientation; }
01294df0 194 bool IsOrientationReversed() const { return m_printOrientationReversed; }
d6b9496a 195
58cf0491 196 // Is this data OK for showing the print dialog?
b7cacb43
VZ
197 bool Ok() const { return IsOk(); }
198 bool IsOk() const ;
58cf0491 199
d6b9496a
VZ
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
7bcb11d3 205 // in wxPageSetupDialogData
d6b9496a 206 wxPrintQuality GetQuality() const { return m_printQuality; }
60090256 207 wxPrintBin GetBin() const { return m_bin; }
6038ec8e 208 wxPrintMode GetPrintMode() const { return m_printMode; }
781609f2 209 int GetMedia() const { return m_media; }
7bcb11d3 210
dbc37e68
RR
211 void SetNoCopies(int v) { m_printNoCopies = v; }
212 void SetCollate(bool flag) { m_printCollate = flag; }
213 void SetOrientation(int orient) { m_printOrientation = orient; }
01294df0 214 void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; }
7bcb11d3 215
d6b9496a
VZ
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; }
60090256 222 void SetBin(wxPrintBin bin) { m_bin = bin; }
781609f2 223 void SetMedia(int media) { m_media = media; }
6038ec8e 224 void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
7bcb11d3 225
8850cbd3
RR
226 wxString GetFilename() const { return m_filename; }
227 void SetFilename( const wxString &filename ) { m_filename = filename; }
ce7208d4 228
7bcb11d3
JS
229 void operator=(const wxPrintData& data);
230
aa96f01c
RR
231 char* GetPrivData() const { return m_privData; }
232 int GetPrivDataLen() const { return m_privDataLen; }
233 void SetPrivData( char *privData, int len );
ce7208d4 234
aa96f01c 235
53fa663a 236 // Convert between wxPrintData and native data
7bcb11d3
JS
237 void ConvertToNative();
238 void ConvertFromNative();
53fa663a
RR
239 // Holds the native print data
240 wxPrintNativeDataBase *GetNativeData() const { return m_nativeData; }
d6b9496a 241
7bcb11d3 242private:
60090256 243 wxPrintBin m_bin;
781609f2 244 int m_media;
6038ec8e 245 wxPrintMode m_printMode;
2b5f62a0 246
7bcb11d3
JS
247 int m_printNoCopies;
248 int m_printOrientation;
01294df0 249 bool m_printOrientationReversed;
7bcb11d3
JS
250 bool m_printCollate;
251
7bcb11d3
JS
252 wxString m_printerName;
253 bool m_colour;
254 wxDuplexMode m_duplexMode;
255 wxPrintQuality m_printQuality;
256 wxPaperSize m_paperId;
257 wxSize m_paperSize;
ce7208d4 258
7bcb11d3 259 wxString m_filename;
ce7208d4 260
aa96f01c
RR
261 char* m_privData;
262 int m_privDataLen;
ce7208d4 263
8850cbd3 264 wxPrintNativeDataBase *m_nativeData;
244e5e34 265
eba33006
RR
266private:
267 DECLARE_DYNAMIC_CLASS(wxPrintData)
c801d85f
KB
268};
269
270/*
7bcb11d3
JS
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.
c801d85f
KB
275 */
276
7bcb11d3 277class WXDLLEXPORT wxPrintDialogData: public wxObject
c801d85f 278{
eba33006 279public:
7bcb11d3
JS
280 wxPrintDialogData();
281 wxPrintDialogData(const wxPrintDialogData& dialogData);
282 wxPrintDialogData(const wxPrintData& printData);
d3c7fc99 283 virtual ~wxPrintDialogData();
d6b9496a 284
47b378bd
VS
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; }
d6b9496a 314
58cf0491 315 // Is this data OK for showing the print dialog?
b7cacb43
VZ
316 bool Ok() const { return IsOk(); }
317 bool IsOk() const { return m_printData.Ok() ; }
58cf0491 318
d6b9496a
VZ
319 wxPrintData& GetPrintData() { return m_printData; }
320 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
7bcb11d3
JS
321
322 void operator=(const wxPrintDialogData& data);
323 void operator=(const wxPrintData& data); // Sets internal m_printData member
d6b9496a 324
7bcb11d3 325private:
7bcb11d3
JS
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;
5360828d 334 bool m_printSelection;
7bcb11d3
JS
335 bool m_printEnableSelection;
336 bool m_printEnablePageNumbers;
337 bool m_printEnableHelp;
338 bool m_printEnablePrintToFile;
7bcb11d3 339 wxPrintData m_printData;
eba33006 340
68379eaf 341private:
eba33006 342 DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
7bcb11d3
JS
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
c801d85f 351
7bcb11d3
JS
352class WXDLLEXPORT wxPageSetupDialogData: public wxObject
353{
7bcb11d3
JS
354public:
355 wxPageSetupDialogData();
356 wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
357 wxPageSetupDialogData(const wxPrintData& printData);
d3c7fc99 358 virtual ~wxPageSetupDialogData();
7bcb11d3 359
47b378bd
VS
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; }
7bcb11d3 374
58cf0491 375 // Is this data OK for showing the page setup dialog?
b7cacb43
VZ
376 bool Ok() const { return IsOk(); }
377 bool IsOk() const { return m_printData.Ok() ; }
58cf0491 378
7bcb11d3
JS
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
47b378bd 383 void SetPaperId(wxPaperSize id) { m_printData.SetPaperId(id); }
69157f8b 384
7bcb11d3
JS
385 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
386 void SetPaperSize(wxPaperSize id);
387
47b378bd
VS
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; }
d6b9496a 400
7bcb11d3
JS
401 // Use paper size defined in this object to set the wxPrintData
402 // paper id
403 void CalculateIdFromPaperSize();
d6b9496a 404
7bcb11d3
JS
405 // Use paper id in wxPrintData to set this object's paper size
406 void CalculatePaperSizeFromId();
d6b9496a 407
5e472c1f
GD
408 wxPageSetupDialogData& operator=(const wxPageSetupData& data);
409 wxPageSetupDialogData& operator=(const wxPrintData& data);
7bcb11d3 410
d6b9496a 411 wxPrintData& GetPrintData() { return m_printData; }
f415cab9 412 const wxPrintData& GetPrintData() const { return m_printData; }
24c5243d 413 void SetPrintData(const wxPrintData& printData);
c801d85f 414
7bcb11d3 415private:
7bcb11d3
JS
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;
7bcb11d3
JS
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;
7bcb11d3 428 wxPrintData m_printData;
68379eaf 429
eba33006
RR
430private:
431 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
7bcb11d3 432};
c801d85f 433
88ac883a
VZ
434#endif // wxUSE_PRINTING_ARCHITECTURE
435
c801d85f 436#endif
7bcb11d3 437// _WX_CMNDATA_H_BASE_