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