]> git.saurik.com Git - wxWidgets.git/blob - include/wx/paper.h
Must have valid colours for X11 popup window implementation
[wxWidgets.git] / include / wx / paper.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: paper.h
3 // Purpose: Paper database types and classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PAPERH__
13 #define _WX_PAPERH__
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "paper.h"
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/event.h"
21 #include "wx/cmndata.h"
22 #include "wx/intl.h"
23 #include "wx/hashmap.h"
24
25 /*
26 * Paper type: see defs.h for wxPaperSize enum.
27 * A wxPrintPaperType can have an id and a name, or just a name and wxPAPER_NONE,
28 * so you can add further paper types without needing new ids.
29 */
30
31 #ifdef __WXMSW__
32 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, platformId, name, w, h)
33 #else
34 #define WXADDPAPER(paperId, platformId, name, w, h) AddPaperType(paperId, 0, name, w, h)
35 #endif
36
37 class WXDLLEXPORT wxPrintPaperType: public wxObject
38 {
39 public:
40 wxPrintPaperType();
41
42 // platformId is a platform-specific id, such as in Windows, DMPAPER_...
43 wxPrintPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h);
44
45 inline wxString GetName() const { return wxGetTranslation(m_paperName); }
46 inline wxPaperSize GetId() const { return m_paperId; }
47 inline int GetPlatformId() const { return m_platformId; }
48
49 // Get width and height in tenths of a millimetre
50 inline int GetWidth() const { return m_width; }
51 inline int GetHeight() const { return m_height; }
52
53 // Get size in tenths of a millimetre
54 inline wxSize GetSize() const { return wxSize(m_width, m_height); }
55
56 // Get size in a millimetres
57 inline wxSize GetSizeMM() const { return wxSize(m_width/10, m_height/10); }
58
59 // Get width and height in device units (1/72th of an inch)
60 wxSize GetSizeDeviceUnits() const ;
61
62 public:
63 wxPaperSize m_paperId;
64 int m_platformId;
65 int m_width; // In tenths of a millimetre
66 int m_height; // In tenths of a millimetre
67 wxString m_paperName;
68
69 private:
70 DECLARE_DYNAMIC_CLASS(wxPrintPaperType)
71 };
72
73 WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType*, wxStringToPrintPaperTypeHashMap);
74
75 class WXDLLEXPORT wxPrintPaperTypeList;
76
77 class WXDLLEXPORT wxPrintPaperDatabase
78 {
79 public:
80 wxPrintPaperDatabase();
81 ~wxPrintPaperDatabase();
82
83 void CreateDatabase();
84 void ClearDatabase();
85
86 void AddPaperType(wxPaperSize paperId, const wxString& name, int w, int h);
87 void AddPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h);
88
89 // Find by name
90 wxPrintPaperType *FindPaperType(const wxString& name);
91
92 // Find by size id
93 wxPrintPaperType *FindPaperType(wxPaperSize id);
94
95 // Find by platform id
96 wxPrintPaperType *FindPaperTypeByPlatformId(int id);
97
98 // Find by size
99 wxPrintPaperType *FindPaperType(const wxSize& size);
100
101 // Convert name to size id
102 wxPaperSize ConvertNameToId(const wxString& name);
103
104 // Convert size id to name
105 wxString ConvertIdToName(wxPaperSize paperId);
106
107 // Get the paper size
108 wxSize GetSize(wxPaperSize paperId);
109
110 // Get the paper size
111 wxPaperSize GetSize(const wxSize& size);
112
113 //
114 wxPrintPaperType* Item(size_t index) const;
115 size_t GetCount() const;
116 private:
117 wxStringToPrintPaperTypeHashMap* m_map;
118 wxPrintPaperTypeList* m_list;
119 // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase)
120 };
121
122 WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase;
123
124
125 #endif
126 // _WX_PAPERH__