]> git.saurik.com Git - wxWidgets.git/blob - include/wx/platinfo.h
Commit wxComboCtrl clipping patch from J. Salli
[wxWidgets.git] / include / wx / platinfo.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/platinfo.h
3 // Purpose: declaration of the wxPlatformInfo class
4 // Author: Francesco Montorsi
5 // Modified by:
6 // Created: 07.07.2006 (based on wxToolkitInfo)
7 // RCS-ID: $Id$
8 // Copyright: (c) 2006 Francesco Montorsi
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PLATINFO_H_
13 #define _WX_PLATINFO_H_
14
15 #include "wx/string.h"
16
17 // ----------------------------------------------------------------------------
18 // wxPlatformInfo
19 // ----------------------------------------------------------------------------
20
21 // VERY IMPORTANT: when changing these enum values, also change the relative
22 // string tables in src/common/platinfo.cpp
23
24
25 // families & sub-families of operating systems
26 enum wxOperatingSystemId
27 {
28 wxOS_UNKNOWN = 0, // returned on error
29
30 wxOS_MAC_OS = 1 << 0, // Apple Mac OS 8/9/X with Mac paths
31 wxOS_MAC_OSX_DARWIN = 1 << 1, // Apple Mac OS X with Unix paths
32 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
33
34 wxOS_WINDOWS_9X = 1 << 2, // Windows 9x family (95/98/ME)
35 wxOS_WINDOWS_NT = 1 << 3, // Windows NT family (NT/2000/XP)
36 wxOS_WINDOWS_MICRO = 1 << 4, // MicroWindows
37 wxOS_WINDOWS_CE = 1 << 5, // Windows CE (Window Mobile)
38 wxOS_WINDOWS = wxOS_WINDOWS_9X |
39 wxOS_WINDOWS_NT |
40 wxOS_WINDOWS_MICRO |
41 wxOS_WINDOWS_CE,
42
43 wxOS_UNIX_LINUX = 1 << 6, // Linux
44 wxOS_UNIX_FREEBSD = 1 << 7, // FreeBSD
45 wxOS_UNIX_OPENBSD = 1 << 8, // OpenBSD
46 wxOS_UNIX_NETBSD = 1 << 9, // NetBSD
47 wxOS_UNIX_SOLARIS = 1 << 10, // SunOS
48 wxOS_UNIX_AIX = 1 << 11, // AIX
49 wxOS_UNIX_HPUX = 1 << 12, // HP/UX
50 wxOS_UNIX = wxOS_UNIX_LINUX |
51 wxOS_UNIX_FREEBSD |
52 wxOS_UNIX_OPENBSD |
53 wxOS_UNIX_NETBSD |
54 wxOS_UNIX_SOLARIS |
55 wxOS_UNIX_AIX |
56 wxOS_UNIX_HPUX,
57
58 // 1<<13 and 1<<14 available for other Unix flavours
59
60 wxOS_DOS = 1 << 15, // Microsoft DOS
61 wxOS_OS2 = 1 << 16 // OS/2
62 };
63
64 // list of wxWidgets ports - some of them can be used with more than
65 // a single toolkit.
66 enum wxPortId
67 {
68 wxPORT_UNKNOWN = 0, // returned on error
69
70 wxPORT_BASE = 1 << 0, // wxBase, no native toolkit used
71
72 wxPORT_MSW = 1 << 1, // wxMSW, native toolkit is Windows API
73 wxPORT_MOTIF = 1 << 2, // wxMotif, using [Open]Motif or Lesstif
74 wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
75 wxPORT_MGL = 1 << 4, // wxMGL, using wxUniversal
76 wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal
77 wxPORT_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager
78 wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager
79 wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
80 wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
81 wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
82 wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API
83 wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal
84 };
85
86 // architecture of the operating system
87 // (regardless of the build environment of wxWidgets library - see
88 // wxIsPlatform64bit documentation for more info)
89 enum wxArchitecture
90 {
91 wxARCH_INVALID = -1, // returned on error
92
93 wxARCH_32, // 32 bit
94 wxARCH_64,
95
96 wxARCH_MAX
97 };
98
99
100 // endian-ness of the machine
101 enum wxEndianness
102 {
103 wxENDIAN_INVALID = -1, // returned on error
104
105 wxENDIAN_BIG, // 4321
106 wxENDIAN_LITTLE, // 1234
107 wxENDIAN_PDP, // 3412
108
109 wxENDIAN_MAX
110 };
111
112 // Information about the toolkit that the app is running under and some basic
113 // platform and architecture info
114 class WXDLLIMPEXP_BASE wxPlatformInfo
115 {
116 public:
117 wxPlatformInfo();
118 wxPlatformInfo(wxPortId pid,
119 int tkMajor = -1, int tkMinor = -1,
120 wxOperatingSystemId id = wxOS_UNKNOWN,
121 int osMajor = -1, int osMinor = -1,
122 wxArchitecture arch = wxARCH_INVALID,
123 wxEndianness endian = wxENDIAN_INVALID,
124 bool usingUniversal = false);
125
126 // default copy ctor, assignment operator and dtor are ok
127
128 bool operator==(const wxPlatformInfo &t) const;
129
130 bool operator!=(const wxPlatformInfo &t) const
131 { return !(*this == t); }
132
133
134 // string -> enum conversions
135 // ---------------------------------
136
137 static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
138 static wxPortId GetPortId(const wxString &portname);
139
140 static wxArchitecture GetArch(const wxString &arch);
141 static wxEndianness GetEndianness(const wxString &end);
142
143 // enum -> string conversions
144 // ---------------------------------
145
146 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
147 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
148 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
149 static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
150
151 static wxString GetArchName(wxArchitecture arch);
152 static wxString GetEndiannessName(wxEndianness end);
153
154 // getters
155 // -----------------
156
157 int GetOSMajorVersion() const
158 { return m_osVersionMajor; }
159 int GetOSMinorVersion() const
160 { return m_osVersionMinor; }
161
162 int GetToolkitMajorVersion() const
163 { return m_tkVersionMajor; }
164 int GetToolkitMinorVersion() const
165 { return m_tkVersionMinor; }
166
167 bool IsUsingUniversalWidgets() const
168 { return m_usingUniversal; }
169
170 wxOperatingSystemId GetOperatingSystemId() const
171 { return m_os; }
172 wxPortId GetPortId() const
173 { return m_port; }
174 wxArchitecture GetArchitecture() const
175 { return m_arch; }
176 wxEndianness GetEndianness() const
177 { return m_endian; }
178
179
180 // string getters
181 // -----------------
182
183 wxString GetOperatingSystemFamilyName() const
184 { return GetOperatingSystemFamilyName(m_os); }
185 wxString GetOperatingSystemIdName() const
186 { return GetOperatingSystemIdName(m_os); }
187 wxString GetPortIdName() const
188 { return GetPortIdName(m_port, m_usingUniversal); }
189 wxString GetPortIdShortName() const
190 { return GetPortIdShortName(m_port, m_usingUniversal); }
191 wxString GetArchName() const
192 { return GetArchName(m_arch); }
193 wxString GetEndiannessName() const
194 { return GetEndiannessName(m_endian); }
195
196 // setters
197 // -----------------
198
199 void SetOSVersion(int major, int minor)
200 { m_osVersionMajor=major; m_osVersionMinor=minor; }
201 void SetToolkitVersion(int major, int minor)
202 { m_tkVersionMajor=major; m_tkVersionMinor=minor; }
203
204 void SetOperatingSystemId(wxOperatingSystemId n)
205 { m_os=n; }
206 void SetPortId(wxPortId n)
207 { m_port=n; }
208 void SetArchitecture(wxArchitecture n)
209 { m_arch=n; }
210 void SetEndianness(wxEndianness n)
211 { m_endian=n; }
212
213 // miscellaneous
214 // -----------------
215
216 bool IsOk() const
217 {
218 return m_osVersionMajor != -1 && m_osVersionMinor != -1 &&
219 m_os != wxOS_UNKNOWN &&
220 m_tkVersionMajor != -1 && m_tkVersionMinor != -1 &&
221 m_port != wxPORT_UNKNOWN &&
222 m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID;
223 }
224
225
226 protected:
227 // OS stuff
228 // -----------------
229
230 // Version of the OS; valid if m_os != wxOS_UNKNOWN
231 // (-1 means not initialized yet).
232 int m_osVersionMajor, m_osVersionMinor;
233
234 // Operating system ID.
235 wxOperatingSystemId m_os;
236
237
238 // toolkit
239 // -----------------
240
241 // Version of the underlying toolkit
242 // (-1 means not initialized yet; zero means no toolkit).
243 int m_tkVersionMajor, m_tkVersionMinor;
244
245 // name of the wxWidgets port
246 wxPortId m_port;
247
248 // is using wxUniversal widgets?
249 bool m_usingUniversal;
250
251
252 // others
253 // -----------------
254
255 // architecture of the OS
256 wxArchitecture m_arch;
257
258 // endianness of the machine
259 wxEndianness m_endian;
260 };
261
262
263 #if WXWIN_COMPATIBILITY_2_6
264 #define wxUNKNOWN_PLATFORM wxOS_UNKNOWN
265 #define wxUnix wxOS_UNIX
266 #define wxWin95 wxOS_WINDOWS_9X
267 #define wxWIN95 wxOS_WINDOWS_9X
268 #define wxWINDOWS_NT wxOS_WINDOWS_NT
269 #define wxMSW wxOS_WINDOWS
270 #define wxWinCE wxOS_WINDOWS_CE
271 #define wxWIN32S wxOS_WINDOWS_9X
272
273 #define wxPalmOS wxPORT_PALMOS
274 #define wxOS2 wxPORT_OS2
275 #define wxMGL wxPORT_MGL
276 #define wxCocoa wxPORT_MAC
277 #define wxMac wxPORT_MAC
278 #define wxMotif wxPORT_MOTIF
279 #define wxGTK wxPORT_GTK
280 #endif // WXWIN_COMPATIBILITY_2_6
281
282 #endif // _WX_PLATINFO_H_