]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cmndata.h
Made various Motif fixes, wxListBox/wxChoice derive from wxControlWithItems,
[wxWidgets.git] / include / wx / cmndata.h
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 #ifdef __GNUG__
16 #pragma interface "cmndata.h"
17 #endif
18
19 #include "wx/window.h"
20 #include "wx/font.h"
21 #include "wx/fontutil.h"
22 #include "wx/colour.h"
23 #include "wx/gdicmn.h"
24
25 #if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__)) && wxUSE_POSTSCRIPT
26 class WXDLLEXPORT wxPrintSetupData;
27 #endif
28
29 class WXDLLEXPORT wxColourData: public wxObject
30 {
31 DECLARE_DYNAMIC_CLASS(wxColourData)
32 public:
33 wxColourData();
34 wxColourData(const wxColourData& data);
35 ~wxColourData();
36
37 void SetChooseFull(bool flag) { chooseFull = flag; }
38 bool GetChooseFull() const { return chooseFull; }
39 void SetColour(wxColour& colour) { dataColour = colour; }
40 wxColour &GetColour() { return dataColour; }
41
42 // Array of 16 custom colours
43 void SetCustomColour(int i, wxColour& colour);
44 wxColour GetCustomColour(int i);
45
46 void operator=(const wxColourData& data);
47
48 public:
49 wxColour dataColour;
50 wxColour custColours[16];
51 bool chooseFull;
52 };
53
54 class WXDLLEXPORT wxFontData: public wxObject
55 {
56 DECLARE_DYNAMIC_CLASS(wxFontData)
57 public:
58 wxFontData();
59 ~wxFontData();
60
61 void SetAllowSymbols(bool flag) { allowSymbols = flag; }
62 bool GetAllowSymbols() const { return allowSymbols; }
63
64 void SetColour(const wxColour& colour) { fontColour = colour; }
65 wxColour &GetColour() { return fontColour; }
66
67 void SetShowHelp(bool flag) { showHelp = flag; }
68 bool GetShowHelp() const { return showHelp; }
69
70 void EnableEffects(bool flag) { enableEffects = flag; }
71 bool GetEnableEffects() const { return enableEffects; }
72
73 void SetInitialFont(const wxFont& font) { initialFont = font; }
74 wxFont GetInitialFont() const { return initialFont; }
75
76 void SetChosenFont(const wxFont& font) { chosenFont = font; }
77 wxFont GetChosenFont() const { return chosenFont; }
78
79 void SetRange(int minRange, int maxRange) { minSize = minRange; maxSize = maxRange; }
80
81 // encoding info is split into 2 parts: the logical wxWin encoding
82 // (wxFontEncoding) and a structure containing the native parameters for
83 // it (wxNativeEncodingInfo)
84 wxFontEncoding GetEncoding() const { return m_encoding; }
85 void SetEncoding(wxFontEncoding encoding) { m_encoding = encoding; }
86
87 wxNativeEncodingInfo& EncodingInfo() { return m_encodingInfo; }
88
89 public:
90 wxColour fontColour;
91 bool showHelp;
92 bool allowSymbols;
93 bool enableEffects;
94 wxFont initialFont;
95 wxFont chosenFont;
96 int minSize;
97 int maxSize;
98
99 private:
100 wxFontEncoding m_encoding;
101 wxNativeEncodingInfo m_encodingInfo;
102 };
103
104 #if wxUSE_PRINTING_ARCHITECTURE
105 /*
106 * wxPrintData
107 * Encapsulates printer information (not printer dialog information)
108 */
109
110 class WXDLLEXPORT wxPrintData: public wxObject
111 {
112 DECLARE_DYNAMIC_CLASS(wxPrintData)
113
114 wxPrintData();
115 wxPrintData(const wxPrintData& printData);
116 ~wxPrintData();
117
118 int GetNoCopies() const { return m_printNoCopies; };
119 bool GetCollate() const { return m_printCollate; };
120 int GetOrientation() const { return m_printOrientation; };
121
122 const wxString& GetPrinterName() const { return m_printerName; }
123 bool GetColour() const { return m_colour; }
124 wxDuplexMode GetDuplex() const { return m_duplexMode; }
125 wxPaperSize GetPaperId() const { return m_paperId; }
126 const wxSize& GetPaperSize() const { return m_paperSize; } // Not used yet: confusable with paper size
127 // in wxPageSetupDialogData
128 wxPrintQuality GetQuality() const { return m_printQuality; }
129
130 void SetNoCopies(int v) { m_printNoCopies = v; };
131 void SetCollate(bool flag) { m_printCollate = flag; };
132 void SetOrientation(int orient) { m_printOrientation = orient; };
133
134 void SetPrinterName(const wxString& name) { m_printerName = name; }
135 void SetColour(bool colour) { m_colour = colour; }
136 void SetDuplex(wxDuplexMode duplex) { m_duplexMode = duplex; }
137 void SetPaperId(wxPaperSize sizeId) { m_paperId = sizeId; }
138 void SetPaperSize(const wxSize& sz) { m_paperSize = sz; }
139 void SetQuality(wxPrintQuality quality) { m_printQuality = quality; }
140
141 // PostScript-specific data
142 const wxString& GetPrinterCommand() const { return m_printerCommand; }
143 const wxString& GetPrinterOptions() const { return m_printerOptions; }
144 const wxString& GetPreviewCommand() const { return m_previewCommand; }
145 const wxString& GetFilename() const { return m_filename; }
146 const wxString& GetFontMetricPath() const { return m_afmPath; }
147 double GetPrinterScaleX() const { return m_printerScaleX; }
148 double GetPrinterScaleY() const { return m_printerScaleY; }
149 long GetPrinterTranslateX() const { return m_printerTranslateX; }
150 long GetPrinterTranslateY() const { return m_printerTranslateY; }
151 wxPrintMode GetPrintMode() const { return m_printMode; }
152
153 void SetPrinterCommand(const wxString& command) { m_printerCommand = command; }
154 void SetPrinterOptions(const wxString& options) { m_printerOptions = options; }
155 void SetPreviewCommand(const wxString& command) { m_previewCommand = command; }
156 void SetFilename(const wxString& filename) { m_filename = filename; }
157 void SetFontMetricPath(const wxString& path) { m_afmPath = path; }
158 void SetPrinterScaleX(double x) { m_printerScaleX = x; }
159 void SetPrinterScaleY(double y) { m_printerScaleY = y; }
160 void SetPrinterScaling(double x, double y) { m_printerScaleX = x; m_printerScaleY = y; }
161 void SetPrinterTranslateX(long x) { m_printerTranslateX = x; }
162 void SetPrinterTranslateY(long y) { m_printerTranslateY = y; }
163 void SetPrinterTranslation(long x, long y) { m_printerTranslateX = x; m_printerTranslateY = y; }
164 void SetPrintMode(wxPrintMode printMode) { m_printMode = printMode; }
165
166 void operator=(const wxPrintData& data);
167
168 // For compatibility
169 #if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__)) && wxUSE_POSTSCRIPT
170 void operator=(const wxPrintSetupData& setupData);
171 #endif
172
173 #if defined(__WXMSW__)
174 // Convert to/from the DEVMODE structure
175 void ConvertToNative();
176 void ConvertFromNative();
177 void* GetNativeData() const { return m_devMode; }
178 void SetNativeData(void* data) { m_devMode = data; }
179 #endif
180
181 public:
182 #ifdef __WXMSW__
183 void* m_devMode;
184 #endif
185
186 private:
187
188 int m_printNoCopies;
189 int m_printOrientation;
190 bool m_printCollate;
191
192 // New members, 24/3/99
193 wxString m_printerName;
194 bool m_colour;
195 wxDuplexMode m_duplexMode;
196 wxPrintQuality m_printQuality;
197 wxPaperSize m_paperId;
198 wxSize m_paperSize;
199
200 // PostScript-specific data
201 wxString m_printerCommand;
202 wxString m_previewCommand;
203 wxString m_printerOptions;
204 wxString m_filename;
205 wxString m_afmPath;
206 double m_printerScaleX;
207 double m_printerScaleY;
208 long m_printerTranslateX;
209 long m_printerTranslateY;
210 wxPrintMode m_printMode;
211 };
212
213 /*
214 * wxPrintDialogData
215 * Encapsulates information displayed and edited in the printer dialog box.
216 * Contains a wxPrintData object which is filled in according to the values retrieved
217 * from the dialog.
218 */
219
220 class WXDLLEXPORT wxPrintDialogData: public wxObject
221 {
222 DECLARE_DYNAMIC_CLASS(wxPrintDialogData)
223
224 wxPrintDialogData();
225 wxPrintDialogData(const wxPrintDialogData& dialogData);
226 wxPrintDialogData(const wxPrintData& printData);
227 ~wxPrintDialogData();
228
229 int GetFromPage() const { return m_printFromPage; };
230 int GetToPage() const { return m_printToPage; };
231 int GetMinPage() const { return m_printMinPage; };
232 int GetMaxPage() const { return m_printMaxPage; };
233 int GetNoCopies() const { return m_printNoCopies; };
234 bool GetAllPages() const { return m_printAllPages; };
235 bool GetSelection() const { return m_printSelection; };
236 bool GetCollate() const { return m_printCollate; };
237 bool GetPrintToFile() const { return m_printToFile; };
238 bool GetSetupDialog() const { return m_printSetupDialog; };
239
240 void SetFromPage(int v) { m_printFromPage = v; };
241 void SetToPage(int v) { m_printToPage = v; };
242 void SetMinPage(int v) { m_printMinPage = v; };
243 void SetMaxPage(int v) { m_printMaxPage = v; };
244 void SetNoCopies(int v) { m_printNoCopies = v; };
245 void SetAllPages(bool flag) { m_printAllPages = flag; };
246 void SetSelection(bool flag) { m_printSelection = flag; };
247 void SetCollate(bool flag) { m_printCollate = flag; };
248 void SetPrintToFile(bool flag) { m_printToFile = flag; };
249 void SetSetupDialog(bool flag) { m_printSetupDialog = flag; };
250
251 void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; };
252 void EnableSelection(bool flag) { m_printEnableSelection = flag; };
253 void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; };
254 void EnableHelp(bool flag) { m_printEnableHelp = flag; };
255
256 bool GetEnablePrintToFile() const { return m_printEnablePrintToFile; };
257 bool GetEnableSelection() const { return m_printEnableSelection; };
258 bool GetEnablePageNumbers() const { return m_printEnablePageNumbers; };
259 bool GetEnableHelp() const { return m_printEnableHelp; };
260
261 wxPrintData& GetPrintData() { return m_printData; }
262 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
263
264 void operator=(const wxPrintDialogData& data);
265 void operator=(const wxPrintData& data); // Sets internal m_printData member
266
267 #ifdef __WXMSW__
268 // Convert to/from the PRINTDLG structure
269 void ConvertToNative();
270 void ConvertFromNative();
271 void SetOwnerWindow(wxWindow* win);
272 void* GetNativeData() const { return m_printDlgData; }
273 #endif
274
275 #ifdef __WXMSW__
276 void* m_printDlgData;
277 #endif
278
279 private:
280
281 int m_printFromPage;
282 int m_printToPage;
283 int m_printMinPage;
284 int m_printMaxPage;
285 int m_printNoCopies;
286 bool m_printAllPages;
287 bool m_printCollate;
288 bool m_printToFile;
289 bool m_printSelection;
290 bool m_printEnableSelection;
291 bool m_printEnablePageNumbers;
292 bool m_printEnableHelp;
293 bool m_printEnablePrintToFile;
294 bool m_printSetupDialog;
295
296 wxPrintData m_printData;
297 };
298
299 /*
300 * This is the data used (and returned) by the wxPageSetupDialog.
301 */
302
303 // Compatibility with old name
304 #define wxPageSetupData wxPageSetupDialogData
305
306 class WXDLLEXPORT wxPageSetupDialogData: public wxObject
307 {
308 DECLARE_DYNAMIC_CLASS(wxPageSetupDialogData)
309
310 public:
311 wxPageSetupDialogData();
312 wxPageSetupDialogData(const wxPageSetupDialogData& dialogData);
313 wxPageSetupDialogData(const wxPrintData& printData);
314 ~wxPageSetupDialogData();
315
316 wxSize GetPaperSize() const { return m_paperSize; };
317 wxPaperSize GetPaperId() const { return m_printData.GetPaperId(); };
318 wxPoint GetMinMarginTopLeft() const { return m_minMarginTopLeft; };
319 wxPoint GetMinMarginBottomRight() const { return m_minMarginBottomRight; };
320 wxPoint GetMarginTopLeft() const { return m_marginTopLeft; };
321 wxPoint GetMarginBottomRight() const { return m_marginBottomRight; };
322
323 bool GetDefaultMinMargins() const { return m_defaultMinMargins; };
324 bool GetEnableMargins() const { return m_enableMargins; };
325 bool GetEnableOrientation() const { return m_enableOrientation; };
326 bool GetEnablePaper() const { return m_enablePaper; };
327 bool GetEnablePrinter() const { return m_enablePrinter; };
328 bool GetDefaultInfo() const { return m_getDefaultInfo; };
329 bool GetEnableHelp() const { return m_enableHelp; };
330
331 // If a corresponding paper type is found in the paper database, will set the m_printData
332 // paper size id member as well.
333 void SetPaperSize(const wxSize& sz);
334
335 void SetPaperId(wxPaperSize& id) { m_printData.SetPaperId(id); };
336
337 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
338 void SetPaperSize(wxPaperSize id);
339
340 void SetMinMarginTopLeft(const wxPoint& pt) { m_minMarginTopLeft = pt; };
341 void SetMinMarginBottomRight(const wxPoint& pt) { m_minMarginBottomRight = pt; };
342 void SetMarginTopLeft(const wxPoint& pt) { m_marginTopLeft = pt; };
343 void SetMarginBottomRight(const wxPoint& pt) { m_marginBottomRight = pt; };
344 void SetDefaultMinMargins(bool flag) { m_defaultMinMargins = flag; };
345 void SetDefaultInfo(bool flag) { m_getDefaultInfo = flag; };
346
347 void EnableMargins(bool flag) { m_enableMargins = flag; };
348 void EnableOrientation(bool flag) { m_enableOrientation = flag; };
349 void EnablePaper(bool flag) { m_enablePaper = flag; };
350 void EnablePrinter(bool flag) { m_enablePrinter = flag; };
351 void EnableHelp(bool flag) { m_enableHelp = flag; };
352
353 #if defined(__WIN95__)
354 // Convert to/from the PAGESETUPDLG structure
355 void ConvertToNative();
356 void ConvertFromNative();
357 void SetOwnerWindow(wxWindow* win);
358 void* GetNativeData() const { return m_pageSetupData; }
359 #endif
360
361 // Use paper size defined in this object to set the wxPrintData
362 // paper id
363 void CalculateIdFromPaperSize();
364
365 // Use paper id in wxPrintData to set this object's paper size
366 void CalculatePaperSizeFromId();
367
368 void operator=(const wxPageSetupData& data);
369 void operator=(const wxPrintData& data);
370
371 wxPrintData& GetPrintData() { return m_printData; }
372 void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
373
374 #if defined(__WIN95__)
375 void* m_pageSetupData;
376 #endif
377
378 private:
379
380 wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
381 wxPoint m_minMarginTopLeft;
382 wxPoint m_minMarginBottomRight;
383 wxPoint m_marginTopLeft;
384 wxPoint m_marginBottomRight;
385
386 // Flags
387 bool m_defaultMinMargins;
388 bool m_enableMargins;
389 bool m_enableOrientation;
390 bool m_enablePaper;
391 bool m_enablePrinter;
392 bool m_getDefaultInfo; // Equiv. to PSD_RETURNDEFAULT
393 bool m_enableHelp;
394
395 wxPrintData m_printData;
396 };
397
398 #endif // wxUSE_PRINTING_ARCHITECTURE
399
400 #endif
401 // _WX_CMNDATA_H_BASE_