group wxPlatformInfo functions for easier browsing; add more descriptions; link the...
[wxWidgets.git] / interface / wx / platinfo.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: platinfo.h
3 // Purpose: interface of wxPlatformInfo
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 /**
11 The following are the operating systems which are recognized by wxWidgets and
12 whose version can be detected at run-time.
13
14 The values of the constants are chosen so that they can be combined as flags;
15 this allows to check for operating system families like e.g. wxOS_MAC and wxOS_UNIX.
16 */
17 enum wxOperatingSystemId
18 {
19 wxOS_UNKNOWN = 0, //!< returned on error
20
21 wxOS_MAC_OS = 1 << 0, //!< Apple Mac OS 8/9/X with Mac paths
22 wxOS_MAC_OSX_DARWIN = 1 << 1, //!< Apple Mac OS X with Unix paths
23 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
24
25 wxOS_WINDOWS_9X = 1 << 2, //!< Windows 9x family (95/98/ME)
26 wxOS_WINDOWS_NT = 1 << 3, //!< Windows NT family (NT/2000/XP)
27 wxOS_WINDOWS_MICRO = 1 << 4, //!< MicroWindows
28 wxOS_WINDOWS_CE = 1 << 5, //!< Windows CE (Window Mobile)
29 wxOS_WINDOWS = wxOS_WINDOWS_9X |
30 wxOS_WINDOWS_NT |
31 wxOS_WINDOWS_MICRO |
32 wxOS_WINDOWS_CE,
33
34 wxOS_UNIX_LINUX = 1 << 6, //!< Linux
35 wxOS_UNIX_FREEBSD = 1 << 7, //!< FreeBSD
36 wxOS_UNIX_OPENBSD = 1 << 8, //!< OpenBSD
37 wxOS_UNIX_NETBSD = 1 << 9, //!< NetBSD
38 wxOS_UNIX_SOLARIS = 1 << 10, //!< SunOS
39 wxOS_UNIX_AIX = 1 << 11, //!< AIX
40 wxOS_UNIX_HPUX = 1 << 12, //!< HP/UX
41 wxOS_UNIX = wxOS_UNIX_LINUX |
42 wxOS_UNIX_FREEBSD |
43 wxOS_UNIX_OPENBSD |
44 wxOS_UNIX_NETBSD |
45 wxOS_UNIX_SOLARIS |
46 wxOS_UNIX_AIX |
47 wxOS_UNIX_HPUX,
48
49 wxOS_DOS = 1 << 15, //!< Microsoft DOS
50 wxOS_OS2 = 1 << 16 //!< OS/2
51 };
52
53 /**
54 The list of wxWidgets ports.
55
56 Some of them can be used with more than a single (native) toolkit;
57 e.g. wxWinCE port sources can be used with smartphones, pocket PCs
58 and handheld devices SDKs.
59 */
60 enum wxPortId
61 {
62 wxPORT_UNKNOWN = 0, //!< returned on error
63
64 wxPORT_BASE = 1 << 0, //!< wxBase, no native toolkit used
65
66 wxPORT_MSW = 1 << 1, //!< wxMSW, native toolkit is Windows API
67 wxPORT_MOTIF = 1 << 2, //!< wxMotif, using [Open]Motif or Lesstif
68 wxPORT_GTK = 1 << 3, //!< wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
69 wxPORT_MGL = 1 << 4, //!< wxMGL, using wxUniversal
70 wxPORT_X11 = 1 << 5, //!< wxX11, using wxUniversal
71 wxPORT_OS2 = 1 << 6, //!< wxOS2, using OS/2 Presentation Manager
72 wxPORT_MAC = 1 << 7, //!< wxMac, using Carbon or Classic Mac API
73 wxPORT_COCOA = 1 << 8, //!< wxCocoa, using Cocoa NextStep/Mac API
74 wxPORT_WINCE = 1 << 9, //!< wxWinCE, toolkit is WinCE SDK API
75 wxPORT_PALMOS = 1 << 10, //!< wxPalmOS, toolkit is PalmOS API
76 wxPORT_DFB = 1 << 11 //!< wxDFB, using wxUniversal
77 };
78
79
80 /**
81 The architecture of the operating system
82 (regardless of the build environment of wxWidgets library - see ::wxIsPlatform64bit()
83 documentation for more info).
84 */
85 enum wxArchitecture
86 {
87 wxARCH_INVALID = -1, //!< returned on error
88
89 wxARCH_32, //!< 32 bit
90 wxARCH_64, //!< 64 bit
91
92 wxARCH_MAX
93 };
94
95
96 /**
97 The endian-ness of the machine.
98 */
99 enum wxEndianness
100 {
101 wxENDIAN_INVALID = -1, //!< returned on error
102
103 wxENDIAN_BIG, //!< 4321
104 wxENDIAN_LITTLE, //!< 1234
105 wxENDIAN_PDP, //!< 3412
106
107 wxENDIAN_MAX
108 };
109
110
111 /**
112 @class wxPlatformInfo
113
114 This class holds informations about the operating system, the toolkit and the
115 basic architecture of the machine where the application is currently running.
116
117 This class does not only have @e getters for the informations above, it also has
118 @e setters. This allows you to e.g. save the current platform informations in a
119 data file (maybe in string form) so that when you later load it, you can easily
120 retrieve (see the static getters for string->enum conversion functions) the
121 signature of the system which generated it.
122
123 @library{wxbase}
124 @category{cfg}
125
126 @see ::wxGetOsVersion(), wxIsPlatformLittleEndian(), wxIsPlatform64Bit(),
127 wxAppTraits, @ref group_funcmacro_networkuseros
128 */
129 class wxPlatformInfo : public wxObject
130 {
131 public:
132
133 /**
134 Initializes the instance with the values corresponding to the currently
135 running platform.
136
137 This is a fast operation because it only requires to copy the values
138 internally cached for the currently running platform.
139
140 @see Get()
141 */
142 wxPlatformInfo();
143
144 /**
145 Initializes the object using given values.
146 */
147 wxPlatformInfo(wxPortId pid = wxPORT_UNKNOWN,
148 int tkMajor = -1,
149 int tkMinor = -1,
150 wxOperatingSystemId id = wxOS_UNKNOWN,
151 int osMajor = -1,
152 int osMinor = -1,
153 wxArchitecture arch = wxARCH_INVALID,
154 wxEndianness endian = wxENDIAN_INVALID);
155
156
157 /**
158 Returns @true if the OS version is at least @c major.minor.
159
160 @see GetOSMajorVersion(), GetOSMinorVersion(),
161 CheckToolkitVersion()
162 */
163 bool CheckOSVersion(int major, int minor) const;
164
165 /**
166 Returns @true if the toolkit version is at least @c major.minor.
167
168 @see GetToolkitMajorVersion(),
169 GetToolkitMinorVersion(), CheckOSVersion()
170 */
171 bool CheckToolkitVersion(int major, int minor) const;
172
173
174 /**
175 Returns @true if this instance is fully initialized with valid values.
176 */
177 bool IsOk() const;
178
179 /**
180 Returns @true if this wxPlatformInfo describes wxUniversal build.
181 */
182 bool IsUsingUniversalWidgets() const;
183
184 /**
185 Inequality operator. Tests all class' internal variables.
186 */
187 bool operator!=(const wxPlatformInfo& t) const;
188
189 /**
190 Equality operator. Tests all class' internal variables.
191 */
192 bool operator==(const wxPlatformInfo& t) const;
193
194 /**
195 Returns the global wxPlatformInfo object, initialized with the values
196 for the currently running platform.
197 */
198 static const wxPlatformInfo& Get();
199
200 /**
201 @name Static enum getters
202
203 These getters allow for easy string-to-enumeration-value conversion.
204 */
205 //@{
206
207 /**
208 Converts the given string to a wxArchitecture enum value or to
209 @c wxARCH_INVALID if the given string is not a valid architecture string
210 (i.e. does not contain nor @c 32 nor @c 64 strings).
211 */
212 static wxArchitecture GetArch(const wxString& arch);
213
214 /**
215 Converts the given string to a wxEndianness enum value or to
216 @c wxENDIAN_INVALID if the given string is not a valid endianness
217 string (i.e. does not contain nor little nor big strings).
218 */
219 static wxEndianness GetEndianness(const wxString& end);
220
221 /**
222 Converts the given string to a wxOperatingSystemId enum value or to @c
223 wxOS_UNKNOWN if the given string is not a valid operating system name.
224 */
225 static wxOperatingSystemId GetOperatingSystemId(const wxString& name);
226
227 /**
228 Converts the given string to a wxWidgets port ID value or to @c wxPORT_UNKNOWN
229 if the given string does not match any of the wxWidgets canonical name ports
230 ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).
231 */
232 static wxPortId GetPortId(const wxString& portname);
233
234 //@}
235
236
237 /**
238 @name Static string-form getters
239
240 These getters allow for easy enumeration-value-to-string conversion.
241 */
242 //@{
243
244 /**
245 Returns the name for the given wxArchitecture enumeration value.
246 */
247 static wxString GetArchName(wxArchitecture arch);
248
249 /**
250 Returns name for the given wxEndianness enumeration value.
251 */
252 static wxString GetEndiannessName(wxEndianness end);
253
254 /**
255 Returns the operating system family name for the given wxOperatingSystemId
256 enumeration value: @c Unix for @c wxOS_UNIX, @c Macintosh for @c wxOS_MAC,
257 @c Windows for @c wxOS_WINDOWS, @c DOS for @c wxOS_DOS, @c OS/2 for @c wxOS_OS2.
258 */
259 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
260
261 /**
262 Returns the name for the given operating system ID value.
263
264 This can be a long name (e.g. <tt>Microsoft Windows NT</tt>);
265 use GetOperatingSystemFamilyName() to retrieve a short, generic name.
266 */
267 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
268
269 /**
270 Returns the name of the given wxWidgets port ID value.
271 The @a usingUniversal argument specifies whether the port is in its native
272 or wxUniversal variant.
273
274 The returned string always starts with the "wx" prefix and is a mixed-case string.
275 */
276 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
277
278 /**
279 Returns the short name of the given wxWidgets port ID value.
280 The @a usingUniversal argument specifies whether the port is in its native
281 or wxUniversal variant.
282
283 The returned string does not start with the "wx" prefix and is always lower case.
284 */
285 static wxString GetPortIdShortName(wxPortId port,
286 bool usingUniversal);
287
288 //@}
289
290
291 /**
292 @name Getters
293 */
294 //@{
295
296 /**
297 Returns the architecture ID of this wxPlatformInfo instance.
298 */
299 wxArchitecture GetArchitecture() const;
300
301 /**
302 Returns the endianness ID of this wxPlatformInfo instance.
303 */
304 wxEndianness GetEndianness() const;
305
306 /**
307 Returns the run-time major version of the OS associated with this
308 wxPlatformInfo instance.
309
310 @see ::wxGetOsVersion(), CheckOSVersion()
311 */
312 int GetOSMajorVersion() const;
313
314 /**
315 Returns the run-time minor version of the OS associated with this
316 wxPlatformInfo instance.
317
318 @see ::wxGetOsVersion(), CheckOSVersion()
319 */
320 int GetOSMinorVersion() const;
321
322 /**
323 Returns the operating system ID of this wxPlatformInfo instance.
324 */
325 wxOperatingSystemId GetOperatingSystemId() const;
326
327 /**
328 Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
329 */
330 wxPortId GetPortId() const;
331
332 /**
333 Returns the run-time major version of the toolkit associated with this
334 wxPlatformInfo instance.
335
336 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
337 (unless externally modified with SetToolkitVersion()); that is, no native
338 toolkit is in use.
339 See wxAppTraits::GetToolkitVersion() for more info.
340
341 @see CheckToolkitVersion()
342 */
343 int GetToolkitMajorVersion() const;
344
345 /**
346 Returns the run-time minor version of the toolkit associated with this
347 wxPlatformInfo instance.
348
349 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
350 (unless externally modified with SetToolkitVersion()); that is, no native
351 toolkit is in use.
352 See wxAppTraits::GetToolkitVersion() for more info.
353
354 @see CheckToolkitVersion()
355 */
356 int GetToolkitMinorVersion() const;
357
358 //@}
359
360
361 /**
362 @name String-form getters
363 */
364 //@{
365
366 /**
367 Returns the name for the architecture of this wxPlatformInfo instance.
368 */
369 wxString GetArchName() const;
370
371 /**
372 Returns the name for the endianness of this wxPlatformInfo instance.
373 */
374 wxString GetEndiannessName() const;
375
376 /**
377 Returns the operating system family name of the OS associated with this
378 wxPlatformInfo instance.
379 */
380 wxString GetOperatingSystemFamilyName() const;
381
382 /**
383 Returns the operating system name of the OS associated with this wxPlatformInfo
384 instance.
385 */
386 wxString GetOperatingSystemIdName() const;
387
388 /**
389 Returns the name of the wxWidgets port ID associated with this wxPlatformInfo
390 instance.
391 */
392 wxString GetPortIdName() const;
393
394 /**
395 Returns the short name of the wxWidgets port ID associated with this
396 wxPlatformInfo instance.
397 */
398 wxString GetPortIdShortName() const;
399
400 //@}
401
402
403
404 /**
405 @name Setters
406 */
407 //@{
408
409 /**
410 Sets the architecture enum value associated with this wxPlatformInfo instance.
411 */
412 void SetArchitecture(wxArchitecture n);
413
414 /**
415 Sets the endianness enum value associated with this wxPlatformInfo instance.
416 */
417 void SetEndianness(wxEndianness n);
418
419 /**
420 Sets the version of the operating system associated with this wxPlatformInfo
421 instance.
422 */
423 void SetOSVersion(int major, int minor);
424
425 /**
426 Sets the operating system associated with this wxPlatformInfo instance.
427 */
428 void SetOperatingSystemId(wxOperatingSystemId n);
429
430 /**
431 Sets the wxWidgets port ID associated with this wxPlatformInfo instance.
432 */
433 void SetPortId(wxPortId n);
434
435 /**
436 Sets the version of the toolkit associated with this wxPlatformInfo instance.
437 */
438 void SetToolkitVersion(int major, int minor);
439
440 //@}
441
442 };
443