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